library(ggplot2)
library(markdown)
library(rmarkdown)
library(tidyr)
library(tidyselect)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ tibble  3.1.6     ✔ dplyr   1.0.7
## ✔ readr   2.1.2     ✔ stringr 1.4.0
## ✔ purrr   0.3.4     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(pairsD3)
library(smss)
library(alr4)
## Loading required package: car
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
## Loading required package: effects
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.

Question 1

1.11 Predictor is ppGDP and response is Fertility

1.12

plot(UN11$ppgdp, UN11$fertility, main = "Fertility and GDP", xlab = "GDP", ylab = "Fertility")
abline(lm(UN11$fertility ~ UN11$ppgdp))

attach(UN11)
view(UN11)

1.13

plot(log(UN11$ppgdp), log(UN11$fertility), main = "Fertility and GDP", xlab = "GDP", ylab = "Fertility")
abline(lm(log(UN11$fertility) ~ log(UN11$ppgdp)))

Question 2

  1. This would multiply the rate by 1.33, changing the slope by that value.
  2. The correlation would not change.

Question 3

It looks like there is a relationship between BSAAM, OSPLAKE, OPRC, OPBPC.

attach(water)
view(water)
pairs(water)

Question 4

Quality and helpfulness/ clarity have a relationship. The relationship becomes less significant over the course of the other variables.

attach(Rateprof)
view(Rateprof)
ratevar<-Rateprof%>%select(quality, helpfulness, clarity, easiness, raterInterest)
pairs(ratevar)

Question 5

  1. Conservative groups are more likely to attend religios practices than other groups
  2. Higher GPA shows a decreasing trend with TV use.
data(student.survey)
lm(pi~re, data = student.survey)
## Warning in model.response(mf, "numeric"): using type = "numeric" with a factor
## response will be ignored
## Warning in Ops.ordered(y, z$residuals): '-' is not meaningful for ordered
## factors
## 
## Call:
## lm(formula = pi ~ re, data = student.survey)
## 
## Coefficients:
## (Intercept)         re.L         re.Q         re.C  
##      3.5253       2.1864       0.1049      -0.6958
lm(hi~tv, data = student.survey)
## 
## Call:
## lm(formula = hi ~ tv, data = student.survey)
## 
## Coefficients:
## (Intercept)           tv  
##     3.44135     -0.01831
boxplot(pi~re, data = student.survey)

scatterplot(hi~tv, data = student.survey)