Re: [R] gls prediction using the correlation structure in nlme
On Wed, Jan 28, 2009 at 9:51 AM, Dr Carbon drcar...@gmail.com wrote: How does one coerce predict.gls to incorporate the fitted correlation structure from the gls object into predictions? In the example below the AR(1) process with phi=0.545 is not used with predict.gls. Is there another function that does this? I'm going to want to fit a few dozen models varying in order from AR(1) to AR(3) and would like to look at the fits with the correlation structure included. Thanks in advance. -JC PS I am including the package maintainers on this post - does this constitute a maintainer-specific question in r-help etiquette? # example set.seed(123) x - arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100) y -x + arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100) x - c(x) y - c(y) lm1 - lm(y~x) ar(residuals(lm1)) # indicates an ar1 model cs1 - corARMA(p=1) fm1 - gls(y~x,corr=cs1) summary(fm1) # get fits fits - predict(fm1) # use coef to get fits fits2 - coef(fm1)[1] + coef(fm1)[2] * x plot(fits,fits2) I think this is the way to do this? b0 - coef(fm1)[1] b1 - coef(fm1)[2] p1 - intervals(fm1)$corStruct[2] y[i] = b0 + p1*y[i-1] + b1*x[i] __ 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] gls prediction using the correlation structure in nlme
How does one coerce predict.gls to incorporate the fitted correlation structure from the gls object into predictions? In the example below the AR(1) process with phi=0.545 is not used with predict.gls. Is there another function that does this? I'm going to want to fit a few dozen models varying in order from AR(1) to AR(3) and would like to look at the fits with the correlation structure included. Thanks in advance. -JC PS I am including the package maintainers on this post - does this constitute a maintainer-specific question in r-help etiquette? # example set.seed(123) x - arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100) y -x + arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100) x - c(x) y - c(y) lm1 - lm(y~x) ar(residuals(lm1)) # indicates an ar1 model cs1 - corARMA(p=1) fm1 - gls(y~x,corr=cs1) summary(fm1) # get fits fits - predict(fm1) # use coef to get fits fits2 - coef(fm1)[1] + (coef(fm1)[2] * x) plot(fits,fits2) __ 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] csaps in R port from Octave?
Since I'm getting no joy looking for an R implementation of the matlab function csaps, can anybody advise me on porting csaps from Octave? There is an octave implementation of csaps here: http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/nonfree/spline-gsvspl/inst/csaps.m This function calls external C function gcvspl located here: http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/nonfree/spline-gsvspl/src/gcvspl.cc Any C gurus out there care to opine on how hard this would be to port to an external C function that R could call. I need to be able to repeat results from csaps as part of a review and don't have access to Matlab (or inclination to install and learn Octave). Or, back to the original query, is there a way to mimic csaps in R? In particular I need to be able to repeat an analysis with the the same smoothing parameter (p) from csaps. Please help! ::DrC __ 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] csaps in R?
Is there is function in R equivalent to Matlab's csaps? I need a spline function with the same calculation of the smoothing parameter in csaps to compare some results. AFAIK, the spar in smooth.spline is related but not the same. __ 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.