if (FALSE) {
data(fysio, package = "R2MLwiN")
# Example taken from Leyland and Groenewegen (2020)
# Change contrasts if wish to avoid warning indicating that, by default,
# specified contrasts for ordered predictors will be ignored by runMLwiN
# (they will be fitted as "contr.treatment" regardless of this setting). To
# enable specified contrasts, set allowcontrast to TRUE (this will be the
# default in future package releases).
my_contrasts <- options("contrasts")$contrasts
options(contrasts = c(unordered = "contr.treatment",
ordered = "contr.treatment"))
# As an alternative to changing contrasts, can instead use C() to specify
# contrasts for ordered predictors in formula object, e.g.:
# F1 <- logit(referral) ~ 1 + C(pagegrp, "contr.treatment") + patsex + diag +
# C(patedu, "contr.treatment") + patinsur + gpexper + gpworkload +
# practype + location + gpphysifr +
# (1 | gpid)
#
# (mod_MQL1 <- runMLwiN(Formula = F1,
# D = "Binomial",
# data = fysio,
# allowcontrast = TRUE))
F1 <- logit(referral) ~ 1 + pagegrp + patsex + diag +
patedu + patinsur + gpexper + gpworkload +
practype + location + gpphysifr +
(1 | gpid)
(mod_MQL1 <- runMLwiN(Formula = F1,
D = "Binomial",
data = fysio))
(mod_PQL2 <- runMLwiN(Formula = F1,
estoptions = list(nonlinear = c(N = 1, M = 2),
startval = list(FP.b = mod_MQL1@FP,
FP.v = mod_MQL1@FP.cov,
RP.b = mod_MQL1@RP,
RP.v = mod_MQL1@RP.cov)),
D = "Binomial",
data = fysio))
# Change contrasts back to pre-existing:
options(contrasts = my_contrasts)
}
Run the code above in your browser using DataLab