Michele, This error means that some of the variables in your formula have missing values, and hence when these terms or added/dropped you have a different sample size. Hence, the AIC cannot be compared between different models. The solution is to create a compelete-data dataframe for the largest model, i.e none of the variables in the largest model should have any missing values. Then run stepAIC on this dataframe.
Best, Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu ----- Original Message ----- From: Michele Santacatterina <miksa...@gmail.com> Date: Wednesday, January 28, 2009 9:51 am Subject: [R] StepAIC with coxph To: R-help@r-project.org > Hi, > > i'm trying to apply StepAIC with coxph...but i have the same error: > > stepAIC(fitBMT) > Start: AIC=327.77 > Surv(TEMPO,morto==1) VOD + SESSO + ETA + ........ > > Error in dropterm.default(fit,scope$drop, scale=scale,trace=max(0, : > number of rows in use has changed: remove missing values? > > anybody know this error?? > > Thanks. > > Michele > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@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.