Description Usage Format Source References Examples
In a randomized, double-blind, crossover experiment, researchers randomly assigned 20 volunteer hospital employees to either a low-fiber or low-fiber treatment group. The subjects followed the diets for six weeks. After two weeks on their normal diet, all patients crossed over to the other treatment group for another six weeks. The total serum cholesterol (in mg/dl) was measured on each patient before the first treatment, at the end of the first six week treatment, and at the end of the second six week treatment.
1 |
A data frame with 20 observations on the following 4 variables.
total serum cholesterol before treatment
total serum cholesterol after the high fiber diet
total serum cholesterol after the low fiber diet
factor to identify order of treatment, with two
levels "HL"
and "LH"
Ramsey, F.L. and Schafer, D.W. (2013). The Statistical Sleuth: A Course in Methods of Data Analysis (3rd ed), Cengage Learning.
Swain, J.F., Rouse, I.L., Curley, C.B., and Sacks, F.M. (1990). Comparison of the Effects of Oat Bran and Low-fiber Wheat on Serum Lipoprotein Levels and Blood Pressure, New England Journal of Medicine 320: 1746–1747.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | str(case1602)
attach(case1602)
## EXPLORATION
highMinusBase <- HiFiber-Baseline
highMinusLow <- HiFiber-LoFiber
plot(highMinusBase ~ highMinusLow)
abline(h=0) # Horizontal line at 0
abline(v=0) # Vertical line at 0
# Hotelling 2-sample t-test for order effect on bivariate response:
myLm1 <- lm(cbind(highMinusBase,highMinusLow) ~ Order ) # Full model
myLm2 <- update(myLm1, ~ . - Order) # Reduced model withour Order effect
anova(myLm2, myLm1, test="Hotelling") # p-value for Order effect
## INFERENCE: HOTELLING ONE-SAMPLE TEST THAT MEAN OF BIVARIATE RESPONSE IS (0,0)
myLm3 <- lm(cbind(highMinusBase, highMinusLow) ~ 1) # Full model
myLm4 <- update(myLm3, ~ . - 1) # Reduced model (with both means = 0)
anova(myLm4, myLm3, test="Hotelling") # test that the bivariate mean is (0,0)
# Confidence intervals
summary(myLm3)
HighMinusBase <- myLm3$coef[1] # -13.850
seHighMinusBase <- 3.533 # Standard error, read from summary(myLm3)
HighMinusLow <- myLm3$coef[2] # -0.850
seHighMinusLow <- 3.527 # Standard error, read from summary(myLm3)
n <- length(highMinusBase) # 20: sample size
multiplier <- sqrt(2*((n-1)/(n-2))*qf(.95,2,n-2)) # See Sleuth, page 495
HighMinusBase + c(-1,1)*multiplier*seHighMinusBase # 95% CI for High - Base
HighMinusLow + c(-1,2)*multiplier*seHighMinusLow # 95% CI for High - Low
## GRAPHICAL DISPLAY FOR PRESENTATION
lowMinusBase <- LoFiber - Baseline
myPointCode <- ifelse(Order== "HL",21,22)
myPointColor <- ifelse(Order== "HL","green","light blue")
plot(highMinusBase ~ lowMinusBase,
xlab="Cholesterol Change (from Baseline) After High Fiber Diet (mg/dl)",
ylab="Cholesterol Change (From Baseline) After Low Fiber Diet (mg/dl)",
main="Cholesterol Effects of High- and Low-Cholesterol Diets on 20 Subjects",
ylim=c(-45,20), pch=myPointCode, bg=myPointColor, cex=2.5, lwd=2)
abline(h=0) # Horizontal line at 0
abline(v=0) # Vertical line at 0
legend(-43,22,c("High Fiber Given First","Low Fiber Given First"), pch=c(21,22),
pt.bg =c("green","light blue"),pt.cex =c(2.5,2.5), lw = c(2,2), lty=c(0,0))
detach(case1602)
|
'data.frame': 20 obs. of 4 variables:
$ Baseline: int 205 161 166 195 206 135 172 172 234 175 ...
$ HiFiber : int 187 145 168 167 174 102 175 157 202 155 ...
$ LoFiber : int 193 138 169 176 203 130 156 161 198 169 ...
$ Order : Factor w/ 2 levels "HL","LH": 1 1 1 1 1 1 1 1 1 1 ...
Analysis of Variance Table
Model 1: cbind(highMinusBase, highMinusLow) ~ 1
Model 2: cbind(highMinusBase, highMinusLow) ~ Order
Res.Df Df Gen.var. Hotelling-Lawley approx F num Df den Df Pr(>F)
1 19 213.50
2 18 -1 208.02 0.17367 1.4762 2 17 0.2564
Analysis of Variance Table
Model 1: cbind(highMinusBase, highMinusLow) ~ 1 - 1
Model 2: cbind(highMinusBase, highMinusLow) ~ 1
Res.Df Df Gen.var. Hotelling-Lawley approx F num Df den Df Pr(>F)
1 20 289.45
2 19 -1 213.50 1.0367 9.3305 2 18 0.001658 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Response highMinusBase :
Call:
lm(formula = highMinusBase ~ 1)
Residuals:
Min 1Q Median 3Q Max
-29.15 -9.65 -1.65 12.85 29.85
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -13.850 3.533 -3.92 0.000919 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 15.8 on 19 degrees of freedom
Response highMinusLow :
Call:
lm(formula = highMinusLow ~ 1)
Residuals:
Min 1Q Median 3Q Max
-28.15 -7.40 -1.65 6.35 33.85
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.850 3.527 -0.241 0.812
Residual standard error: 15.78 on 19 degrees of freedom
[1] -23.528141 -4.171859
[1] -10.51170 18.47341
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.