# Regression with repeated data

I have a question regarding regression analysis on a dataset were the input values generate different results over time:

e.g.

1 2
2 2
3 5
4 1
2 5
3 8


How would I go about doing the regression on such a dataset, since the values change?

What do you mean by "the input values generate different results over time?" This happens a lot in regression analysis, and isn't typically a problem.

x<-c(1,2,3,4,2,3)
y<-c(2,2,5,1,5,8)

model<-lm(y~x)
summary(model)

plot(x,y)
lines(x,fitted(model))


In the case of your example data, a simple linear model is terrible. Can you be more specific about what you're trying to do?

/edit: In response to suncoolso: once you've fit a simple linear model, you can use the "gls" command from the "nlme" package to fit a simple linear model with an autoregressive correlation structure.

• I think aeWiardll is implying that there is a correlation (or some similar structure) in the data. Therefore, the simple assumption of independence of lm is probably not what @eWizardll is looking for. I hope the answer to your question would make things clearer. – suncoolsu Jan 22 '11 at 4:50