DOC PREVIEW
UIUC STAT 420 - HW#2

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

#1data = read.table("CH01PR20.txt", header = FALSE, as.is= TRUE, col.names= c("time","No.ofcopiers"))ERF <- lm(data$time ~ data$No.ofcopiers)anova(ERF)Analysis of Variance TableResponse: data$time Df Sum Sq Mean Sq F value Pr(>F) data$No.ofcopiers 1 76960 76960 968.66 < 2.2e-16 ***Residuals 43 3416 79 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Interpretation:We could read from the ANOVA table that the SSM is 76960, SSR is 3416, SSR = 76960, MSR = 76960, F-value for number of copiers is 968.66, and the associate P-value is < 2.2 * 10-16. (F (1, 43) = 968.66; p < .000) From the F value, we can infer that the hypothesis β1 ≠ 0 is hold For an additional copier, the mean will get an increment of b1, which is 15.035No. We can’t conclude that the intercept in the regression model is zero. data = read.table("CH01PR20.txt", header = FALSE, as.is= TRUE, col.names= c("time","copiers"))y=data[,1]x=data[,2]lm=lm(data$time ~ data$copiers)summary(lm)anova(lm)library(ggplot2)qplot(data$time, data$copiers, geom=c("point","smooth"), method="lm",se=T,level=0.9, main="Confidence Band for Problem 1",xlab="Number of copiers serviced",ylab="Time ")#5a)data = read.table("CH01PR27.txt", header = FALSE, as.is= TRUE, col.names= c("age","mass"))y <- data[,1]x <- data[,2]lm <- lm(y ~ x)fit <- lm$fitted.valueresidual <- lm$residualsssr=sapply(fit,function(x) x-mean(y))fit=as.vector(fit)residual=as.vector(residual)ssr=as.vector(ssr)qplot(x,residual,geom="point",main="Residual & Age",xlab = "Age")qplot(x,ssr,geom="point",main="SSR & Age",xlab = "Age")b)anova(lm)Analysis of Variance TableResponse: y Df Sum Sq Mean Sq F value Pr(>F) x 1 11627.5 11627.5 174.06 < 2.2e-16 ***Residuals 58 3874.4 66.8 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1c)Test Hypothesis: H0: β1 = 0 vs Ha: β1 ≠ 0. We would conclude to Ha if F* > F(0.95; 1,58) = 4.007. From the ANOVA table above, we can tell that F* = 174.06. Therefore,we come to the conclusion that Ha holds. On the other hand, we could reject H0 if P-value < = 0.05α . From the ANOVA table above, we can tell that p-value < 0.0000, which is less than 0.05. We come to the conclusion that Ha holds. d) 1 – R2 = 1 – 0.7501 = 0.2499. The percentile is 24.99%. This proportion is small. e)R2 = SSR/SSTO = 0.750067. r = - 0.866064, the negative sign is because the slope of the regression line is negative. #6 (3.2)1) Prototype of plot where error variance decreases with X would be like the following picture:2) The residual plot for the situation in which the true regression is U-shaped, but the linear regression is fitted would be U-shaped as well:#7 (3.3)1) data = read.table("CH01PR19.txt", header = FALSE, as.is= TRUE, col.names= c("GPA","ACT_Score"))x=data[,2]y=data[,1]boxplot(x)We can lean from the box plot that it is symmetric and there is no outliers.b)lm=lm(y ~ x)qplot(lm$residuals,x,geom=("point"),main="X and Residual",xlab="ACT test score",ylab = "GPA")We can see that most residuals are within a vertical interval (-1,1), with (0,0) as their center. No symmetric tendencies to be positive or negative. Therefore, a linear regression model is held. c)qplot(lm$residuals,lm$fitted.value,geom=("point"),main="Fitted value & Residual", xlab="ACT test score",ylab = "GPA")It could be concluded that the error variance is approximately a constant, and a linear regression function could be applied here.d)resid=lm$residualsqq=qqnorm(lm$residuals);exp=qq$x;corr=sum((lm$resid-mean(lm$resid))*(exp-mean(exp)))/sqrt(sum((lm$resid-mean(lm$resid))^2)*sum((exp-mean(exp))^2)) corr[1] 0.9744497The corr=0.9744. Under significant level of = 0.05, for n = 100, we obtain a αcritical value of 0.987 and the value would be increased with n getting larger. Therefore, for n = 120, corr(0.9744) would be smaller than the critical value. In addition, from the normal Q-Q plot, we can infer that the error term is not from a normal distribution. Therefore, the error term depart from a normal distribution.e)For the Brown-Forsythe Test, we can have:If |t*| ≤ t(1-α/2; n-2), we conclude that the error variance is constant.If |t*| > t(1-α/2; n-2), we conclude that the error variance is not a constantd1<-abs(resid[data[,2]<26]-median(resid[data[,2]<26]));d2<-abs(resid[data[,2]>=26]-median(resid[data[,2]>=26]));n1<-length(d1);n2<-length(d2);sd_BF<-sqrt((sum((d1-mean(d1))^2)+sum((d2-mean(d2))^2))/118);testBF<-(mean(d1)-mean(d2))/(sd_BF*sqrt(1/n1+1/n2));testBF[1] -0.8967448Therefore, we can clnclude that the variance is constant. f)data = read.table("CH03PR03.txt", header = FALSE, as.is= TRUE)X2=data[,3]X3=data[,4]qplot(resid,X2,geom=("point"),main="Test Score & Residuals")qplot(resid,X3,geom=("point"),main="Class rank Percentile & Residuals") From the graphs we get, the residual plot again intelligence test scores has a seemingly increasing trend, which could be inferred that there might be some information that the test cannot explain. On the other hand, for the residual plot against class rank percentile, the dots seem to be random and no obvious trend could be found, and most of them fall in the interval (-1,1), with a center around (0,0). Therefore, we can add class rank into the


View Full Document

UIUC STAT 420 - HW#2

Documents in this Course
Load more
Download HW#2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view HW#2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view HW#2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?