I can use the anova
function to get the ANOVA table for linear model. However this gives the individual effects of each explanatory variable on the response variable. I wonder if there is any function in R to get the overall ANOVA
where we can get the overall effect of all explanatory variables on response variable. Thanks in advance for your help.
MWE
set.seed(12345)
X1 <- 10*abs(rnorm(n=10, mean = 5, sd = 1))
X2 <- 20*abs(rnorm(n=10, mean = 4, sd = 2))
Y <- 50*abs(rnorm(n=10, mean = 10, sd = 4))
df <- data.frame(X1, X2, Y)
fm1 <- lm(formula=Y~X1+X2, data=df)
anova(fm1)
Analysis of Variance Table
Response: Y
Df Sum Sq Mean Sq F value Pr(>F)
X1 1 37842 37842 0.7815 0.406
X2 1 115774 115774 2.3910 0.166
Residuals 7 338941 48420
Edited (2017-10-23)
The required output is
Analysis of Variance Table
Response: Y
Df Sum Sq Mean Sq F value Pr(>F)
Regression 2 153616.587 76808.293 1.586 0.2703
Residuals 7 338940.570 48420.081