library(qgcompint)
n = 500
dat <- data.frame(y=rbinom(n, 1, 0.5), cd=runif(n), pb=runif(n),
raceth=factor(sample(c("WNH", "BNH", "AMIND"), n, replace=TRUE),
levels = c("BNH", "WNH", "AMIND")))
(qfit <- qgcomp.emm.glm.noboot(f=y ~cd + pb, emmvar="raceth",
expnms = c('cd', 'pb'), data=dat, q=4,
family=binomial()))
# first level of the stratifying variable should be the referent category,
# which you can set with the "levels" argument to "factor" when
# cleaning/generating data
levels(dat$raceth)
# stratum specific mixture log-odds ratios
# this one comes straight from the model (psi 1)
getjointeffects(qfit, emmval = "BNH")
# this will coincide with joint effects, since it is in the referent category
getstrateffects(qfit, emmval = "BNH")
# the stratum specific effect for a non-referent category of the EMM
# will not coincide with the joint effect
getjointeffects(qfit, emmval = "AMIND")
getstrateffects(qfit, emmval = "AMIND")
Run the code above in your browser using DataLab