Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:39:20+00:00 2026-06-01T07:39:20+00:00

I am running a logistic regression in R and doing backward elimination inorder to

  • 0

I am running a logistic regression in R and doing “backward elimination” inorder to get my final model:

FulMod2 <- glm(surv~as.factor(tdate)+as.factor(tdate)+as.factor(sline)+as.factor(pgf)
                                    +as.factor(weight5)+as.factor(backfat5)+as.factor(srect2)
                                    +as.factor(bcs)+as.factor(loco3)+as.factor(fear3)
                                    +as.factor(teats)+as.factor(preudder)+as.factor(postudder)
                                    +as.factor(colos)+as.factor(tb5) +as.factor(respon3)
                                    +as.factor(feed5)+as.factor(bwt5)+as.factor(sex)
                                    +as.factor(fos2)+as.factor(gest3)+as.factor(int3),
                                    family=binomial(link="logit"),data=sof)

When trying to run the backward elimination script:

step(FulMod2,direction="backward",trace=FALSE)

I got this error message:

Error in step(FulMod2, direction = "backward", trace = FALSE) : 
  number of rows in use has changed: remove missing values?

This is the second model that I am running using the backward elimination function. The first model was fine when I did backward elimination to get my final model.

Any help would be very much appreciated!

Baz

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:39:21+00:00Added an answer on June 1, 2026 at 7:39 am

    In order to successfully run step() on your model for backwards selection, you should remove the cases in sof with missing data in the variables you are testing.

    myForm <- as.formula(surv~
      as.factor(tdate)+as.factor(tdate)+as.factor(sline)+as.factor(pgf)
      +as.factor(weight5)+as.factor(backfat5)+as.factor(srect2)
      +as.factor(bcs)+as.factor(loco3)+as.factor(fear3)
      +as.factor(teats)+as.factor(preudder)+as.factor(postudder)
      +as.factor(colos)+as.factor(tb5) +as.factor(respon3)
      +as.factor(feed5)+as.factor(bwt5)+as.factor(sex)
      +as.factor(fos2)+as.factor(gest3)+as.factor(int3))
    
    sofNoMis <- sof[which(complete.cases(sof[,all.vars(myForm)])),]
    
    FulMod2 <- glm(myForm,family=binomial(link="logit"),data=sofNoMis)
    
    step(FulMod2,direction="backward",trace=FALSE)
    

    In your comment, you mentioned that 1 out of 9 cases has missing data. However, I recommend checking that again with the above code, in case some of that missingness corresponded to variables not included in FulMod2. If you still have many incomplete cases, you might want to decide a priori if you can eliminate some of the variables with high missingness.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running the following logistic regression model in R and one of the important
I am doing logistic regression in R. Can somebody clarify what is the differences
I am attempting to run a pooled logistic regression with panel data and a
Running my play framework small app I get the following exception: ... Caused by:
Running a Play! app with Scala. I'm doing a request where the response is
running my program with gdb I get this: fem.o: malloc.c:3096: sYSMALLOc: Assertion `(old_top ==
Running into a problem where on certain servers we get an error that the
Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled
Running Solr on Tomcat 7 on Win 2008 Server. I am looping through a
Running my script through Devel::NYTProf showed that the following portion of code took up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.