1.Regress Days on Index using simple linear regression, what are the estimates of your fitted regression line?
#Days as response = y
#Index = x
x<-c(16.7,17.1,18.2,18.1,17.2,18.2,16,17.2,18,17.2,16.9,17.1,18.2,17.3,17.5,16.6)
y<-c(91,105,106,108,88,91,58,82,81,65,61,48,61,43,33,36)
model1<-lm(y~x)
summary(model1)
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -41.70 -21.54 2.12 18.56 36.42
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -192.984 163.503 -1.180 0.258
## x 15.296 9.421 1.624 0.127
##
## Residual standard error: 23.79 on 14 degrees of freedom
## Multiple R-squared: 0.1585, Adjusted R-squared: 0.09835
## F-statistic: 2.636 on 1 and 14 DF, p-value: 0.1267
b0 = -192.984, b1 = 15.296
2.What is the value of R^2?
summary(model1)$r.square
## [1] 0.1584636
R^2 value = 0.1584636
3.Test for the signifiance of the regression at a 0.05 level of signficance assuming the response is Normally distributed, what is your conclusion?
summary(model1)$p
## NULL
The p-value is 0.1267, which is p>0.05, So, this model does not reject Null hypothesis
min(x)
## [1] 16
max(x)
## [1] 18.2
newx<-seq(16,18.2,0.02)
conf<-predict(model1,data.frame(x=newx),interval = "confidence")
pred<-predict(model1,data.frame(x=newx),interval = "prediction")
4.Regardless of whether you conclude that the regression is signficant above, make a scatterplot of the data showing the fitted regression line, confidence interval, and prediction interval
plot(x,y, main="Fitted regression line, confidence interval, and prediction interval")
abline(model1)
lines(newx,conf[,3])
lines(newx,conf[,2])
lines(newx,pred[,3])
lines(newx,pred[,2])
5.Calculate a 95% confidence interval on the mean number of days the ozone level exceeds 20ppm when the meterological index is 17.0. Comment on the meaning of this interval
metindex<-c(17)
confmet<-predict(model1,data.frame(x=metindex),interval = "confidence")
print(confmet)
## fit lwr upr
## 1 67.05437 52.52748 81.58127
In 95% interval, confidence value for fitted value = 67.05437, Lower value = 52.52748, Upper value = 81.58127
6.Calculate a 95% prediction interval on the mean number of days the ozone level exceeds 20ppm when the meterological index is 17.0. Comment on the meaning of this intervall? Compare the width of the prediction interval to that of the confidence interval and comment
predmet<-predict(model1,data.frame(x=metindex),interval = "prediction")
print(predmet)
## fit lwr upr
## 1 67.05437 13.99203 120.1167
In 95% interval, prediction value for fitted value = 67.05437, Lower value = 13.99203, Upper value = 120.1167