Analyzing a Fatigue Experiment

Data was collected on individuals to analyze the effects of body-fat, smoking and gender on an individual’s physical stress tolerance. The target variable collected was minutes until the subject felt fatigued. The subjects were not screened for anything other than the those mentioned above, so factors such as age, relationship status or exercise habits were not considered.

In the end the data provided us with a good understanding of which factors contribute to physical stress fatigue.

# Load Data
# The varables are coded as follows:
# Smoking = A, 1 = Heavy,  -1 = Light
# Gender = B,  1 = Female, -1 = Male 
# Bodyfat = C, 1 = High,   -1 = Low 

# The results of the target variable are:
tolerance <- matrix(c(24.1,29.2,24.6,17.6, 18.8, 23.2, 
                      20, 21.9, 17.6, 14.8, 10.3, 11.3,
                      14.6, 15.3, 12.3, 14.9, 20.4, 12.8, 
                      16.1, 9.3, 10.8, 10.1, 14.4, 6.1),
                      byrow=T,ncol=3)
# Build Table
dimnames(tolerance) <- list(
  c("(1)","a","b","ab","c","ac","bc","abc"),
    c("Rep1","Rep2","Rep 3"))
A <- as.numeric(rep(c("-1","1"),4))
B <- as.numeric(rep(c("-1","-1","1","1"),2))
C <- as.numeric(c(rep("-1",4),rep("1",4)))
Total <- as.numeric(apply(tolerance,1,sum))
Average <- Total/3
cbind(A,B,C,tolerance,Total)
A B C Rep1 Rep2 Rep 3 Total
(1) -1 -1 -1 24.1 29.2 24.6 77.9
a 1 -1 -1 17.6 18.8 23.2 59.6
b -1 1 -1 20.0 21.9 17.6 59.5
ab 1 1 -1 14.8 10.3 11.3 36.4
c -1 -1 1 14.6 15.3 12.3 42.2
ac 1 -1 1 14.9 20.4 12.8 48.1
bc -1 1 1 16.1 9.3 10.8 36.2
abc 1 1 1 10.1 14.4 6.1 30.6

Next, we organized the data in a table which includes treatment combinations, totals, and averages for each combination. Now, for example, we can see that there is a large difference among males with a light smoking history and low body fat percentage versus males with a light smoking history and high body fat percentage (11.87 minutes).

## Interaction effects
AB <- A*B
AC <- A*C
BC <- B*C
ABC <- A*B*C
cbind(A,B,C,AB,AC,BC,ABC,Total,Average)

## Summary
#Effects <- t(Total) %*% cbind(A,B,C,AB,AC,BC,ABC)/(4*n)
#Summary <- rbind( cbind(A,B,C,AB,AC,BC,ABC),Effects)
#dimnames(Summary)[[1]] <- c(dimnames(tolerance)[[1]],"Effect")
#Summary
A B C AB AC BC ABC Total Average
-1 -1 -1 1 1 1 -1 77.9 25.96667
1 -1 -1 -1 -1 1 1 59.6 19.86667
-1 1 -1 -1 1 -1 1 59.5 19.83333
1 1 -1 1 -1 -1 -1 36.4 12.13333
-1 -1 1 1 -1 -1 1 42.2 14.06667
1 -1 1 -1 1 -1 -1 48.1 16.03333
-1 1 1 -1 -1 1 -1 36.2 12.06667
1 1 1 1 1 1 1 30.6 10.20000

Now we run a model to estimate parameters and conduct an analysis of variance. The ANOVA table is below.

# Fit as an ANOVA model
tolerance.vec <- c(t(tolerance))
Af <- rep(as.factor(A),rep(3,8))
Bf <- rep(as.factor(B),rep(3,8))
Cf <- rep(as.factor(C),rep(3,8))
options(contrasts=c("contr.sum","contr.poly"))
tol.lm <- lm(tolerance.vec ~ Af*Bf*Cf)
anova(tol.lm)
Df Sum Sq Mean Sq F value Pr(>F)
Af 1 70.383750 70.383750 7.5394332 0.0143573964
Bf 1 176.583750 176.583750 18.9154653 0.0004970517
Cf 1 242.570417 242.570417 25.9838875 0.0001075770
Af:Bf 1 11.070417 11.070417 1.1858514 0.2922988652
Af:Cf 1 72.453750 72.453750 7.7611694 0.0132205135
Bf:Cf 1 13.650417 13.650417 1.4622183 0.2441432427
Af:Bf:Cf 1 1.870417 1.870417 0.2003571 0.6604336459
Residuals 16 149.366667 9.335417 NA NA

