Скачать презентацию Stat 6601 project Linear Statistical Models Analysis of Скачать презентацию Stat 6601 project Linear Statistical Models Analysis of

65dcb020e34d35b6bfd6cb687383c575.ppt

  • Количество слайдов: 11

Stat 6601 project Linear Statistical Models Analysis of Covariance Example By Gadir Marian Myrna Stat 6601 project Linear Statistical Models Analysis of Covariance Example By Gadir Marian Myrna Moreno

Data ¨ ‘Whiteside’ data, Mr. Derek recorded weekly gas consumption and average external temperature Data ¨ ‘Whiteside’ data, Mr. Derek recorded weekly gas consumption and average external temperature at his house during two ‘heating seasons’ one before and after cavity-wall insulation was installed. ¨ Variables: - Insul (levels: before or after insulation) - Temp (the average outside temperature in degrees Celsius) -Gas (The weekly gas consumption in 1000 cubic feet units)

Goal ¨ Assess the effect of the insulation on gas consumption. Goal ¨ Assess the effect of the insulation on gas consumption.

Plotting the data Plotting the data

Method ¨ Linear Model for Analysis of Covariance Y= +X + Where: is a Method ¨ Linear Model for Analysis of Covariance Y= +X + Where: is a random effect due to treatment. is a fixed effect due to covariate. is a random error.

Method(continued) ¨ Using R: -A primary model is fitted using a “model fitting function” Method(continued) ¨ Using R: -A primary model is fitted using a “model fitting function” lm (formula, data, weights, subset, na. action) - A resulting “fitted model object” can be analysed, interrogated or modified.

Codes ¨ ¨ ¨ ¨ ¨ require(latice) xyplot(Gas ~ Temp | Insul, whiteside, panel Codes ¨ ¨ ¨ ¨ ¨ require(latice) xyplot(Gas ~ Temp | Insul, whiteside, panel = function(x, y, . . . ) { panel. xyplot(x, y, . . . ) panel. lmline(x, y, . . . ) }, xlab = "Average external temperature (deg. C)", ylab = "Gas consumption (1000 cubic feet)", aspect = "xy", strip = function(. . . ) strip. default(. . . , style = 1)) gas. B <- lm(Gas ~ Temp, whiteside, subset = Insul=="Before") gas. A <- update(gas. B, subset = Insul=="After") summary(gas. B) summary(gas. A) gas. BA <- lm(Gas ~ Insul/Temp - 1, whiteside) summary(gas. BA) gas. Q <- lm(Gas ~ Insul/(Temp + I(Temp^2)) - 1, whiteside) summary(gas. Q)$coef gas. PR <- lm(Gas ~ Insul + Temp, whiteside) anova(gas. PR, gas. BA) options(contrasts = c("contr. treatment", "contr. poly")) gas. BA 1 <- lm(Gas ~ Insul*Temp, whiteside) summary(gas. BA 1)$coef

Results ¨ The output from fitting regression model: Residuals: Min 1 Q Median 3 Results ¨ The output from fitting regression model: Residuals: Min 1 Q Median 3 Q Max -0. 97802 -0. 18011 0. 03757 0. 20930 0. 63803 Coefficients: Estimate Std. Error t value Pr(>|t|) Insul. Before 6. 85383 0. 13596 50. 41 <2 e-16 *** Insul. After 4. 72385 0. 11810 40. 00 <2 e-16 *** Insul. Before: Temp -0. 39324 0. 02249 -17. 49 <2 e-16 *** Insul. After: Temp -0. 27793 0. 02292 -12. 12 <2 e-16 *** Residual standard error: 0. 323 on 52 degrees of freedom

Results(continued) The output by fitting quadratic regression model: Estimate Std. Error t value Pr(>|t|) Results(continued) The output by fitting quadratic regression model: Estimate Std. Error t value Pr(>|t|) Insul. Before 6. 759215179 0. 150786777 44. 826312 4. 854615 e-42 Insul. After 4. 496373920 0. 160667904 27. 985514 3. 302572 e-32 Insul. Before: Temp -0. 31765873 0. 062965170 -5. 044991 6. 362323 e-06 Insul. After: Temp -0. 137901603 0. 073058019 -1. 887563 6. 489554 e-02 Insul. Before: I(Temp^2) -0. 008472572 0. 006624737 -1. 278930 2. 068259 e-01 Insul. After: I(Temp^2) -0. 014979455 0. 007447107 -2. 011446 4. 968398 e-02

Results(continued) The output from the ANOVA Estimate Std. Error t value Pr(>|t|) (Intercept) 6. Results(continued) The output from the ANOVA Estimate Std. Error t value Pr(>|t|) (Intercept) 6. 8538277 0. 13596397 50. 409146 7. 997414 e-46 Insul. After -2. 1299780 0. 18009172 -11. 827185 2. 315921 e-16 Temp -0. 3932388 0. 02248703 -17. 487358 1. 976009 e-23 Insul. After: Temp 0. 1153039 0. 03211212 3. 590665 7. 306852 e-04

Summary ¨ Whiteside data ¨ Fitting Linear Regression Model ¨ Fitting Quadratic Regression Model Summary ¨ Whiteside data ¨ Fitting Linear Regression Model ¨ Fitting Quadratic Regression Model