Set up an additive model for the ashina data, as part of ISwR package
This data contain additive effects on subjects, period and treatment. Compare the results with those obtained from t tests.
Hint
The additive model shows that treatment significantly affects pain scores (p = 0.005644) which is consistent with the paired t-test result. Many individual subject coefficients are also significant, showing variability in pain response among subjects. The period effect is positive and significant, suggesting that the timing of treatment influences pain scores. The model explains about 75.66% of the variance (R^2 = 0.7566).
Question 2. 10.3.
Consider the following
a <- g1(2, 2, 8) # Creates factor with 2 levels, each repeated 2 times, length 8
b <- g1(2, 4, 8) # Creates factor with 2 levels, each repeated 4 times, length 8
x <- 1:8
y <- c(1:4, 8:5)
z <- rnorm (8)
Note:
The rnorm() is a built-in R function that generates a vector of normally distributed random numbers. The rnorm() method takes a sample size as input and generates that many random numbers.
Your assignment is to generate the model matrices for models
In your assignment, please discuss the implications. Please be reminded about the model fits and notice which models contain singularities.
Hint
We are looking for: model.matrix (~ a:b
); lm (z ~ a:b
)
In the full interaction model (z ~ a * b), all factors and interactions are able to be estimated with no singularities. In the interaction-only model (z ~ a:b
), one interaction term (a2:b2
) is not estimatable due to singularity which shows redundancy. The model fit statistics are similar between models indicating no significant advantage to omitting main effects.