Learn R Programming

hopit (version 0.9.0)

latentIndex: Calculate the latent index

Description

Calculate the latent index from the fitted model. The latent index is a standardized latent measure that takes values from 0 to 1, where 0 refers to the worst predicted state (the maximal observed value for the latent measure) and 1 refers to the best predicted state (the minimal observed value for the latent measure).

Usage

latentIndex(model, decreasing.levels = TRUE, subset = NULL,
  plotf = FALSE, response = c("data", "fitted", "Jurges"),
  ylab = "Latent index", ...)

healthIndex(model, decreasing.levels = TRUE, subset = NULL, plotf = FALSE, response = c("data", "fitted", "Jurges"), ylab = "Latent index", ...)

Arguments

model

a fitted hopit model.

decreasing.levels

a logical indicating whether self-reported (e.g., health) classes are ordered in decreasing order.

subset

an optional vector that specifies a subset of observations.

plotf

a logical indicating whether to plot the summary figure.

response

X-axis plotting option; choose 'data' for the raw responses and 'fitted' for the responses reclassified by the model.

ylab

a label of the y-axis.

...

further parameters passed to the plot function.

Value

a vector with a latent index for each individual.

References

Jurges2007hopit OKSUZYAN2019hopit

See Also

standardizeCoef, getCutPoints, getLevels, hopit.

Examples

Run this code
# 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