[R] Problem with groupedData and lme

Luc Villandre villandl at dms.umontreal.ca
Thu Jul 2 20:09:33 CEST 2009


Dear R-users,

I'm currently having trouble with the implementation of a groupedData 
object in the lme() function.

Executing the following function
> applyScalingSimp <- function(input.population)
> {
>         ## GA is a time value
>         varInOrder <- c("GA","weight","grouping","sex")
>         modelVar <- c("GA_","VARI1","id","v51026")
>         names(modelVar) <- varInOrder
>
>         ## The following re-expresses the time in the spline basis.
>         GASpline <- rcspline.eval(input.population[,modelVar["GA"]],
>                                     
> knots=quantile(input.population[,modelVar["GA"]],
>                                     
> probs=qVec<-c(0.05,0.275,0.5,0.725,0.95),na.rm=TRUE),
>                                     inclx=TRUE)
>
>         colnames(GASpline) <- 
> paste("GA",head(seq_along(qVec),n=-1),sep="")
>         input.population <- cbind(input.population,GASpline)
>
>         lmeFormula <- as.formula(paste("VARI1", "~", 
> modelVar["sex"],"+ (", paste(colnames(GASpline),sep="",collapse="+"), 
> ")|id"))
>         groupFrame <- groupedData(formula = lmeFormula, data = 
> input.population)
>
>         lme.output <- lme(  fixed=groupFrame,
>                             
> random=do.call(what="pdDiag",args=list(form=as.formula(paste("~",paste(colnames(GASpline),collapse="+"),sep="")))),
>                             correlation = corSymm,
>                             na.action=na.omit)
>
>         return(lme.output)
> }
with the following data.frame object as a value for the input.population 
argument
> "GA_" "VARI1" "id" "v51026"
> 123 7.28824594963692 5 1
> 185 9.97279896947955 5 1
> 231 11.4784464688259 5 1
> 262 12.3480880103964 5 1
> 277 12.7415557997424 5 1
> 131 7.52808268709084 38 1
> 176 9.5429893459525 38 1
> 232 11.4704437962050 38 1
> 258 12.1768098655929 38 1
> 280 12.5830142986889 38 1
> 126 7.3457418485436 41 2
> 177 9.66889759453008 41 2
> 232 11.4729189241886 41 2
> 261 12.1974400314058 41 2
> 292 12.2546939619415 41 2
> 124 7.17697081721814 56 2
> 174 9.40475505947726 56 2
> 230 11.4940807273184 56 2
> 250 11.9731637779112 56 2
> 294 12.8907335176616 56 2
yields the following error message
> Error in inherits(x, "data.frame") : object 'groupFrame' not found
However, groupFrame does exist (as shown by using the debug() function).

Can anyone here offer an explanation as to why this might be occurring?

Just in case you might want it...
>                _                           
> platform       i386-pc-mingw32             
> arch           i386                        
> os             mingw32                     
> system         i386, mingw32               
> status                                     
> major          2                           
> minor          9.0                         
> year           2009                        
> month          04                          
> day            17                          
> svn rev        48333                       
> language       R                           
> version.string R version 2.9.0 (2009-04-17)

Cheers,

-- 
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/




More information about the R-help mailing list