Skip to content
Prev 247977 / 398503 Next

Error in ANOVA for model comparison

Dear Rosario,

Because of missing data in the additional variable PHt, the two models
weren't fit to the same subset of valid observations -- the default in lm()
is to use complete cases for the variables in the model. 

A mechanical solution is to use na.omit() to filter your data set, only for
the variables you intend to use, to produce a data set with no NAs. Then
you'll fit each model to a consistent subset of valid cases. 

Of course, if you have a substantial amount of missing data, complete-case
analysis is probably a poor strategy.

I hope this helps,
 John

--------------------------------
John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox