My aim is to carry out a generalized linear model (glm) with 1 response variable and 13 explanatory variables.Unfortunately 3 out of the 10 explanatory variables contain NA values (2/3 of data set of this 3 variables are NA values - in total 410 observations). I realized that the "step" function does not work with NA values (Why does the number of rows change during AIC in R? How to ensure that this doesn't happen?). Therfore my question: How can I proceed to automatically improve my glm without eliminating my sites with NA values?

Example (only 3 explanatory variables and 5 observations) enter image description here

  • $\begingroup$ Can you impute the values? How many observations are in your dataset and can you tell us a bit more about why the data might be missing? $\endgroup$ Apr 10, 2015 at 20:46
  • $\begingroup$ I added an example table. Does that clarify my question? Observations are missing because they were not measured at all sites. $\endgroup$
    – kalakaru
    Apr 10, 2015 at 20:54
  • $\begingroup$ Something doesn't seem right here. You only have 5 observations and you want to build a model with 13 explanatory variables? That just won't work. I must be missing something. Can you clarify? $\endgroup$ Apr 10, 2015 at 20:55
  • $\begingroup$ well no, that was just an example dataset... I actually have 410 observations. sorry for the confusion! $\endgroup$
    – kalakaru
    Apr 10, 2015 at 20:57

1 Answer 1


I see. Thanks for clarifying. I think you should considered or do you know about multiple imputation? It's a technique that you may want to consider here that allows you to "fill in" the missing values in your dataset with statistically reasonable guesses. Most statistical software packages have routines that will perform the imputation for you. Once you've imputed your data, you can then run your analyses on the multiple datasets that are created by the routine and then your results are averaged over the imputed data -- again the software does all that. What software are you using?

One thing to be aware of is that it's generally not a good idea to impute your data when you have larger proportions of missing data. What percentage of each of your variables is missing? Is there a way also to investigate or follow-up with your sites to determine the actual missing values?

  • $\begingroup$ Thanks! The missing data might be hard to guess (eg discharge) but I will have a look at the imputation method. I am using R. About 2/3 of my data is missing (250 NA of 410 observations). But the data is only missing for few Explanatory Variables. $\endgroup$
    – kalakaru
    Apr 10, 2015 at 21:09
  • $\begingroup$ Yes, multiple imputation make statistically valid best estimates of the missing values, so "guess" is kind of a strong word. The uncertainty in the "guesses" is taken into account when you perform analyses on your data using the procedures. You'll want to check out the "mice" or "mi" packages in R. $\endgroup$ Apr 10, 2015 at 21:14
  • 1
    $\begingroup$ If you are intending to use your model for predictions on new data sets and the variables with many NAs are often unavailable in practice, it might be best to omit such hard-to-obtain variables. Also, stepwise selection is not generally a very good way to build a model. See CV pages with the stepwise-regression tag, for example this page. $\endgroup$
    – EdM
    Apr 10, 2015 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.