data("metals") # from qgcomp package
# create categorical outcome from the existing continuous outcome (usually, one will already exist)
metals$ycat = factor(quantize(metals, "y",q=4)$data$y, levels=c("0", "1", "2", "3"),
labels=c("cct", "ccg", "aat", "aag"))
# restrict to smaller dataset for simplicity
smallmetals = metals[,c("ycat", "arsenic", "lead", "cadmium", "mage35")]
### 1: Define mixture and underlying model ####
mixture = c("arsenic", "lead", "cadmium")
f0 = ycat ~ arsenic + lead + cadmium # the multinomial model
# (be sure that factor variables are properly coded ahead of time in the dataset)
rr = qgcomp.multinomial.noboot(
f0,
expnms = mixture,
q=4,
data = smallmetals,
)
### 5: Create summary qgcomp object for nice printing ####
summary(rr, tests=c("H")) # include homogeneity test
# 95% confidence intervals
confint(rr, level=0.95)
rr$breaks # quantile cutpoints for exposures
# homogeneity_test(rr)
joint_test(rr)
Run the code above in your browser using DataLab