Description Usage Arguments Value Author(s) Examples
This function returns the design matrix for an ordinal Bradley-Terry-Luce model.
1 2 3 |
X |
a data frame in long format (see |
var1 |
a character of the column name from |
var2 |
a character of the column name from |
use.vars |
a character vector with the names of additional covariates
of |
reference |
a character specifying the reference object. |
prefix |
(optional) a character added in the names of the estimated object parameters |
prefix.home |
(optional) a character added in the names of the estimated home advantage parameters |
home.advantage |
Note that the home advantage is equivalent to an order effect
|
A data frame where each row refers to a pair comparison and each column corresponds to an object.
Giuseppe Casalicchio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # 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)
|
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Loading required package: VGAM
Loading required package: stats4
Loading required package: splines
Attaching package: 'VGAM'
The following object is masked from 'package:caret':
predictors
Loading required package: wikibooks
Loading required package: gtools
Attaching package: 'gtools'
The following object is masked from 'package:VGAM':
logit
'data.frame': 306 obs. of 11 variables:
$ Saison : Factor w/ 44 levels "1963/1964","1964/1965",..: 43 43 43 43 43 43 43 43 43 43 ...
$ Spieltag : int 1 1 1 1 1 1 1 1 1 2 ...
$ Datum : Date, format: "2005-08-05" "2005-08-06" ...
$ Anpfiff : Factor w/ 31 levels "14:00","14:15",..: 28 6 6 6 6 6 6 15 15 6 ...
$ Heim : Factor w/ 50 levels "1. FC Kaiserslautern",..: 18 2 31 24 49 40 25 20 16 8 ...
$ Gast : Factor w/ 50 levels "1. FC Kaiserslautern",..: 11 5 47 3 10 7 27 1 8 18 ...
$ Tore.Heim : int 3 1 1 3 2 5 2 2 1 2 ...
$ Tore.Gast : int 0 0 1 0 2 2 2 1 4 5 ...
$ Tore.Heim.Halbzeit: int 1 0 1 2 1 3 0 0 1 1 ...
$ Tore.Gast.Halbzeit: int 0 0 1 0 0 2 0 1 1 3 ...
$ Y3 : Ord.factor w/ 3 levels "1"<"2"<"3": 1 1 2 1 2 1 2 1 3 3 ...
'data.frame': 306 obs. of 18 variables:
$ GAMMA.1.FC.Kaiserslautern : num 0 0 0 0 0 0 0 -1 0 0 ...
$ GAMMA.1.FC.Koeln : num 0 1 0 0 0 0 0 0 0 0 ...
$ GAMMA.1.FC.Nuernberg : num 0 0 0 -1 0 0 0 0 0 0 ...
$ GAMMA.1.FSV.Mainz.05 : num 0 -1 0 0 0 0 0 0 0 0 ...
$ GAMMA.Arminia.Bielefeld : num 0 0 0 0 0 -1 0 0 0 0 ...
$ GAMMA.Bayer.Leverkusen : num 0 0 0 0 0 0 0 0 -1 1 ...
$ GAMMA.Borussia.Dortmund : num 0 0 0 0 -1 0 0 0 0 0 ...
$ GAMMA.Borussia.Moenchengladbach: num -1 0 0 0 0 0 0 0 0 0 ...
$ GAMMA.Eintracht.Frankfurt : num 0 0 0 0 0 0 0 0 1 0 ...
$ GAMMA.FC.Bayern.Muenchen : num 1 0 0 0 0 0 0 0 0 -1 ...
$ GAMMA.FC.Schalke.04 : num 0 0 0 0 0 0 0 1 0 0 ...
$ GAMMA.Hamburger.SV : num 0 0 0 1 0 0 0 0 0 0 ...
$ GAMMA.Hannover.96 : num 0 0 0 0 0 0 1 0 0 0 ...
$ GAMMA.Hertha.BSC.Berlin : num 0 0 0 0 0 0 -1 0 0 0 ...
$ GAMMA.MSV.Duisburg : num 0 0 1 0 0 0 0 0 0 0 ...
$ GAMMA.SV.Werder.Bremen : num 0 0 0 0 0 1 0 0 0 0 ...
$ GAMMA.VfB.Stuttgart : num 0 0 -1 0 0 0 0 0 0 0 ...
$ GAMMA.VfL.Wolfsburg : num 0 0 0 0 1 0 0 0 0 0 ...
'data.frame': 306 obs. of 19 variables:
$ GAMMA.1.FC.Kaiserslautern : num 0 0 0 0 0 0 0 -1 0 0 ...
$ GAMMA.1.FC.Koeln : num 0 1 0 0 0 0 0 0 0 0 ...
$ GAMMA.1.FC.Nuernberg : num 0 0 0 -1 0 0 0 0 0 0 ...
$ GAMMA.1.FSV.Mainz.05 : num 0 -1 0 0 0 0 0 0 0 0 ...
$ GAMMA.Arminia.Bielefeld : num 0 0 0 0 0 -1 0 0 0 0 ...
$ GAMMA.Bayer.Leverkusen : num 0 0 0 0 0 0 0 0 -1 1 ...
$ GAMMA.Borussia.Dortmund : num 0 0 0 0 -1 0 0 0 0 0 ...
$ GAMMA.Borussia.Moenchengladbach: num -1 0 0 0 0 0 0 0 0 0 ...
$ GAMMA.Eintracht.Frankfurt : num 0 0 0 0 0 0 0 0 1 0 ...
$ GAMMA.FC.Bayern.Muenchen : num 1 0 0 0 0 0 0 0 0 -1 ...
$ GAMMA.FC.Schalke.04 : num 0 0 0 0 0 0 0 1 0 0 ...
$ GAMMA.Hamburger.SV : num 0 0 0 1 0 0 0 0 0 0 ...
$ GAMMA.Hannover.96 : num 0 0 0 0 0 0 1 0 0 0 ...
$ GAMMA.Hertha.BSC.Berlin : num 0 0 0 0 0 0 -1 0 0 0 ...
$ GAMMA.MSV.Duisburg : num 0 0 1 0 0 0 0 0 0 0 ...
$ GAMMA.SV.Werder.Bremen : num 0 0 0 0 0 1 0 0 0 0 ...
$ GAMMA.VfB.Stuttgart : num 0 0 -1 0 0 0 0 0 0 0 ...
$ GAMMA.VfL.Wolfsburg : num 0 0 0 0 1 0 0 0 0 0 ...
$ ALPHA : num 1 1 1 1 1 1 1 1 1 1 ...
'data.frame': 306 obs. of 36 variables:
$ GAMMA.1.FC.Kaiserslautern : num 0 0 0 0 0 0 0 -1 0 0 ...
$ GAMMA.1.FC.Koeln : num 0 1 0 0 0 0 0 0 0 0 ...
$ GAMMA.1.FC.Nuernberg : num 0 0 0 -1 0 0 0 0 0 0 ...
$ GAMMA.1.FSV.Mainz.05 : num 0 -1 0 0 0 0 0 0 0 0 ...
$ GAMMA.Arminia.Bielefeld : num 0 0 0 0 0 -1 0 0 0 0 ...
$ GAMMA.Bayer.Leverkusen : num 0 0 0 0 0 0 0 0 -1 1 ...
$ GAMMA.Borussia.Dortmund : num 0 0 0 0 -1 0 0 0 0 0 ...
$ GAMMA.Borussia.Moenchengladbach: num -1 0 0 0 0 0 0 0 0 0 ...
$ GAMMA.Eintracht.Frankfurt : num 0 0 0 0 0 0 0 0 1 0 ...
$ GAMMA.FC.Bayern.Muenchen : num 1 0 0 0 0 0 0 0 0 -1 ...
$ GAMMA.FC.Schalke.04 : num 0 0 0 0 0 0 0 1 0 0 ...
$ GAMMA.Hamburger.SV : num 0 0 0 1 0 0 0 0 0 0 ...
$ GAMMA.Hannover.96 : num 0 0 0 0 0 0 1 0 0 0 ...
$ GAMMA.Hertha.BSC.Berlin : num 0 0 0 0 0 0 -1 0 0 0 ...
$ GAMMA.MSV.Duisburg : num 0 0 1 0 0 0 0 0 0 0 ...
$ GAMMA.SV.Werder.Bremen : num 0 0 0 0 0 1 0 0 0 0 ...
$ GAMMA.VfB.Stuttgart : num 0 0 -1 0 0 0 0 0 0 0 ...
$ GAMMA.VfL.Wolfsburg : num 0 0 0 0 1 0 0 0 0 0 ...
$ ALPHA.1.FC.Kaiserslautern : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.1.FC.Koeln : num 0 1 0 0 0 0 0 0 0 0 ...
$ ALPHA.1.FC.Nuernberg : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.1.FSV.Mainz.05 : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.Arminia.Bielefeld : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.Bayer.Leverkusen : num 0 0 0 0 0 0 0 0 0 1 ...
$ ALPHA.Borussia.Dortmund : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.Borussia.Moenchengladbach: num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.Eintracht.Frankfurt : num 0 0 0 0 0 0 0 0 1 0 ...
$ ALPHA.FC.Bayern.Muenchen : num 1 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.FC.Schalke.04 : num 0 0 0 0 0 0 0 1 0 0 ...
$ ALPHA.Hamburger.SV : num 0 0 0 1 0 0 0 0 0 0 ...
$ ALPHA.Hannover.96 : num 0 0 0 0 0 0 1 0 0 0 ...
$ ALPHA.Hertha.BSC.Berlin : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.MSV.Duisburg : num 0 0 1 0 0 0 0 0 0 0 ...
$ ALPHA.SV.Werder.Bremen : num 0 0 0 0 0 1 0 0 0 0 ...
$ ALPHA.VfB.Stuttgart : num 0 0 0 0 0 0 0 0 0 0 ...
$ ALPHA.VfL.Wolfsburg : num 0 0 0 0 1 0 0 0 0 0 ...
'data.frame': 306 obs. of 19 variables:
$ GAMMA.1.FC.Kaiserslautern : num 0 0 0 0 0 0 0 -1 0 0 ...
$ GAMMA.1.FC.Koeln : num 0 1 0 0 0 0 0 0 0 0 ...
$ GAMMA.1.FC.Nuernberg : num 0 0 0 -1 0 0 0 0 0 0 ...
$ GAMMA.1.FSV.Mainz.05 : num 0 -1 0 0 0 0 0 0 0 0 ...
$ GAMMA.Arminia.Bielefeld : num 0 0 0 0 0 -1 0 0 0 0 ...
$ GAMMA.Bayer.Leverkusen : num 0 0 0 0 0 0 0 0 -1 1 ...
$ GAMMA.Borussia.Dortmund : num 0 0 0 0 -1 0 0 0 0 0 ...
$ GAMMA.Borussia.Moenchengladbach: num -1 0 0 0 0 0 0 0 0 0 ...
$ GAMMA.Eintracht.Frankfurt : num 0 0 0 0 0 0 0 0 1 0 ...
$ GAMMA.FC.Bayern.Muenchen : num 1 0 0 0 0 0 0 0 0 -1 ...
$ GAMMA.FC.Schalke.04 : num 0 0 0 0 0 0 0 1 0 0 ...
$ GAMMA.Hamburger.SV : num 0 0 0 1 0 0 0 0 0 0 ...
$ GAMMA.Hannover.96 : num 0 0 0 0 0 0 1 0 0 0 ...
$ GAMMA.Hertha.BSC.Berlin : num 0 0 0 0 0 0 -1 0 0 0 ...
$ GAMMA.MSV.Duisburg : num 0 0 1 0 0 0 0 0 0 0 ...
$ GAMMA.SV.Werder.Bremen : num 0 0 0 0 0 1 0 0 0 0 ...
$ GAMMA.VfB.Stuttgart : num 0 0 -1 0 0 0 0 0 0 0 ...
$ GAMMA.VfL.Wolfsburg : num 0 0 0 0 1 0 0 0 0 0 ...
$ Spieltag : int 1 1 1 1 1 1 1 1 1 2 ...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.