Module 11 Assignment

Daniel Tafmizi

Lis 4273

Dr. Ajani 

March 24, 2024

Module 11 Assignment

1.

ashina$subject <- factor(1:16)

 attach(ashina)

 act <- data.frame(vas=vas.active, subject, grp = 2)

 plac <-data.frame(vas=vas.plac, subject, grp = 1)

 

 model <- glm(unlist(act)~unlist(plac))

Coefficients:
 (Intercept)  unlist(plac)  
     -13.609         1.236  

Degrees of Freedom: 47 Total (i.e. Null);  46 Residual
Null Deviance:	    95890 
Residual Deviance: 61180 	AIC: 485.4

 plot(model)



The model shows us that the active treatment patients responded better than the placebo treatment patients. I wish I could say more, but to be completely honest; I am very confused. 

2.

a <- gl(2, 2, 8)

b <- gl(2, 4, 8)

x <-- 1:8

y <- c(1:4, 8:5)

z <- rnorm (8)

model.matrix(z~a:b)

  (Intercept) a1:b1 a2:b1 a1:b2 a2:b2
1           1     1     0     0     0
2           1     1     0     0     0
3           1     0     1     0     0
4           1     0     1     0     0
5           1     0     0     1     0
6           1     0     0     1     0
7           1     0     0     0     1
8           1     0     0     0     1

 x<- lm(z~a:b)

Coefficients:
(Intercept)        a1:b1        a2:b1        a1:b2        a2:b2  
    -0.3270      -0.4941      -0.2662       0.6857           NA  


The model matrix expands the given values into a fitted value data frame. It does this by creating dummy variables from the regression coefficients and is listed as 1 or 0. The differences are seen where one B class has values of 1 and the respective class has 0. This is a difference of the mean of the two groups. In our example, each class is different from the next. We see a difference in means in each grouping. The regression coefficients show the variability within each class. We can make predictions by turning this into an equation. Y = -0.3270 - 0.7603(b1) +0.6857(b2)


Comments

Popular posts from this blog

First Day Assignment

Module 10 Assignment

Final Project