Hi Yianni,
This just proves that you should be using R as your calculator, and not the
other one!
Regards, Mark.
gatemaze wrote:
>
> Hello,
>
> on a simple linear model the values produced from the fitted(model)
> function
> are difference from manually calculating on calc. Will anyone have
Thank you all for your help. Apologies for not giving an example.
model.matrix was useful as comparing that table with the one from the
spreadsheet showed the "mispell".
On 19/02/2008, Douglas Bates <[EMAIL PROTECTED]> wrote:
>
> On Feb 19, 2008 8:41 AM, <[EMAIL PROTECTED]> wrote
>
> > on a simpl
On Feb 19, 2008 8:41 AM, <[EMAIL PROTECTED]> 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.
___
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
Hi
A simple example of a linear model:
x<-1:10
y<-3*x+1
m1<-lm(y~x)
y
# [1] 4 7 10 13 16 19 22 25 28 31
fitted(m1)
# 1 2 3 4 5 6 7 8 9 10
# 4 7 10 13 16 19 22 25 28 31
The fitted and calculated values look identical to me.
Can you give an example of how your calculated values
5 matches
Mail list logo