The data frame `x77` contains data from each of the fifty United States. First coerce the `state.x77` variable into a data frame with:*
```{r, eval=FALSE}
x77 <- data.frame(state.x77)
```
*For the following, make a scatter plot with the regression line:*
1. *The model of illiteracy rate (`Illiteracy`) modeled by high school graduation rate (`HS.Grad`).*
2. *The model of life expectancy (`Life.Exp`) modeled by the murder rate (`Murder`).*
3. *The model of income (`Income`) modeled by the illiteracy rate (`Illiteracy`).*
*Write a sentence or two describing any relationship for each fo the relationships examined above. In particular, do you find it as expected or surprising?*
Please provide code from R and answer all the
questions.
Solution:
x77 <- data.frame(state.x77)
library(ggpubr)
require(ggpubr)
ggscatter(x77, x = "HS.Grad", y = "Illiteracy", add = "reg.line")
+
stat_cor(label.y = 300) +
stat_regline_equation(label.y = 280)
There exists a a negative relationship between HS Grad and Illiteracy.
as Illiteracy increases,,HS grad decreases.
Rgression eq is
illiteracy=3.8-0.05*HS Grad
R=-0.66
p=2.2*10^-7
p<0.05
Relationship between HS Grad and Illiteracy. is statistically significant at 5% level of signfiicance
Solution2:
ggscatter(x77, x = "Murder", y = "Life.Exp", add = "reg.line")
+
stat_cor(label.y = 300) +
stat_regline_equation(label.y = 250)
Life expectancy =73-0.28*Murder
there exists a negative relationship between murders and life expectancy.
As number of murders increases,life expectancy decreases and vice versa.
R=-0.78
p=2.3*01^-11
p<0.05
Relationship between HS Grad and Illiteracy. is statistically significant at 5% level of signfiicance
3. *The model of income (`Income`) modeled by the illiteracy rate (`Illiteracy`).*
ggscatter(x77, x = "Illiteracy", y = "Income", add = "reg.line")
+
stat_cor(label.y = 400) +
stat_regline_equation(label.y = 50)
Regression eq is
income=5000-440*Illiteracy
There exists a negative relationship between Income and Illiteracy
as Illiteracy rate is high,income earned is low and viceversa
r=-0.44
p=0.0015
p<0.05
Relationship between income and Illiteracy. is statistically significant at 5% level of signfiicance
Get Answers For Free
Most questions answered within 1 hours.