1
$\begingroup$

I've got some baseball stats, RBIs by season, let's say:

player      s1  s2  s3
Brian_Giles 66  68  70
Joe_Thomas  71  72  71
Robin_Yount 71  69  68
Jim_Jones   66  66  65

And I want to do a simple linear regression using lm() on this data to predict their RBI #s in a 4th season. Would I need another variable here to create my formula? How would I most simply complete this linear regression?

I'm trying to work off of this tutorial (http://www.r-bloggers.com/wp-content/uploads/2009/11/simpleLinRegExample1.txt), which seems like I might need a second variable, (I'm new to linear regressions, obviously) but I can't figure out what it should be. The slope of a best-fit line for those three seasons of data?

$\endgroup$
3
  • $\begingroup$ Is there a reason not to use each player's average as your prediction for the next season? $\endgroup$
    – dsaxton
    Commented Jul 27, 2015 at 14:52
  • $\begingroup$ I mean, yeah, that makes the most sense, but I'm actually just trying to wrap my head around basic linear regressions and how they're implemented in R. If it means anything, another reason I want to use lm() is because I envision this type of linear model being ideal for golf scores, heading into the 4th round, for example -- the idea being if they're playing well, they'll only play better in that 4th round. Obviously flawed, but interesting, perhaps. $\endgroup$
    – skathan
    Commented Jul 27, 2015 at 15:04
  • $\begingroup$ You will want to read about "regression to the mean" before you do that golf analysis! $\endgroup$
    – whuber
    Commented Jul 27, 2015 at 15:53

1 Answer 1

2
$\begingroup$

You can't run an lm this way. You would need a variable for time and then you could regress on that, but that model would violate the assumption of independent errors, so you probably would want to use a multi-level model (in R see nlme or mle4). Those models get tricky.

A linear model needs a dependent variable (in your case, RBI) and at least one independent variable. In your case, you could, for example, use the RBI from a single season and model it as a function of (e.g.) position or league or team or age or whatever. But you need an independent variable.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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