[R] fitted values are different from manually calculating
Douglas Bates
bates at stat.wisc.edu
Tue Feb 19 16:01:40 CET 2008
On Feb 19, 2008 8:41 AM, <gatemaze at gmail.com> wrote
> on a simple linear model the values produced from the fitted(model) function
> are difference from manually calculating on calc. Will anyone have a clue...
> or any insights on how fitted function calculates the values? Thank you.
______________________________________________
> R-help at 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.
As the posting guide (you did read the posting guide, didn't you?)
says, it helps if you can provide a reproducible example. Otherwise,
we can only guess at what you mean.
Try taking a fitted model and examining
model.matrix(model)
and
coef(model)
It should be the case that
model.matrix(model) %*% coef(model)
is reasonably close to fitted(model).
I just saw that Dimitris wrote almost the same thing but, since I have
written it, I'll mail it anyway.
More information about the R-help
mailing list