I'm trying to do some smoothing with lme and am having some difficulty
bringing commands over from S-PLUS to R. I have the following setup
(modified from Ngo and Wand, 2004):
set.seed(1)
x <- runif(200)
y <- sin(3*pi*x) + rnorm(200)*.4
## library(splines)
z <- ns(x, 4)
The following runs without error on S-PLUS
f <- lme(y ~ 1, random = pdIdent(~ -1 + z))
But in R I get
library(nlme)
> f <- lme(y ~ 1, random = pdIdent(~ -1 + z))
Error in getGroups.data.frame(dataMix, groups) :
Invalid formula for groups
Does the S-PLUS lme have some default setting that R doesn't? Any help
would be appreciated.
Thanks,
-roger
"Roger D. Peng" <rpeng at jhsph.edu> writes:> f <- lme(y ~ 1, random = pdIdent(~ -1 + z)) > > But in R I get > > library(nlme) > > f <- lme(y ~ 1, random = pdIdent(~ -1 + z)) > Error in getGroups.data.frame(dataMix, groups) : > Invalid formula for groups > > Does the S-PLUS lme have some default setting that R doesn't? Any > help would be appreciated.Which version of S-PLUS? lme has changed and the newer versions insist on having grouping levels for the random effects, so I think you're looking for> g <- rep(1,200) > f <- lme(y ~ 1, random = list(g=pdIdent(~ z-1))) > fLinear mixed-effects model fit by REML Data: NULL Log-restricted-likelihood: -111.2290 Fixed: y ~ 1 (Intercept) 0.3568754 Random effects: Formula: ~z - 1 | g Structure: Multiple of an Identity z1 z2 z3 z4 Residual StdDev: 1.623315 1.623315 1.623315 1.623315 0.398023 Number of Observations: 200 Number of Groups: 1 -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907