Displaying 2 results from an estimated 2 matches for "whichapproach".
2012 Sep 26
0
lme(y ~ ns(x, df=splineDF)) error
...handle splineDF
inside the wrapper function.
A workaround is to turn the lme() command, along with the appropriate
value of splineDF, into a text string and then use
eval(parse(text=mystring)). Is there not a more elegant solution?
The function below demonstrates this. According to the value of
WhichApproach (1, 2, or 3), it attempts one of the approaches that
does not work or the workaround using the text string.
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base...
2012 Sep 06
0
lme( y ~ ns(x, df=splineDF)) error
...0-6 MASS_7.3-18 memoise_0.1
munsell_0.3 plyr_1.7.1
[11] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
scales_0.2.1 stringr_0.6
[16] tools_2.15.1
The following function can also be downloaded from
http://jacobwegelin.net/tmp/r-help/.
wrapper <-function(WhichApproach=1, splineDF=4 ){
# Create toy dataset
nID<-25
IDnames<-LETTERS[1:nID]
longdat<-data.frame( x=rep(-10:10, nID) / 3 , ID= rep( IDnames , each=21)
)
set.seed(5)
longdat$x<-longdat$x + rnorm(nrow(longdat))/10
IDeffect<-rnorm(nID) * 20
names(IDeffect) <- IDnames
longdat$IDeffect<-I...