[R] Making predictions from a linear model

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Aug 28 05:48:52 CEST 2013


In spite of your claim to be familiar with explanatory modeling, you are not describing your questions about R in terms of theory you would like to apply and assumptions you are willing to make. This list is about R, so don't go fishing for statistical advice.

Have you read the help file for predict or predict.lm? The interval="confidence" option might be useful.

Please post plain text per the Posting Guide instructions.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Abraham Mathew <abmathewks at gmail.com> wrote:
>I'm trying to educate myself about predictive analytics and am using R
>to
>generate a linear model with the following data.
>
>age     <- c(23,   19,   25,   10,9, 12,   11,8)
>steroid <- c(27.1, 22.1, 21.9, 10.7,  7.4, 18.8, 14.7, 5.7)
>gpa     <- c( 2.1,  2.9,  2.8,  3.5,  3.2,  3.9,  2.8, 2.6)
>sample  <- data.frame(age, steroid, gpa)
>fit2    <- lm(steroid~age+gpa)
>summary(fit2)
>newdata <- data.frame(age=15, gpa=3.2)
>predict(fit2, newdata, interval="predict")  # I want the fitted /
>predicted value
>
>>From the summary for the linear model, I have information on the
>coefficients associated with each predictor. However, I want to go
>further
>and find the predicted probability of information from this data. So
>for
>someone who is 13 and has a GPA of 3.3, what's the predicted
>probability of
>them ranking high on the steroid scale? What about for someone who is
>age
>10? etc.
>
>I understand explanatory modeling and have no problem implementing that
>in R,
>I just have issues with using R to construct meaningful predictive
>analytics. If you have any insights on this, feel free to share.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list