Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Solutions to problems
Solved problems: 4.1, H:1, HTF 5.1, 5.5
the R-code for problem 4.1.. #Ex. 4.1 #Load library stats library(stats) #Write datafram with all possible combination of factors 4*4*4=64 dd <- data.frame(A = gl(4,16), B = gl(4,1,64), C = gl(4,4,64)) #Say that you want some ( e.g. here sum-to-zero) constraints on main and first-order effects options("contrasts") #In model.matrix: 1. define model, ()^2 indicates that the model should include first-order interactions; #2. give all possible combinations in a dataframe, 3. give constraints in a list vector model.matrix(~ (A + B + C)^2, dd, contrasts = list(A = "contr.sum",B = "contr.sum", C = "contr.sum"))