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

  • SEARCH
  • Home
  • 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 7494145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:20:48+00:00 2026-05-29T17:20:48+00:00

I ran a logit model and am trying to plot the probability curve. I’m

  • 0

I ran a logit model and am trying to plot the probability curve. I’m posting the question here and not the stats board because it’s more an R question than a stats on, or at least I think so.

My model looks like:

mod1 = glm(factor(status1) ~ our_bid1 + factor(state) + factor(type),
           data=mydat, family=binomial(link="logit"))
print(summary(mod1))

Status1 is a factor with two levels, our_bid ranges from 0 to 20, state is 11 levels (top 10 populous and one which is other), and type has three levels.

To get the predicted probabilities, I ran the following code

all.x1 <- expand.grid(status1=unique(status1), our_bid1=unique(our_bid1),
                      state=unique(state), type=unique(type))

y.hat.new1 <- predict(mod1, newdata=all.x1, type="response")

The problem happens when I am trying to plot the curve. I’m trying to have a general curve for change in our bid given the model.

plot(our_bid1<-000:1600, 
     predict(mod1, newdata=data.frame(our_bid1<-c(000:1600)), type="response"),
     lwd=5, col="blue", type="l")

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : 
  variable lengths differ (found for 'factor(state)')
In addition: Warning message:
'newdata' had 1601 rows but variable(s) found have 29532 rows 

Do I have to specify all the independent variables in the plot command? What am I doing wrong?

  • 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-05-29T17:20:52+00:00Added an answer on May 29, 2026 at 5:20 pm
    • this is not reproducible, it would be a little easier if it were (i.e. give us a working example of mydata)
    • you do need to specify values of all the independent (I prefer “predictor”) variables
    • your specification confuses <- and = (which are not quite interchangeable, although they are in the context of assignment): you want something like

    (I need some text here so SO will format the code properly)

    bidvec <- 0:1600
    plot(bidvec,predict(mod1,
        newdata=data.frame(our_bid1=bidvec,
                           state=ref_state,type=ref_type),
                            type="response"), 
    lwd=5, col="blue", type="l")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Restatement of the question I'm resurrecting this question because I just ran into this
I am trying to use R to estimate a multinomial logit model with a
Ran into an Out of Stack Space error trying to serialize an ASP.Net AJAX
I ran into the problem that my primary key sequence is not in sync
I ran into a problem while trying to parse an XML string returned from
During the course of our application login there are several queries ran, all around
Our current project has ran into a circular dependency issue. Our business logic assembly
Ran across this line of code: FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); What do
Ran into something interesting, want to know if I'm doing something wrong or if
I ran into an issue with an IIS web app shutting down an idle

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.