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 9155409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:14+00:00 2026-06-17T12:35:14+00:00

In R predict.lm computes predictions based on the results from linear regression and also

  • 0

In R predict.lm computes predictions based on the results from linear regression and also offers to compute confidence intervals for these predictions. According to the manual, these intervals are based on the error variance of fitting, but not on the error intervals of the coefficient.

On the other hand predict.glm which computes predictions based on logistic and Poisson regression (amongst a few others) doesn’t have an option for confidence intervals. And I even have a hard time imagining how such confidence intervals could be computed to provide a meaningful insight for Poisson and logistic regression.

Are there cases in which it is meaningful to provide confidence intervals for such predictions? How can they be interpreted? And what are the assumptions in these cases?

  • 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-17T12:35:15+00:00Added an answer on June 17, 2026 at 12:35 pm

    The usual way is to compute a confidence interval on the scale of the linear predictor, where things will be more normal (Gaussian) and then apply the inverse of the link function to map the confidence interval from the linear predictor scale to the response scale.

    To do this you need two things;

    1. call predict() with type = "link", and
    2. call predict() with se.fit = TRUE.

    The first produces predictions on the scale of the linear predictor, the second returns the standard errors of the predictions. In pseudo code

    ## foo <- mtcars[,c("mpg","vs")]; names(foo) <- c("x","y") ## Working example data
    mod <- glm(y ~ x, data = foo, family = binomial)
    preddata <- with(foo, data.frame(x = seq(min(x), max(x), length = 100)))
    preds <- predict(mod, newdata = preddata, type = "link", se.fit = TRUE)
    

    preds is then a list with components fit and se.fit.

    The confidence interval on the linear predictor is then

    critval <- 1.96 ## approx 95% CI
    upr <- preds$fit + (critval * preds$se.fit)
    lwr <- preds$fit - (critval * preds$se.fit)
    fit <- preds$fit
    

    critval is chosen from a t or z (normal) distribution as required (I forget exactly now which to use for which type of GLM and what the properties are) with the coverage required. The 1.96 is the value of the Gaussian distribution giving 95% coverage:

    > qnorm(0.975) ## 0.975 as this is upper tail, 2.5% also in lower tail
    [1] 1.959964
    

    Now for fit, upr and lwr we need to apply the inverse of the link function to them.

    fit2 <- mod$family$linkinv(fit)
    upr2 <- mod$family$linkinv(upr)
    lwr2 <- mod$family$linkinv(lwr)
    

    Now you can plot all three and the data.

    preddata$lwr <- lwr2 
    preddata$upr <- upr2 
    ggplot(data=foo, mapping=aes(x=x,y=y)) + geom_point() +         
       stat_smooth(method="glm", method.args=list(family=binomial)) + 
       geom_line(data=preddata, mapping=aes(x=x, y=upr), col="red") + 
       geom_line(data=preddata, mapping=aes(x=x, y=lwr), col="red") 
    

    enter image description here

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

Sidebar

Related Questions

I'm working on a predict the results type system where users are asked to
i wan't to remove all sales according to predict expression IQueryable<Sale> sales = entites.Sales.Where<Sale>(s
Hi i have a spec for fetch the files from server and predict the
I'm trying to follow this guide to play around with Google Predict from the
I am trying to predict fitted values over data containing NA s, and based
I'm using the vars package and want to predict some values from the calculated
As said in the help(predict.nls), when se.fit=TRUE,the standard errors of the predictions should be
I am attempting to understand how the predict.loess function is able to compute new
I am trying to predict test reuslts based on known previous scores. The test
Was: Design by contract: predict methods needed, discipline yourself and deal with code that

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.