| Title: | Variance-Guided Time-Series Modeling for Temporal Risk Detection |
|---|---|
| Description: | Fits balanced-panel autoregressive models with conditional heteroscedasticity for temporal risk detection. The main estimator combines autoregressive exogenous mean modeling with GARCH-X variance modeling, subject-specific baseline terms, shared population coefficients, and L1 penalization for high-dimensional covariates. The package returns conditional mean and variance estimates, coefficient summaries, simulations, and exceedance-based risk scores defined as estimated conditional threshold-exceedance probabilities. The implementation builds on the lasso of Tibshirani (1996) <doi:10.1111/j.2517-6161.1996.tb02080.x>, generalized autoregressive conditional heteroscedasticity of Bollerslev (1986) <doi:10.1016/0304-4076(86)90063-1>, and L1-regularized high-dimensional time-series modeling of Medeiros and Mendes (2016) <doi:10.1016/j.jeconom.2015.10.011>. |
| Authors: | Zihao Wang [aut], Min Lu [aut, cre] |
| Maintainer: | Min Lu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.13 |
| Built: | 2026-10-17 08:47:05 UTC |
| Source: | https://github.com/cran/varGuidTS |
Fits a balanced panel ARX-GARCHX model with subject-specific
intercepts, shared population coefficients, and joint L1
penalization on the conditional mean and variance. Provides an
exceedance-based risk score
for personalized
temporal risk assessment from wearable-sensor and other high-frequency
panel time-series data.
Maintainer: Min Lu [email protected]
Authors: Zihao Wang, Min Lu
Tibshirani R. (1996). "Regression Shrinkage and Selection Via the Lasso." Journal of the Royal Statistical Society: Series B, 58(1), 267–288. doi:10.1111/j.2517-6161.1996.tb02080.x
Bollerslev T. (1986). "Generalized Autoregressive Conditional Heteroskedasticity." Journal of Econometrics, 31(3), 307–327. doi:10.1016/0304-4076(86)90063-1
Medeiros M. C. and Mendes E. F. (2016). "L1-Regularization of High-Dimensional Time-Series Models with Non-Gaussian and Heteroskedastic Errors." Journal of Econometrics, 191(1), 255–271. doi:10.1016/j.jeconom.2015.10.011
lmvt, predict.lmvt,
summary.lmvt, simulate_scenario
coef() returns the list of fitted parameter blocks
(subject-specific intercepts, AR coefficients, mean covariate
coefficients, baseline variances, ARCH/GARCH parameters, and
variance covariate coefficients).
print() produces a one-screen summary of the fit.
## S3 method for class 'lmvt' coef(object, ...) ## S3 method for class 'lmvt' print(x, ...)## S3 method for class 'lmvt' coef(object, ...) ## S3 method for class 'lmvt' print(x, ...)
object, x
|
A fitted |
... |
Unused. |
For coef.lmvt(), a named list containing fitted coefficient blocks:
alphasubject-specific intercepts in the conditional mean model.
thetashared autoregressive coefficients for lagged responses.
betashared coefficients for covariates in the conditional mean model.
omegasubject-specific baseline variance parameters.
ashared ARCH coefficients for lagged squared residuals.
bshared GARCH coefficients for lagged conditional variances.
gammashared coefficients for covariates in the conditional variance model.
For print.lmvt(), the fitted object x is returned invisibly after
printing a short model summary.
Joint maximum-quasi-likelihood fit of the conditional mean and variance across a balanced panel of subjects, with subject-specific intercepts, shared population coefficients, and L1 penalties on the mean and variance covariate vectors.
lmvt(data, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0, lambda_gamma = 0, maxit = 200, tol = 1e-4, standardize_X = TRUE, use_x_in_variance = TRUE, phi_cap = 0.995, omega_min = 1e-6, omega_cap_mult = 10, gamma_steps = 8, gamma_step = 1e-3, verbose = FALSE)lmvt(data, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0, lambda_gamma = 0, maxit = 200, tol = 1e-4, standardize_X = TRUE, use_x_in_variance = TRUE, phi_cap = 0.995, omega_min = 1e-6, omega_cap_mult = 10, gamma_steps = 8, gamma_step = 1e-3, verbose = FALSE)
data |
A data frame containing columns |
p |
Autoregressive order in the mean. |
q |
Distributed-lag order for covariates |
r |
ARCH order in the variance. |
s_ord |
GARCH order in the variance. |
lambda_beta |
L1 penalty for the mean covariate coefficients. |
lambda_gamma |
L1 penalty for the variance covariate coefficients. |
maxit |
Maximum number of outer block-coordinate iterations. |
tol |
Absolute tolerance on the QML objective for convergence. |
standardize_X |
Center and scale covariates before fitting. |
use_x_in_variance |
Include the lagged-X block in the variance equation. |
phi_cap |
Upper bound on |
omega_min |
Lower bound on subject-specific baseline variance. |
omega_cap_mult |
Multiplier on |
gamma_steps |
Inner proximal-gradient steps for |
gamma_step |
Step size for the proximal-gradient update of |
verbose |
Logical; print per-iteration diagnostics. |
An object of class "lmvt": a list with elements
alpha, theta, beta, omega, a, b, gamma, ids, xcols, x_center,
x_scale, orders, penalties, call, converged, iters, mean_times,
var_times, iter_times.
Tibshirani R. (1996). "Regression Shrinkage and Selection Via the Lasso." Journal of the Royal Statistical Society: Series B, 58(1), 267–288. doi:10.1111/j.2517-6161.1996.tb02080.x
Bollerslev T. (1986). "Generalized Autoregressive Conditional Heteroskedasticity." Journal of Econometrics, 31(3), 307–327. doi:10.1016/0304-4076(86)90063-1
Medeiros M. C. and Mendes E. F. (2016). "L1-Regularization of High-Dimensional Time-Series Models with Non-Gaussian and Heteroskedastic Errors." Journal of Econometrics, 191(1), 255–271. doi:10.1016/j.jeconom.2015.10.011
predict.lmvt, summary.lmvt, simulate_scenario
set.seed(1) sim <- simulate_scenario(scen = 1, S = 5, T = 80, d_noise = 5, noise_kind = "iid", seed = 1) df <- sim[, c("s","t","y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05) print(fit)set.seed(1) sim <- simulate_scenario(scen = 1, S = 5, T = 80, d_noise = 5, noise_kind = "iid", seed = 1) df <- sim[, c("s","t","y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05) print(fit)
lmvt objectComputes the conditional mean , conditional
standard deviation , and the exceedance-based
risk score
on a new (or
held-out) panel data frame.
## S3 method for class 'lmvt' predict(object, newdata, threshold = NULL, innov_g = TRUE, innov_t = FALSE, df_t = 6, ...)## S3 method for class 'lmvt' predict(object, newdata, threshold = NULL, innov_g = TRUE, innov_t = FALSE, df_t = 6, ...)
object |
A fitted |
newdata |
A data frame containing columns |
threshold |
Threshold |
innov_g |
Logical; return Gaussian-innovation exceedance
probability |
innov_t |
Logical; return Student-t-innovation exceedance
probability |
df_t |
Degrees of freedom for the Student-t innovation. |
... |
Unused, kept for S3 compatibility. |
A data frame with columns s, t, yhat = muhat,
muhat, sigmahat, threshold_used, and one or both
of risk_g, risk_t.
set.seed(1) sim <- simulate_scenario(scen = 2, S = 4, T = 70, d_noise = 4, noise_kind = "iid", seed = 1) df <- sim[, c("s", "t", "y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05, maxit = 8) # 1) Pooled/global threshold: one cutoff is applied to every row. pr_global <- predict(fit, df, threshold = stats::quantile(df$y, 0.90)) head(pr_global) # 2) Subject-specific thresholds: use a named vector indexed by subject ID. subject_cutoffs <- tapply(df$y, df$s, stats::quantile, probs = 0.75, na.rm = TRUE) pr_subject <- predict(fit, df, threshold = subject_cutoffs) head(pr_subject) # 3) Return both Gaussian and Student-t exceedance risk scores. pr_t <- predict(fit, df, threshold = subject_cutoffs, innov_g = TRUE, innov_t = TRUE, df_t = 8) head(pr_t[, c("s", "t", "muhat", "sigmahat", "risk_g", "risk_t")])set.seed(1) sim <- simulate_scenario(scen = 2, S = 4, T = 70, d_noise = 4, noise_kind = "iid", seed = 1) df <- sim[, c("s", "t", "y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05, maxit = 8) # 1) Pooled/global threshold: one cutoff is applied to every row. pr_global <- predict(fit, df, threshold = stats::quantile(df$y, 0.90)) head(pr_global) # 2) Subject-specific thresholds: use a named vector indexed by subject ID. subject_cutoffs <- tapply(df$y, df$s, stats::quantile, probs = 0.75, na.rm = TRUE) pr_subject <- predict(fit, df, threshold = subject_cutoffs) head(pr_subject) # 3) Return both Gaussian and Student-t exceedance risk scores. pr_t <- predict(fit, df, threshold = subject_cutoffs, innov_g = TRUE, innov_t = TRUE, df_t = 8) head(pr_t[, c("s", "t", "muhat", "sigmahat", "risk_g", "risk_t")])
Simulates a balanced panel from one of four built-in demonstration scenarios.
Returns a long-format data frame with the response y, oracle mean
and variance, the covariate block, optional regime indicator, and the oracle
exceedance probability.
simulate_scenario(scen = 1L, S = 8L, T = 240L, L = 20L, d_noise = 20L, noise_kind = c("iid", "ar1"), threshold_c = 1.0, seed = NULL, floor_sigma2 = 1e-10)simulate_scenario(scen = 1L, S = 8L, T = 240L, L = 20L, d_noise = 20L, noise_kind = c("iid", "ar1"), threshold_c = 1.0, seed = NULL, floor_sigma2 = 1e-10)
scen |
Integer 1:4 selecting one of the four scenarios. |
S |
Number of subjects. |
T |
Number of post-burn-in time points per subject. |
L |
Mean run length for the piecewise regime in Scenario 4. |
d_noise |
Number of nuisance covariates with zero true effect. |
noise_kind |
Either |
threshold_c |
Threshold |
seed |
Random seed. |
floor_sigma2 |
Lower clamp on simulated variance. |
A data frame with columns s, t, y, oracle
mu and sigma, covariate columns, optional Xbin,
and the oracle exceedance probability pi_true. Generating
parameters are stored in attr(., "params").
Tibshirani R. (1996). "Regression Shrinkage and Selection Via the Lasso." Journal of the Royal Statistical Society: Series B, 58(1), 267–288. doi:10.1111/j.2517-6161.1996.tb02080.x
Bollerslev T. (1986). "Generalized Autoregressive Conditional Heteroskedasticity." Journal of Econometrics, 31(3), 307–327. doi:10.1016/0304-4076(86)90063-1
Medeiros M. C. and Mendes E. F. (2016). "L1-Regularization of High-Dimensional Time-Series Models with Non-Gaussian and Heteroskedastic Errors." Journal of Econometrics, 191(1), 255–271. doi:10.1016/j.jeconom.2015.10.011
set.seed(7) sim <- simulate_scenario(scen = 2, S = 4, T = 50, d_noise = 3, noise_kind = "iid", seed = 7) head(sim)set.seed(7) sim <- simulate_scenario(scen = 2, S = 4, T = 50, d_noise = 3, noise_kind = "iid", seed = 7) head(sim)
lmvt objectProduces model-level diagnostics and a coefficient summary table for a
fitted penalized panel ARX-GARCHX model. The table includes
subject-specific mean intercepts, autoregressive coefficients, mean
covariate coefficients, subject-specific variance baselines, ARCH/GARCH
coefficients, and variance covariate coefficients. Because lmvt()
fits a penalized quasi-likelihood model, the table reports estimates and
variable-selection indicators rather than classical standard errors or
p-values.
## S3 method for class 'lmvt' summary(object, tol = 1e-8, include_zero = TRUE, sort_by = c("block", "abs_estimate", "none"), top = NULL, ...)## S3 method for class 'lmvt' summary(object, tol = 1e-8, include_zero = TRUE, sort_by = c("block", "abs_estimate", "none"), top = NULL, ...)
object |
A fitted |
tol |
Absolute value used to flag a coefficient as selected/nonzero. |
include_zero |
Logical; if |
sort_by |
Sorting rule for the coefficient table. Use |
top |
Optional positive integer limiting the returned coefficient table
to the first |
... |
Unused, kept for S3 compatibility. |
summary.lmvt() returns an object of class "summary.lmvt", a
list containing:
model: model-level diagnostics;
nonzero: counts of selected/nonzero coefficients by parameter block;
table: the coefficient summary table after filtering/sorting;
full_table: the complete coefficient table before filtering.
set.seed(12) sim <- simulate_scenario(scen = 1, S = 4, T = 60, d_noise = 4, noise_kind = "iid", seed = 12) df <- sim[, c("s", "t", "y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05, maxit = 8) # Printed summary summary(fit) # Programmatic coefficient table sm <- summary(fit, include_zero = FALSE, sort_by = "abs_estimate") sm$tableset.seed(12) sim <- simulate_scenario(scen = 1, S = 4, T = 60, d_noise = 4, noise_kind = "iid", seed = 12) df <- sim[, c("s", "t", "y", grep("^X|^Noise|^Xbin", names(sim), value = TRUE))] fit <- lmvt(df, p = 1, q = 0, r = 1, s_ord = 1, lambda_beta = 0.05, lambda_gamma = 0.05, maxit = 8) # Printed summary summary(fit) # Programmatic coefficient table sm <- summary(fit, include_zero = FALSE, sort_by = "abs_estimate") sm$table