[R] Problem with calculating the residuals in an AR(p)-model

2009-02-17 Thread Spiderschwein

Hi,

I'm trying to calculate the residuals in a one-sided AR(p) model:
sum (phi_j (X_t-j - EX)) = epsilon

My X is an ARMA(1,1)-model, which can be represented as an AR(infty) model.
I calculate the order of the model with AIC and the parameters with the
Yule-Walker method.

For the residuals, I tried:

for (k in (p+1):n){ 
 for (j in 1:p){
  eps[k] - sum(phi[j] * (X[k-j] - mean(X)))
 }
 ceps[k] - eps[k] - sum(eps)/(n-p+1) #centering the residuals
}


The residuals in my ARMA(1,1)-models are t-distributed with 6 degrees of
freedom.
Unfortunately my code results in residuals, which are all around zero. So
ecdf(eps) or ecdf(ceps) are very different from a t(6)-distribution.

Where's the bug in my code?

Regards,
Martin
-- 
View this message in context: 
http://www.nabble.com/Problem-with-calculating-the-residuals-in-an-AR%28p%29-model-tp22055764p22055764.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re sampling from an ECDF

2008-12-04 Thread Spiderschwein

Good day everyone,

I have about 500 values to generate my ecdf.
Now I want to sample 2000 values i.i.d. distributed according to my ecdf.

Is it possible to sample from an ecdf? 
If yes, I would appreciate your help.

Martin

-- 
View this message in context: 
http://www.nabble.com/Resampling-from-an-ECDF-tp20831433p20831433.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re sampling from an ECDF

2008-12-04 Thread Spiderschwein

Say F_n is my ecdf, generated from my sample x.
With sample(x, 2000, replace = TRUE) I get a uniformly distributed sample
from x.

But I need a (re)sample, which is F_n distributed.
Now I'm confused, if that makes a difference or not...

Regards,
Martin



Dimitris Rizopoulos-4 wrote:
 
 say 'x' is your sample, then try
 
 sample(x, 2000, replace = TRUE)
 
 
 I hope it helps.
 
 Best,
 Dimitris
 -- 
 Dimitris Rizopoulos
 Assistant Professor
 Department of Biostatistics
 Erasmus Medical Center
 
 Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
 Tel: +31/(0)10/7043478
 Fax: +31/(0)10/7043014
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Resampling-from-an-ECDF-tp20831433p20835550.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to sample a block

2008-11-10 Thread Spiderschwein

Hi,
I want to sample a block of information.

Let's say x is a time series. Using sample(x,5) I get a random sample of
length 5 from x.

Is it possible to sample consecutive observations, i.e. I sample one
observation and also get the next 4 observations?

Thanks a lot!

Martin
-- 
View this message in context: 
http://www.nabble.com/how-to-sample-a-block-tp20418997p20418997.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.