The analysis of variance confirms that all three main effects and one interaction effect (AC, or Smoking and Body-fat) are significant. Then the reduced model may be described as below.

# Reduced ANOVA
tol.lm2 <- lm(tolerance.vec ~ Bf+Af*Cf+Af)
anova(tol.lm2)
Df Sum Sq Mean Sq F value Pr(>F)
Bf 1 176.58375 176.583750 19.067578 3.319784e-04
Af 1 70.38375 70.383750 7.600063 1.254795e-02
Cf 1 242.57042 242.570417 26.192842 6.113833e-05
Af:Cf 1 72.45375 72.453750 7.823582 1.149689e-02
Residuals 19 175.95792 9.260943 NA NA
# Residuls
tol.res = resid(tol.lm2)
tolerance.data = c(24.1,29.2,24.6,17.6, 18.8, 23.2, 20, 21.9, 17.6, 14.8, 10.3, 11.3,
                   14.6, 15.3, 12.3, 14.9, 20.4, 12.8, 
                   16.1, 9.3, 10.8, 10.1, 14.4, 6.1)
plot(tolerance.data, tol.res, 
     ylab="Residuals", xlab="Tolerance (minutes)", 
     main="Stress Test, Residual Plot", col=tolerance,pch=16) 
abline(0, 0)

# Normal Prob.
# Check if error term is normally distributed
tol.stdres = rstandard(tol.lm2)
qqnorm(tol.stdres, 
            ylab="Standardized Residuals", 
            xlab="Normal Scores", 
            main="Stress Test, Normal Probability Plot") 
qqline(tol.stdres, col=16)

# Shapiro test
shapiro.test(tol.res)
1
	Shapiro-Wilk normality test

data:  tol.res
W = 0.93256, p-value = 0.1112
2

In the above residual and normal probability plots, we see the assumptions of constancy and normality hold.
Additionally, there appears to be no outliers. Also confirmed through the Shapiro Wilk’s test, which fails to reject the hypothesis of normality at the 5% level.

## Interaction Plots
A2 <- rep(c("Light","Heavy"),4)
B2 <- rep(c("Male","Male","Female","Female"),2)
C2 <- c(rep("Low",4),rep("High",4))
Af2 <- rep(as.factor(A2),rep(3,8))
Bf2 <- rep(as.factor(B2),rep(3,8))
Cf2 <- rep(as.factor(C2),rep(3,8))
Smoking <- Af2
Gender <- Bf2
Fat <- Cf2
interaction.plot(Gender, Smoking, tolerance.vec, col  
                 = c("red","blue"), lty=1, leg.bty = "o", 
                 main = "Interaction Plot, Gender and Smoking")
3
interaction.plot(Gender, Fat, tolerance.vec, col  
                 = c("red","blue"), lty=1, leg.bty = "o",
                 main= "Interaction plot, Gender and Fat Level")
4
interaction.plot(Smoking, Fat, tolerance.data, col  
                 = c("red","blue"), lty=1, leg.bty = "o",
                 main= "Interaction plot, Smoking and Fat Level")
5

As seen in the interaction plot above, subjects with heavy smoking history and low body fat showed significantly lower mean physical stress tolerance compared to subjects with light smoking history and low body fat, which is not surprising. However, subjects with heavy smoking histories and high body fat have about the same mean tolerance as those with light smoking histories and high body fat. Furthermore, subjects with light smoking histories and high body fat had significantly lower mean physical stress tolerance compared to those with light smoking histories and low fat. This sort of significance was not exhibited in other factor level comparisons. This suggests that heavy smoking does not lower physical stress tolerance in high body fat individuals.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s