Last chance! 50% off unlimited learning
Sale ends in
design(X, var1, var2, use.vars=NULL, reference=NULL, prefix="GAMMA", prefix.home="ALPHA", home.advantage=c("no","specific","yes"))
wide2long
).X
specifying the first object to be compared (or, in sport context, the home team).X
specifying the second object to be compared (or, in sport context, the away team).X
that will additionally be included into the design matrix.
(example: use.vars = c("ENG", "SEX")
) if the covariates ENG
and SEX
should be included.
If all covariates of X
should be included, you can use use.vars = "ALL"
.
The default is use.vars = NULL
for no additional covariates.home.advantage="no"
uses no home advantage (order effect),
home.advantage="specific"
uses one home advantage (order effect) for each object and
home.advantage="yes"
uses one home advantage (order effect) for any object.# load german football-league (Bundesliga) data
library("wikibooks")
data(Bundesliga)
# add new variable Y3 reflecting the response which is coded as
# 1 if the home team wins
# 2 if the game ends up with a tie
# 3 if the home team loses
diff <- Bundesliga$Tore.Heim - Bundesliga$Tore.Gast
Bundesliga$Y3 <- as.ordered(ifelse(diff >= 1, 1,
ifelse(diff <= -1, 3, 2)))
buli0506 <- subset(Bundesliga, Saison=="2005/2006")
str(buli0506)
# Design matrix without home advantage
des.nohome <- design(buli0506, var1="Heim", var2="Gast",
home.advantage="no")
str(des.nohome)
# Design matrix with one home advantage parameter for all objects
des.onehome <- design(buli0506, var1="Heim", var2="Gast",
home.advantage="yes")
str(des.onehome)
# Design matrix with home advantage parameters for each object
des.teamhome <- design(buli0506, var1="Heim", var2="Gast",
home.advantage="specific")
str(des.teamhome)
# Design matrix with additional covariable "Spieltag"
des.covs <- design(buli0506, var1="Heim", var2="Gast",
use.vars=c("Spieltag"), home.advantage="no")
str(des.covs)
Run the code above in your browser using DataLab