latentIndex: Calculate the latent index

View source: R/reportingheterogeneity.R

latentIndexR Documentation

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, subset = NULL)

healthIndex(model, subset = NULL)

Arguments

model

a fitted hopit model.

subset

an optional vector that specifies a subset of observations.

Value

a vector with a latent index for each individual.

Author(s)

Maciej J. Danko

References

\insertRef

Jurges2007hopit

\insertRefOKSUZYAN2019hopit

See Also

standardizeCoef, getCutPoints, getLevels, hopit.

Examples

# 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
hi <- latentIndex(model1)

summary(hi)

# plot a simple histogram of the function output
hist(hi, col='deepskyblue3')

#plot the reported health status versus the health index.
plot(hi, response = "data", ylab = 'Health index',
     col='deepskyblue3', main = 'Reported health levels')

# plot the model-predicted health levels versus the health index.
plot(hi, response = "fitted", ylab = 'Health index',
     col='deepskyblue3', main = 'Model-predicted health levels')

MaciejDanko/gotm documentation built on Oct. 1, 2022, 12:59 p.m.