[R] Extracting and using fitted values and residuals with missing data

Matt1299 reederm1 at gmail.com
Wed Aug 24 19:56:50 CEST 2011


Hi folks,

I've a basic question concerning missing data.  I'm running mixed effects
analyses using nlme.  I've a sizable chunk of missing data on the outcome
being modeled, and am using "na.action=na.omit" when running the models. 
After fitting the models, I'm then trying to extract and use the fitted
values and/or residuals for additional analysis, but keep hitting walls
which I believe stem from the missing data.  For instance, when I tried to
plot the residuals against one of the predictors in the models, I get the
error:

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ.

Similarly, if I try to get the variance of the residuals across levels of a
categorical predictor, I get the error:

Error in tapply(fitted(fm.1, level = 1), multi.2$catpred, var,  : 
  arguments must have same length

My question is how to circumvent the problem, as it's becoming a hindrance. 
I've tried basic/obvious solutions (e.g., when trying to get the residual
variances above, including "na.rm=T"), but nothing helps, and this seems to
simplistic of a problem for there not to be a solution (I've just not
stumbled across it).  Thanks in advance for any ideas.


Thanks,
Matt

--
View this message in context: http://r.789695.n4.nabble.com/Extracting-and-using-fitted-values-and-residuals-with-missing-data-tp3766156p3766156.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list