1. Select a dataset from “100+ Interesting Data Sets for Statistics”
  1. Select one independent variable and select one dependent variable
  1. Read the dataset as a data.table or data.frame
library("Ecdat", lib.loc="~/R/win-library/3.0")
data(University)
summary(University)
##   undstudents     poststudents       nassets         acnumbers     
##  Min.   :    0   Min.   :  26.0   Min.   :  2037   Min.   :  48.0  
##  1st Qu.: 2678   1st Qu.: 665.2   1st Qu.: 17707   1st Qu.: 383.2  
##  Median : 3828   Median : 958.5   Median : 32261   Median : 558.5  
##  Mean   : 4373   Mean   :1115.1   Mean   : 55043   Mean   : 753.9  
##  3rd Qu.: 6336   3rd Qu.:1554.2   3rd Qu.: 59737   3rd Qu.:1008.8  
##  Max.   :10035   Max.   :3975.0   Max.   :406564   Max.   :2030.0  
##     acrelnum         clernum          compop           techn      
##  Min.   : 11.00   Min.   : 17.0   Min.   :  0.00   Min.   : 10.0  
##  1st Qu.: 91.25   1st Qu.:193.0   1st Qu.:  6.00   1st Qu.:111.6  
##  Median :140.00   Median :276.5   Median :  8.50   Median :172.0  
##  Mean   :171.88   Mean   :312.9   Mean   : 13.17   Mean   :227.0  
##  3rd Qu.:229.75   3rd Qu.:401.6   3rd Qu.: 13.75   3rd Qu.:331.1  
##  Max.   :658.00   Max.   :845.5   Max.   :200.00   Max.   :639.5  
##      stfees          acpay          acrelpay        secrpay      
##  Min.   :  520   Min.   :  806   Min.   :    0   Min.   : 189.0  
##  1st Qu.: 4162   1st Qu.: 8243   1st Qu.: 1110   1st Qu.: 984.2  
##  Median : 6065   Median :10728   Median : 2248   Median :1648.5  
##  Mean   : 7061   Mean   :14390   Mean   : 2937   Mean   :1934.0  
##  3rd Qu.: 9248   3rd Qu.:20360   3rd Qu.: 3885   3rd Qu.:2476.2  
##  Max.   :18800   Max.   :35253   Max.   :10478   Max.   :8667.0  
##      admpay        agresrk           furneq       landbuild     
##  Min.   : 221   Min.   : 139.0   Min.   :  89   Min.   :  2583  
##  1st Qu.:1086   1st Qu.: 972.5   1st Qu.:1166   1st Qu.: 16855  
##  Median :1538   Median :1718.1   Median :1764   Median : 24744  
##  Mean   :1872   Mean   :2406.6   Mean   :2419   Mean   : 38635  
##  3rd Qu.:2586   3rd Qu.:3396.7   3rd Qu.:3338   3rd Qu.: 41737  
##  Max.   :4705   Max.   :9147.1   Max.   :9400   Max.   :362000  
##      resgr      
##  Min.   :  121  
##  1st Qu.: 3570  
##  Median : 6534  
##  Mean   : 9237  
##  3rd Qu.:12150  
##  Max.   :40746
  1. Describe, in detail, \(H_0\), your null hypothesis
  1. Describe, in detail, your (linear) model
  1. Describe the dataset you selected
attach(University)
lm<-lm(acpay~resgr)
  1. Plot the scattergram of your data
  2. Plot the regression line
  3. Plot the 95% confidence intervals of the regression line, \(b_0\) and \(b_1\)
plot(resgr,acpay,cex=1,pch=16,col="red", main="Academic pay vs. Research grants in the UK", xlab="Research Grants", ylab="Academic pay")
abline(lm$coef, lwd=2, col="green")
ci<-confint(lm,level=0.95)
abline(ci[,1],lty=2,col="green")
abline(ci[,2],lty=2,col="green")

  1. Print a summary of your model
summary(lm)
## 
## Call:
## lm(formula = acpay ~ resgr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -12055.8  -2419.1    -72.8   2137.3  12660.0 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 6.072e+03  8.364e+02    7.26 9.02e-10 ***
## resgr       9.004e-01  6.663e-02   13.51  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4460 on 60 degrees of freedom
## Multiple R-squared:  0.7527, Adjusted R-squared:  0.7486 
## F-statistic: 182.6 on 1 and 60 DF,  p-value: < 2.2e-16
  1. Interpret the results of the statistical analysis \(b_0\), \(b_1\) and \(r\)