Hi! Does anyone know how to do the test for goodness of fit of a logistic model (in rms package) after running fit.mult.impute? I am using the rms and Hmisc packages to do a multiple imputation followed by a logistic regression model using lrm. Everything works fine until I try to run the test for goodness of fit: residuals(type=c("gof")) One needs to specify y=T and x=T in the fit. But I get a warning message when I do that with fit.multiple.impute. a<-aregImpute(~med.hist.err+ med.discr+newLiving+No.drugs+Days.categ+Los+Age+Ward+Sex, n.impute=20, nk=0,data=med.err) ddist<-datadist(Age,No.drugs,Days.categ, Sex, Living, Ward) options(datadist="ddist") fmi<-fit.mult.impute(med.hist.err~Age+No.drugs+Days.categ+Sex+Living+Ward, fitter=lrm, x=T, y=T,a,data=med.err) Error in 1:n.impute : NA/NaN argument In addition: Warning message: In 1:n.impute : numerical expression has 18 elements: only the first used It works to do the fit.mult.impute without x and y=T but then I get the following warning message when running residuals gof<-residuals(fmi, type=c("gof")) Error in residuals.lrm(fmi, type = c("gof")) : you did not specify y=T in the fit It was no problem to do the goodness of fit test when I ran the lrm on my complete data set without multiple imputation and fit.mult.impute. model.lrm<-lrm(med.hist.err~Age+No.drugs+Days +Sex+Living+Ward, x=TRUE, y=TRUE) gof<-residuals(model.lrm, type=c("gof")) Thanks Lina _________________ PhD student Linnaeus University Sweden [[alternative HTML version deleted]]
There is a problem passing x in the ... arguments to fit.mult.impute when the function has a formal argument starting with "x" (xtrans). To get around this specify xtrans=a to fit.mult.impute instead of just listing a. Frank Lina Hellstr?m wrote:> > Hi! > Does anyone know how to do the test for goodness of fit of a logistic > model (in rms package) after running fit.mult.impute? > > I am using the rms and Hmisc packages to do a multiple imputation followed > by a logistic regression model using lrm. > Everything works fine until I try to run the test for goodness of fit: > residuals(type=c("gof")) > One needs to specify y=T and x=T in the fit. But I get a warning message > when I do that with fit.multiple.impute. > > a<-aregImpute(~med.hist.err+ > med.discr+newLiving+No.drugs+Days.categ+Los+Age+Ward+Sex, n.impute=20, > nk=0,data=med.err) > ddist<-datadist(Age,No.drugs,Days.categ, Sex, Living, Ward) > options(datadist="ddist") > > fmi<-fit.mult.impute(med.hist.err~Age+No.drugs+Days.categ+Sex+Living+Ward, > fitter=lrm, x=T, y=T,a,data=med.err) > Error in 1:n.impute : NA/NaN argument > In addition: Warning message: > In 1:n.impute : numerical expression has 18 elements: only the first used > > It works to do the fit.mult.impute without x and y=T but then I get the > following warning message when running residuals > gof<-residuals(fmi, type=c("gof")) > Error in residuals.lrm(fmi, type = c("gof")) : > you did not specify y=T in the fit > > It was no problem to do the goodness of fit test when I ran the lrm on my > complete data set without multiple imputation and fit.mult.impute. > model.lrm<-lrm(med.hist.err~Age+No.drugs+Days +Sex+Living+Ward, x=TRUE, > y=TRUE) > gof<-residuals(model.lrm, type=c("gof")) > > Thanks > Lina > _________________ > PhD student > Linnaeus University > Sweden > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Rms-package-problems-with-fit-mult-impute-tp3619814p3621045.html Sent from the R help mailing list archive at Nabble.com.
Thank you Frank! Now it works perfectly fine. Regards Lina Message: 73 Date: Thu, 23 Jun 2011 14:13:06 -0700 (PDT) From: Frank Harrell <f.harrell@vanderbilt.edu> To: r-help@r-project.org Subject: Message-ID: <1308863586428-3621045.post@n4.nabble.com> Content-Type: text/plain; charset=UTF-8 There is a problem passing x in the ... arguments to fit.mult.impute when the function has a formal argument starting with "x" (xtrans). To get around this specify xtrans=a to fit.mult.impute instead of just listing a. Frank Lina Hellstr?m wrote:> > Hi! > Does anyone know how to do the test for goodness of fit of a logistic > model (in rms package) after running fit.mult.impute? > > I am using the rms and Hmisc packages to do a multiple imputation followed > by a logistic regression model using lrm. > Everything works fine until I try to run the test for goodness of fit: > residuals(type=c("gof")) > One needs to specify y=T and x=T in the fit. But I get a warning message > when I do that with fit.multiple.impute. > > a<-aregImpute(~med.hist.err+ > med.discr+newLiving+No.drugs+Days.categ+Los+Age+Ward+Sex, n.impute=20, > nk=0,data=med.err) > ddist<-datadist(Age,No.drugs,Days.categ, Sex, Living, Ward) > options(datadist="ddist") > > fmi<-fit.mult.impute(med.hist.err~Age+No.drugs+Days.categ+Sex+Living+Ward, > fitter=lrm, x=T, y=T,a,data=med.err) > Error in 1:n.impute : NA/NaN argument > In addition: Warning message: > In 1:n.impute : numerical expression has 18 elements: only the first used > > It works to do the fit.mult.impute without x and y=T but then I get the > following warning message when running residuals > gof<-residuals(fmi, type=c("gof")) > Error in residuals.lrm(fmi, type = c("gof")) : > you did not specify y=T in the fit > > It was no problem to do the goodness of fit test when I ran the lrm on my > complete data set without multiple imputation and fit.mult.impute. > model.lrm<-lrm(med.hist.err~Age+No.drugs+Days +Sex+Living+Ward, x=TRUE, > y=TRUE) > gof<-residuals(model.lrm, type=c("gof")) > > Thanks > Lina > _________________ > PhD student > Linnaeus University > Sweden[[alternative HTML version deleted]]