Module #11 Assignment

 11/6/2023


10.1

library(ISwR)

data(ashina)

data

ashina$subject <- factor(1:16)

attach(ashina)

act <- data.frame(vas=vas.active, subject, treat=1, period=grp)

plac <-data.frame(vas=vas.plac, subject, treat=0, period = grp)


first I created the model: 

additive_model <- aov(vas ~ treat + subject + period, data = rbind(act, plac))                  
> anova(additive_model)                  
Analysis of Variance Table

Response: vas
          Df Sum Sq Mean Sq F value   Pr(>F)   
treat      1  14706 14706.1  10.413 0.005644 **
subject   15  51137  3409.2   2.414 0.049184 * 
Residuals 15  21184  1412.3                    
---
Signif. codes:  
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> t_test_1 <- t.test(vas ~ treat, data = ashina, subset = period == 1)
> t_test_2 <- t.test(vas ~ treat, data = act, subset = period == 2)



10.3

> model_1 <- lm(z ~ a * b)
model_2 <- lm(z ~ a:b)
Call:
lm(formula = z ~ a * b)

Coefficients:
(Intercept)            a            b          a:b  
     3.3666      -3.3252      -0.8162       0.8592  

> model_2

Call:
lm(formula = z ~ a:b)

Coefficients:
(Intercept)          a:b  
   -0.43716      0.05247 

The a * b model includes the effect of a and b and the way they interact with z. The coefficients in a and b indicate the change in z for one unit changes in a and b. 
The a:b model includes the interaction between a and b on z instead of the effects of a and b.
After printing the summaries of each model, there are no NA coefficients, leading me to believe that there are no singularities. 

Comments

Popular posts from this blog

Module #12 Assignment

Module #9 Assignment