[R] MITOOLS: Error in eval(expr, envir, enclos) : invalid 'envir' argument
Brant Inman
Inman.Brant at mayo.edu
Fri Jun 15 04:45:31 CEST 2007
Update: error solved.
The error was that one of the imputed datasets had a singular matrix. As
such, when eval tried to run the expression on that dataset (i.e.
environment) it did not find an appropriate dataset and therefore the
function returned an error. In other words, the problem was a bad input to
the with.imputationList function.
Brant Inman wrote:
>
>
> R-users & helpers:
>
> I am using Amelia, mitools and cmprsk to fit cumulative incidence curves
> to multiply imputed datasets. The error message that I get
>
> "Error in eval(expr, envir, enclos) : invalid 'envir' argument"
>
> occurs when I try to fit models to the 50 imputed datasets using the
> "with.imputationList" function of mitools. The problem seems to occur
> intermittently, depending on the type of model that I try to fit to the
> datasets as well as the previous code that has been executed during the
> R session. I have read the previous postings for similar problems and
> have tried renaming many of my objects which has not solved the problem.
>
>
> What is weird is that I have not been able to reproduce the problem
> using other standard survival datasets (like pbc). It therefore seems to
> have something to do with my particular analysis, likely the names of my
> objects. I cannot find the source of the problem and would greatly
> appreciate any help.
>
> Brant
>
> Below is my session information and some code demonstrating the issue
> occuring with coxph.
>
>> sessionInfo()
> R version 2.5.0 (2007-04-23)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
>
> attached base packages:
> [1] "splines" "grid" "stats" "graphics" "grDevices" "utils"
>
> [7] "datasets" "methods" "base"
>
> other attached packages:
> cmprsk mitools Amelia survival RGraphics
> latticeExtra
> "2.1-7" "1.0" "1.1-23" "2.31" "1.0-6"
> "0.2-1"
> lattice foreign MASS
> "0.15-8" "0.8-20" "7.2-34"
>
>
>> str(utt.mi) # My dataset
> 'data.frame': 168 obs. of 25 variables:
> $ age : num 79.5 67.1 63.7 76.9 69.0 ...
> $ gender : Factor w/ 2 levels "0","1": 1 2 2 2 1 2 2 2 2 2 ...
> $ symptoms : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 2 1 1 2 ...
> $ site : Factor w/ 3 levels "1","2","3": 1 1 2 1 2 1 1 2 1 3 ...
> $ multifoc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
> $ ctnm : Factor w/ 2 levels "1","2": 1 NA 2 1 2 2 1 NA 1 2 ...
> $ prebca : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 2 1 1 1 ...
> $ precystec: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
> $ surgery : Factor w/ 2 levels "1","2": 1 1 2 1 2 1 1 1 1 1 ...
> $ ptnm.t : Factor w/ 5 levels "0","1","2","3",..: 3 3 5 1 2 4 2 1 1 5
> ...
> $ grade : Factor w/ 3 levels "1","2","3": 2 2 3 2 2 3 2 1 1 3 ...
> $ histol : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ...
> $ postbca : Factor w/ 2 levels "0","1": 2 1 2 2 2 NA 2 1 1 1 ...
> $ postcyst : Factor w/ 2 levels "0","1": 1 1 1 2 1 1 1 1 1 1 ...
> $ chemo : Factor w/ 2 levels "0","1": 1 1 2 1 1 2 2 1 1 2 ...
> $ mets : Factor w/ 2 levels "0","1": 1 2 2 1 2 2 2 1 1 2 ...
> $ status : Factor w/ 4 levels "1","2","3","4": 1 3 2 1 3 3 3 1 1 3
> ...
> $ futime : num 10.46 1.15 2.43 2.83 6.82 ...
> $ smk : Factor w/ 2 levels "0","1": 2 2 2 1 2 1 2 1 2 2 ...
> $ surg.yr : int 88 94 92 93 86 85 95 98 91 85 ...
> $ nodes : Factor w/ 2 levels "0","1": 1 1 2 1 1 2 1 1 1 2 ...
> $ os : num 0 1 0 0 1 1 1 0 0 1 ...
> $ css : num 0 1 0 0 1 1 1 0 0 1 ...
> $ rfs : num 0 1 1 0 1 1 1 0 0 1 ...
> $ comp : num 0 1 1 0 1 1 1 0 0 1 ...
>
>> set.seed(200)
>> M <- 50 # Number of imputations
>> am.imp <- amelia(utt.mi, m=M, p2s=1, startvals=1, write.out=F,
> + idvars=c('os','css','rfs','comp'),
> +
> noms=c('gender','symptoms','site','multifoc','ctnm','prebca','precystec'
> ,
> + 'smk','surgery','ptnm.t','nodes','grade','histol','postbca',
> + 'postcyst','chemo','mets','status'),
> + sqrts=c('futime'))
> -- Imputation 1 --
>
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
>
> <snip>
>
> -- Imputation 50 --
>
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> 21 22 23 24 25 26
>
>> MIset <- imputationList(am.imp[1:M])
>> mifit <- with(MIset,
> + coxph(Surv(futime, os) ~ age + symptoms + ctnm + smk))
>
> Error in eval(expr, envir, enclos) : invalid 'envir' argument
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
--
View this message in context: http://www.nabble.com/MITOOLS%3A---Error-in-eval%28expr%2C-envir%2C-enclos%29-%3A-invalid-%27envir%27-argument-tf3885940.html#a11132419
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list