Re: [R] Calculation of VCV matrix of estimated coefficient

2024-09-06 Thread peter dalgaard
> On 5 Sep 2024, at 16:36 , Gabor Grothendieck wrote: > > sigma(model)^2 will give the correct MSE. Also note that your model > matrix has intercept at > the end whereas vcov will have it at the beginning so you will need to > permute the rows > and columns to get them to be the same/ Also,

Re: [R] Calculation of VCV matrix of estimated coefficient

2024-09-05 Thread Gabor Grothendieck
sigma(model)^2 will give the correct MSE. Also note that your model matrix has intercept at the end whereas vcov will have it at the beginning so you will need to permute the rows and columns to get them to be the same/ On Wed, Sep 4, 2024 at 3:34 PM Daniel Lobo wrote: > > Hi, > > I am trying to

Re: [R] Calculation of VCV matrix of estimated coefficient

2024-09-04 Thread Ben Bolker
The number you need for MSE is sum(residuals(model)^2)/df.residual(model) On Wed, Sep 4, 2024 at 3:34 PM Daniel Lobo wrote: > > Hi, > > I am trying to replicate the R's result for VCV matrix of estimated > coefficients from linear model as below > > data(mtcars) > model <- lm(mpg~disp+hp, data=m

[R] Calculation of VCV matrix of estimated coefficient

2024-09-04 Thread Daniel Lobo
Hi, I am trying to replicate the R's result for VCV matrix of estimated coefficients from linear model as below data(mtcars) model <- lm(mpg~disp+hp, data=mtcars) model_summ <-summary(model) MSE = mean(model_summ$residuals^2) vcov(model) Now I want to calculate the same thing manually, library(