hw4.pdf - STAT 359 Assignment#4 YI TANG V00826204 Q1 a temperature<-c(24.9,35.0,44.9,55.1,65.2,75.2,85.2,95.2

hw4.pdf - STAT 359 Assignment#4 YI TANG V00826204 Q1 a...

This preview shows page 1 - 5 out of 12 pages.

STAT 359Assignment #4YI TANG V008262042018/3/21Q1atemperature<-c(24.9,35.0,44.9,55.1,65.2,75.2,85.2,95.2)viscosity<-c(1.133,0.977,0.853,0.755,0.672,0.602,0.542,0.507)par(mfrow=c(1,1))plot(temperature,viscosity,xlab="Temperature(C)",ylab="Viscosity(mPa.s)",main="Scatter Plot with Fitted Linear Line",cex.main=0.7)fit1=lm(viscosity~temperature)summary(fit1)#### Call:## lm(formula = viscosity ~ temperature)#### Residuals:##Min1QMedian3QMax## -0.043815 -0.035960 -0.0093150.0200090.069634#### Coefficients:##Estimate Std. Error t value Pr(>|t|)## (Intercept)1.28148870.046855627.35 1.58e-07 ***## temperature -0.00876000.0007282-12.03 2.00e-05 ***## ---## Signif. codes:0***0.001**0.01*0.05.0.11#### Residual standard error: 0.04742 on 6 degrees of freedom## Multiple R-squared:0.9602, Adjusted R-squared:0.9536## F-statistic: 144.7 on 1 and 6 DF,p-value: 2.001e-05anova(fit1)## Analysis of Variance Table#### Response: viscosity##DfSum Sq Mean Sq F valuePr(>F)## temperature1 0.32545 0.32545144.73 2.001e-05 ***## Residuals6 0.01349 0.00225## ---## Signif. codes:0***0.001**0.01*0.05.0.11abline(fit1,col="blue")1
305070900.50.81.1Scatter Plot with Fitted Linear LineTemperature(C)Viscosity(mPa.s)par(mfrow=c(2,2))plot(fit1)0.50.70.9-0.040.020.06Fitted valuesResidualsResiduals vs Fitted184-1.5-0.50.51.01.5-1.00.01.02.0Theoretical QuantilesStandardized residualsNormal Q-Q1840.50.70.90.00.40.81.2Fitted valuesStandardized residualsScale-Location1840.00.10.20.30.4-1.00.01.02.0LeverageStandardized residualsCook's distance0.50.51Residuals vs Leverage184shapiro.test(fit1$residuals)##2
##Shapiro-Wilk normality test#### data:fit1$residuals## W = 0.86814, p-value = 0.1445The simple linear model areviscosity= 1.2814887(0.0468556)-0.0087600(0.0007282)temperature. Accordingto the graphs, we see the points in residuals vs fitted value plot are not random, the line is quadratic pattern.Therefore the linear model is not a good fit for these data. There are three points need to be noticed inqq norm plot.Since the p-value is 0.1445 for Shapiro-Wilk normality test, therefore, it satisfies normalityassumption.btemperature2<-temperature^2quadratic<-lm(viscosity~temperature+temperature2)plot(temperature,viscosity,xlab="Temperature(C)",ylab="Viscosity(mPa.s)",main="Scatter Plot with Fitted Quadratic Line",cex.main=0.7)xv<-seq(0,100,.1)yv.quadratic<-predict(quadratic,list(temperature=xv,temperature2=xv^2))lines(xv,yv.quadratic,col="red")305070900.50.81.1Scatter Plot with Fitted Quadratic LineTemperature(C)Viscosity(mPa.s)summary(quadratic)#### Call:## lm(formula = viscosity ~ temperature + temperature2)#### Residuals:##123456##0.0074507 -0.0064922 -0.00869370.00073150.00603850.0057613##78## -0.0021377 -0.0026585#### Coefficients:##Estimate Std. Error t value Pr(>|t|)## (Intercept)1.553e+001.825e-0285.08 4.25e-09 ***## temperature-1.934e-026.661e-04-29.04 9.07e-07 ***## temperature28.811e-055.470e-0616.11 1.68e-05 ***## ---## Signif. codes:0***0.001**0.01*0.05.0.11##3
## Residual standard error: 0.007142 on 5 degrees of freedom## Multiple R-squared:0.9992, Adjusted R-squared:0.9989## F-statistic:3320 on 2 and 5 DF,p-value: 1.554e-08anova(quadratic)## Analysis of Variance Table#### Response: viscosity##DfSum Sq Mean Sq F valuePr(>F)## temperature1 0.32545 0.32545 6379.58 5.829e-09 ***## temperature21 0.01324 0.01324259.48 1.680e-05 ***## Residuals5 0.00026 0.00005## ---## Signif. codes:0***0.001**0.01*0.05.0.11par(mfrow=c(2,2))plot(quadratic)0.50.70.91.1-0.0100.000Fitted valuesResidualsResiduals vs Fitted312-1.5-0.50.51.01.5-1.50.01.02.0Theoretical QuantilesStandardized residualsNormal Q-Q1320.50.70.91.10.00.40.81.2Fitted valuesStandardized residuals

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture