0

i'am doing a stepwise logistic regression to find out which variables should be included into my model. Therefor i'm running this code: sara58.stepwist.swrexmilk.rumi <- step(SARA58.swrexMilk.rumi)

Where SARA58.swrexMilk.rumi is the glm function which works if i run it seperately. However when i run the code for step wise logistic regression the model does give some output but it gives also the next error message:

Error in stats::step(object, ...) : of rows in use has changed: remove missing values?

What am i doing wrong and how could improve my code? Thanks in advance

  • Hi, welcome to StackOverflow. Can you make a reproducible example? I.e. provide a small dataset on which you get the same error. This would allow people to replicate your error. See also: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – slamballais May 13 '21 at 11:59
  • Hi Laterow, i tried to take a small sample of my data however than the error does not occur. Unfortunally i'm not allowed to share my whole data-set. – PietroFleer May 14 '21 at 09:12
  • Hopefully somebody recognizes the error and is still able to give some feedback. – PietroFleer May 14 '21 at 09:13
  • So, without knowing the function: the error refers to "missing values". What could be the case, is that you have missings in variables that are not in all models. Since most R functions use `na.omit` (i.e. remove individuals with missingness), it could be that some models have fewer individuals than others. Can you check this? – slamballais May 14 '21 at 09:21
  • See also `?step`, under the header `Warning`. I think this is relevant for your problem: "The model fitting must apply the models to the same dataset. This may be a problem if there are missing values and R's default of na.action = na.omit is used. We suggest you remove the missing values first. Calls to the function nobs are used to check that the number of observations involved in the fitting process remains unchanged." – slamballais May 14 '21 at 09:22

0 Answers0