why do you say this? Check for instance the following code:
x1 <- runif(100, -5, 5)
x2 <- rnorm(100)
x3 <- rep(0:1, each = 50)
y <- 2 + 0.5 * x1 + 2 * x2 - 3 * x3 + rnorm(100)
fit <- lm(y ~ x1 + x2 + x3)
all.equal(
as.vector(fitted(fit)),
as.vector(model.matrix(fit) %*% coef(fit))
)
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 19, 2008 3:41 PM
Subject: [R] fitted values are different from manually calculating
> Hello,
>
> 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.
>
> --
> -- Yianni
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] 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.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
______________________________________________
[email protected] 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.