samedi 23 septembre 2017

Wald test on regression coefficients of factorial variable in R

I'm a newbie in R and I have this fitted model:

> mqo_reg_g <- lm(G ~ factor(year), data = data)
> summary(mqo_reg_g)

Call:
lm(formula = G ~ factor(year), data = data)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.11134 -0.06793 -0.04239  0.01324  0.85213 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)      0.111339   0.005253  21.197  < 2e-16 ***
factor(year)2002 -0.015388   0.007428  -2.071 0.038418 *  
factor(year)2006 -0.016980   0.007428  -2.286 0.022343 *  
factor(year)2010 -0.024432   0.007496  -3.259 0.001131 ** 
factor(year)2014 -0.025750   0.007436  -3.463 0.000543 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.119 on 2540 degrees of freedom
Multiple R-squared:  0.005952,  Adjusted R-squared:  0.004387 
F-statistic: 3.802 on 4 and 2540 DF,  p-value: 0.004361

I want to test the difference between the coefficients of factor(year)2002 and Intercept; factor(year)2006 and factor(year)2002; and so on.

In STATA I know people use the function "test" that performs a Wald tests about the parameters of the fitted model. But I could find how to do in R.

How can I do it?

Thanks!

Aucun commentaire:

Enregistrer un commentaire