[R] Do YOU know an equation for splines (ns)?

Ranae ranae.dietzel at gmail.com
Mon Jun 11 21:31:14 CEST 2012


I was able to get the predicted values from the splines.  Thanks so much
for the help.

I wrote a loop with some of the code that Bill suggested.  It seems that
when using predict with nlme, it is important to be specific with what one
is using as newdata.  This does come through in Pinheiro and Bates, I just
didn't recognize it to begin with.  Bert, I did try your code, but was only
getting coefficients, so I may have neglected a step.

##The successful code:
library(nlme)
library(splines)

rootCN<-read.table("spline.txt", header=3DTRUE)
rootCN$plotF<-as.factor(rootCN$plot)
rcn10G<-groupedData(N ~ day | plotF, data=3DrootCN)

fit10 <- lme( N~ns(day, 3), data =3D rcn10G)

plot(augPred(fit10))


t<- 152:305
subject<-rootCN[11:22,2]
sim<-NULL
for(i in 1:12){
sim<- cbind(sim, predict(fit10, data.frame(day=3Dt, plotF=3Drep(subject[i],
length(t)))))
}
colnames(sim) <- c(subject)


par(mfrow=3Dc(4,3))
for(i in 1:12){
plot(t, sim[,i], type=3D"l", main=3Dsubject[i])
}


-Ranae

--
View this message in context: http://r.789695.n4.nabble.com/Do-YOU-know-an-equation-for-splines-ns-tp4632440p4633037.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list