If you want fitted() to return NAs in the positions where there were NA's in data, use na.action=na.exclude in your call to lm(). E.g.,
> z <- data.frame(y=1:5, x=c(1,NA,3,3,5)) > fitted(lm(y~x, data=z)) 1 3 4 5 1.25 3.25 3.25 5.25 > fitted(lm(y~x, data=z, na.action=na.exclude)) 1 2 3 4 5 1.25 NA 3.25 3.25 5.25 I think the help file for model.matrix has more detail, including how to use options() to set the na.action for your R session. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of arunkumar1111 > Sent: Monday, November 14, 2011 3:36 AM > To: r-help@r-project.org > Subject: Re: [R] help in fitted values in lm function > > Yes there are few NA in the Data > > -- > View this message in context: > http://r.789695.n4.nabble.com/help-in-fitted-values-in-lm-function- > tp4038642p4039207.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.