A colleague of mine sent me this problem apparently making the rounds on the internet:
If $3 = 18, 4 = 32, 5 = 50, 6 = 72, 7 = 98$, Then, $10 =$ ?
The answer seems to be 200.
3*6
4*8
5*10
6*12
7*14
8*16
9*18
10*20=200
When I do a linear regression in R:
data <- data.frame(a=c(3,4,5,6,7), b=c(18,32,50,72,98))
lm1 <- lm(b~a, data=data)
new.data <- data.frame(a=c(10,20,30))
predict <- predict(lm1, newdata=new.data, interval='prediction')
I get:
fit lwr upr
1 154 127.5518 180.4482
2 354 287.0626 420.9374
3 554 444.2602 663.7398
So my linear model is predicting $10 = 154$.
When I plot the data it looks linear... but obviously I assumed something that is not correct.
I'm trying to learn how to best use linear models in R. What is the proper way to analyze this series? Where did I go wrong?