On Fri, 2011-02-11 at 20:51 -0500, Axel Urbiz wrote: > Dear users, > > I'll appreciate your help with this (hopefully) simple problem. > > I have a model object which was fitted to inputs X1, X2, X3. Now, I'd like > to use this object to make predictions on a new data set where only X1 and > X2 are available (just use the estimated coefficients for these variables in > making predictions and ignoring the coefficient on X3). Here's my attempt > but, of course, didn't work. > > #fit some linear model to random data > > x=matrix(rnorm(100*3),100,3) > y=sample(1:2,100,replace=TRUE) > mydata <- data.frame(y,x) > mymodel <- lm(y ~ ns(X1, df=3) + X2 + X3, data=mydata) > summary(mymodel) > > #create new data with 1 missing input > > mynewdata <- data.frame(matrix(rnorm(100*2),100,2)) > mypred <- predict(mymodel, mynewdata) > Thanks in advance for your help! > > Axel.
Axel, I think mice package solve your problem -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil ______________________________________________ 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.