lrt.hopit: Likelihood ratio test for a pair of models

lrt.hopitR Documentation

Likelihood ratio test for a pair of models

Description

Likelihood ratio test for a pair of models

Usage

lrt.hopit(full, nested)

Arguments

full, nested

models to be compared.

Value

a vector with the results of the test.

Author(s)

Maciej J. Danko

See Also

print.lrt.hopit, anova.hopit, 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 ---------------------

# fitting two nested models
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)

# model with an interaction between hypertension and high_cholesterol
model2 <- 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)

# Likelihood ratio test
lrt1 <- lrt.hopit(full = model2, nested = model1)
lrt1

# print the results in a shorter form
print(lrt1, short = TRUE)

# equivalently
print(anova(model2, model1), short = TRUE)


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