View source: R/lrt_order_inad.R
| test_order_inad | R Documentation |
Performs a likelihood ratio test comparing INAD models of different orders.
test_order_inad(
y,
order_null = 0,
order_alt = 1,
thinning = "binom",
innovation = "pois",
blocks = NULL,
use_chibar = TRUE,
weights = NULL,
fit_null = NULL,
fit_alt = NULL,
...
)
y |
Integer matrix with n_subjects rows and n_time columns. |
order_null |
Order under null hypothesis (0 or 1). |
order_alt |
Order under alternative hypothesis (1 or 2). Must be order_null + 1. |
thinning |
Thinning operator: "binom", "pois", or "nbinom". |
innovation |
Innovation distribution: "pois", "bell", or "nbinom". |
blocks |
Optional integer vector for block effects. |
use_chibar |
Logical; if TRUE, use chi-bar-square for boundary test. |
weights |
Optional weights for chi-bar-square mixture. |
fit_null |
Optional pre-computed null fit. |
fit_alt |
Optional pre-computed alternative fit. |
... |
Additional arguments passed to fit_inad. |
The test compares nested INAD models of orders order_null and
order_alt = order_null + 1 using:
\lambda = 2(\ell_{alt} - \ell_{null})
where \ell_{null} and \ell_{alt} are maximized log-likelihoods
under the null and alternative models.
The default p-value uses the chi-square approximation with degrees of freedom
matching the number of additional dependence parameters introduced under the
higher-order model. When use_chibar = TRUE, a chi-bar-square mixture
p-value is also reported for boundary-aware inference.
Missing-data inputs are supported through the same na_action options
available in fit_inad. If y has missing values and
na_action is not supplied via ..., this function defaults to
na_action = "marginalize".
A list with class "test_order_inad" containing:
Inference method used ("lrt").
Fitted model under H0
Fitted model under H1
Test statistic value
Likelihood ratio test statistic
Degrees of freedom
Chi-square p-value
Chi-bar-square p-value (if use_chibar = TRUE)
BIC under H0
BIC under H1
Which model BIC prefers
Two-row model comparison table
Input and derived settings for the test
Li, C. and Zimmerman, D.L. (2026). Integer-valued antedependence models for longitudinal count data. Biostatistics.
fit_inad, bic_order_inad,
test_stationarity_inad
set.seed(1)
y <- simulate_inad(
n_subjects = 40,
n_time = 5,
order = 1,
thinning = "binom",
innovation = "pois",
alpha = 0.3,
theta = 2
)
out <- test_order_inad(
y,
order_null = 0,
order_alt = 1,
thinning = "binom",
innovation = "pois",
max_iter = 20
)
out$statistic
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.