In: Statistics and Probability
USING R ---locate the pre-loaded MASS package, then load the data frame cats within that packag. This provides data on sex, body weight (in kgs), and heart weight (in grams) for 144 household cats. Load the MASS package with a call to library("MASS"), and access the object directly by entering cats at the console prompt.
1. Fit a least-squares multiple linear regression model using heart weight as the response variable and the other two variables as predictors, and view a model summary. Write down the equation for a least-squares multiple linear regression fitted model and interpret the estimated regression coefficients for body weight and sex (of the cats in the above package). Are both statistically significant? What does this say about the relationship between the response and predictors?
library(MASS)
data(cats)
head(cats,n=2) # it show first two row of cats data
Sex Bwt Hwt
1 F 2 7.0
2 F 2 7.4
#1. Fit a least-squares multiple linear regression model
using heart weight as the response variable and the other two
variables as predictors, and view a model summary.
model=lm(Hwt~Bwt+Sex,data=cats)
model
Call:
lm(formula = Hwt ~ Bwt + Sex, data = cats)
Coefficients:
(Intercept) Bwt SexM
-0.4150 4.0758 -0.0821
> summary(model)
Call:
lm(formula = Hwt ~ Bwt + Sex, data = cats)
Residuals:
Min 1Q Median 3Q Max
-3.5833 -0.9700 -0.0948 1.0432 5.1016
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.4149 0.7273 -0.571 0.569
Bwt 4.0758 0.2948 13.826 <2e-16 ***
SexM -0.0821 0.3040 -0.270 0.788
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.457 on 141 degrees of freedom
Multiple R-squared: 0.6468, Adjusted R-squared: 0.6418
F-statistic: 129.1 on 2 and 141 DF, p-value: < 2.2e-16
so from above R-output.
the equation for a least-squares multiple linear regression fitted model
Hwt = -0.4150+4.0758 *Bwt--0.0821*SexM
interpret the estimated regression coefficients for body weight and sex
For body weight = 4.0758
It can be interpreted as if we change body weight by 1 kg then their is average increase in heart weight by 4.0758 kg by keeping Sex constant.
For Sex Male = -0.0821
It can be interpreted as if your sex is male then their is average decrease in heart weight by -0.0821 kg by keeping Body weight constant.
Are both statistically significant?
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.4149 0.7273 -0.571 0.569
Bwt 4.0758 0.2948 13.826 <2e-16 ***
SexM -0.0821 0.3040 -0.270 0.788
From above output P-value for Body weight is <2e-16 < 0.05 level of significance so we reject the null hypothesis and conclude that Body weight is statistically significant variable.
From above output P-value for Sex 0.788 > 0.05 level of significance so we accept the null hypothesis and conclude that Sex is not statistically significant variable.
What does this say about the relationship between the response and predictors?
F-statistic: 129.1 on 2 and 141 DF, p-value: < 2.2e-16
Here p-value is (< 2.2e-16) < 0.05 level of significance so we reject the null hypothesis and conclude that relationship between he response and predictors statistically significant.