This vignette shows a minimal analysis report: fit a model, print fixed effects, plot fitted vs observed, and show residual ACF and Q-Q.
library(tidyILD)
d <- ild_simulate(n_id = 8, n_obs_per = 10, irregular = TRUE, seed = 101)
x <- ild_prepare(d, id = "id", time = "time", gap_threshold = 7200)
x <- ild_center(x, y)
fit <- ild_lme(y ~ y_bp + y_wp + (1 | id), data = x, ar1 = FALSE, warn_no_ar1 = FALSE)
#> Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
#> Model failed to converge with max|grad| = 0.117947 (tol = 0.002, component 1)
#> Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
#> - Rescale variables?diag <- ild_diagnostics(fit, type = c("residual_acf", "qq"))
diag
#> ILD diagnostics
#> Engine: lmer
#> AR1/CAR1: no
#> Id column: id Time column: time
#> N persons: 8 N observations: 80
#> Types computed: residual_acf, qqSame workflow with residual autocorrelation (nlme path). If the AR1 model fails to converge on this small example, we show the code only; in practice use more data or a different seed.
fit_ar1 <- tryCatch(
ild_lme(y ~ y_bp + y_wp, data = x, random = ~ 1 | id, ar1 = TRUE),
error = function(e) NULL
)
if (!is.null(fit_ar1)) {
tidy_ild_model(fit_ar1)
} else {
message("AR1 fit did not converge on this run; use ild_lme(..., ar1 = TRUE) with your data.")
}
#> AR1 fit did not converge on this run; use ild_lme(..., ar1 = TRUE) with your data.