Sunday, 5 February 2017

how to compare two model in r using ANOVA

how to compare two model in r using ANOVA

 mod2=lm(r$Crime~r$Ineq)
> mod3=lm(r$Crime~r$Wealth+r$Ineq)
> anova(mod2,mod3)
Analysis of Variance Table

Model 1: r$Crime ~ r$Ineq
Model 2: r$Crime ~ r$Wealth + r$Ineq
  Res.Df     RSS Df Sum of Sq      F   Pr(>F)  
1     45 6660397                                
2     44 4137694  1   2522703 26.826 5.32e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

No comments:

Post a Comment