Dear all,
I would like to fit a linear regression with replication (on each year,
observation is replicated, e.g 4 times). The independent variable ranges
for instance 1-5 year, so I expect to have a linear fit of 5 points.
For that purpose I do these (with dummy variables x and y):

x<-rep(seq(1:5),4)
y<-rnorm(20)
linreg<-lm(y~x)
fitted.values(linreg)  # why produce 20 points of estimate?
predict(linreg)        # why produce 20 points of estimate?

Please somebody explain:
1. why both fitted.values and predict functions produced 20 points of
estimate, NOT 5 points.
2. is "lm(y~x)" correct to solve this regression case, or there's a
correct procedure.

Many thanks.

______________________________________________
R-help@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.

Reply via email to