In: Statistics and Probability
1. In the iris data, build a linear regression model to predict Sepal.Length based on both Petal.Length and Species.
a. Calculate the regression equation, including the interaction.
b. From this equation, you should be able to find 3 regression lines (one for each Species). Interpret each of the 3 slopes of the lines in the context of the problem. Remember that both numerical variables are measured in centimeters.
c. Plot the 3 regression lines in a scatterplot of Sepal.Length vs. Petal.Length. Use a different color for each Species.
d. Predict the Sepal.Length for a Versicolor iris with a petal that is 3.4 cm long.
e. Conduct a partial ?-test to see if the Petal.Length:Species interaction terms are significant. State the hypothesis, ?-value, and conclusion of the test.
f. Now calculate the regression equation without the interaction term. Interpret the slope in the context of the problem.
g. Using the no-interaction model, I’m 90% sure that the sepal length of a Virginica iris with a 5.5-cm-long petal will be between __________ cm and __________ cm.
h. Identify and interpret the ? 2 from the no-interaction model.
ANSWER::
Note : allowed to answer only 4 sub questions in one post.
a to d answered and r code given
e to h
> library(interactions)
> library(ggplot2)
> fitiris <- lm(Sepal.Length ~ Petal.Length * Species, data =
iris)
> summary(fitiris)
Call:
lm(formula = Sepal.Length ~ Petal.Length * Species, data =
iris)
Residuals:
Min 1Q Median 3Q Max
-0.73479 -0.22785 -0.03132 0.24375 0.93608
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.2132 0.4074 10.341 < 2e-16 ***
Petal.Length 0.5423 0.2768 1.959 0.05200 .
Speciesversicolor -1.8056 0.5984 -3.017 0.00302 **
Speciesvirginica -3.1535 0.6341 -4.973 1.85e-06 ***
Petal.Length:Speciesversicolor 0.2860 0.2951 0.969 0.33405
Petal.Length:Speciesvirginica 0.4534 0.2901 1.563 0.12029
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3365 on 144 degrees of freedom
Multiple R-squared: 0.8405, Adjusted R-squared:
0.8349
F-statistic: 151.7 on 5 and 144 DF, p-value: < 2.2e-16
> plot(iris$Sepal.Length,iris$Petal.Length, pch=21,
bg=c("red","green3","blue")[unclass(iris$Species)], main="Edgar
Anderson's Iris Data", xlab="Sepal.Length",
ylab="Petal.Length")
> interact_plot(fitiris, pred = Petal.Length, modx =
Species)
> 5.22622
[1] 5.22622
NOTE:: I HOPE THIS ANSWER IS HELPFULL TO YOU......**PLEASE SUPPORT ME WITH YOUR RATING......
**PLEASE GIVE ME "LIKE".....ITS VERY IMPORTANT FOR,ME......PLEASE SUPPORT ME .......THANK YOU