# DATA
data(healthsurvey)
# the order of response levels decreases from the best health to
# the worst health; hence the hopit() parameter decreasing.levels
# is set to TRUE
levels(healthsurvey$health)
# Example 1 ---------------------
# fit a model
model1 <- hopit(latent.formula = health ~ hypertension + high_cholesterol +
heart_attack_or_stroke + poor_mobility + very_poor_grip +
depression + respiratory_problems +
IADL_problems + obese + diabetes + other_diseases,
thresh.formula = ~ sex + ageclass + country,
decreasing.levels = TRUE,
control = list(trace = FALSE),
data = healthsurvey)
# a function that modifies the coefficient names.
txtfun <- function(x) gsub('_',' ',substr(x,1,nchar(x)-3))
# calculate and plot the disability weights
sc <- standardizeCoef(model1, namesf = txtfun)
sc
summary(sc)
plot(sc)
Run the code above in your browser using DataLab