1
$\begingroup$

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, 13)
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.

$\endgroup$
  • 1
    $\begingroup$ Your age variable has fewer values than steroid or gpa. That means R will recycle 23, 19 (add them on to the end of age to make it equal length). You should be sure you want that. (I would bet you don't.) $\endgroup$ – gung - Reinstate Monica Aug 28 '13 at 2:59
  • 3
    $\begingroup$ Regarding your main question, you need to clarify what "the predicted probability of them ranking high" means. $\endgroup$ – gung - Reinstate Monica Aug 28 '13 at 3:00
-1
$\begingroup$

if you are beginner looking for predictive analytics then: 1. first of all you will need a training dataset to see if the model you have constructed using the code above is a good fit. R offers variety of tools for that but I prefer Rattle for a quick glimpse. 2. Once you tune the model that fits your training dataset, then you can predict the output every time you get a new values for AGE, STEROID, GPA.

if you are not beginner, the put some more detailed description of the problem and avoid administrators/users from removing the topic ;)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.