# NOT RUN {
# 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)
# calculate the health index and plot the reported health status
# versus the health index.
hi <- latentIndex(model1, plotf = TRUE, response = "data",
ylab = 'Health index', col='deepskyblue3')
# plot a simple histogram of the function output
hist(hi)
# calculate the health index and plot the adjusted health status vs. the health index
# using Jurges (Jurges 2007) method.
latentIndex(model1, plotf = TRUE, response = "Jurges",
ylab = 'Health index', col='deepskyblue3')
# calculate the health index and plot the model-predicted health levels
# versus the health index.
latentIndex(model1, plotf = TRUE, response = "fitted",
ylab = 'Health index', col='deepskyblue3')
# }
Run the code above in your browser using DataLab