Reputation: 105
I have a dataset where I've fitted a linear model and I've tried to use the step function on this linear model. I get an error message "saying number of rows in use has changed: remove missing values?".
I noticed that a few of the observations (not many) in my dataset had NA values for one variable. I've seen similar questions which suggest using na.omit(), but when I do this I lose the observations. I want to keep the observations however, because they contain useful information for the other variables. Is there a way to use step and avoid losing the observations?
Upvotes: 0
Views: 164
Reputation: 149
You can call the nobs
function to check that the number of observations is unchanged, and its use.fallback
argument to potentially guess the missing values. The R documentation however recommends omitting the relevant data before running step
.
Upvotes: 1
Reputation: 55
I would discourage you from simply omitting the missing values if they are indeed really missing. You can use multiple imputation via Amelia to impute the data such that you have a full dataset.
see here: https://cran.r-project.org/web/packages/Amelia/Amelia.pdf also I would recommend reviewing the book "Statistical Analysis With Missing Data" by R. Little and D.B. Rubin.
Upvotes: 0