| Title: | Distributed Sampling for Dynamic Regression Models |
|---|---|
| Description: | A toolbox for distributed dynamic regression modeling, parallel estimation, multiple distributed sampling algorithms (Metropolis-Hastings, block bootstrap, adaptive, hypergeometric), sparse matrix optimization, model visualization, prediction and performance evaluation. The philosophy of the package is described in Guo (2025) <doi:10.1038/s41598-025-93333-6>. |
| Authors: | Guangbao Guo [aut, cre] (ORCID: <https://orcid.org/0000-0002-4115-6218>) |
| Maintainer: | Guangbao Guo <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 0.1.3 |
| Built: | 2026-07-10 21:46:29 UTC |
| Source: | https://github.com/cran/DSDRM |
Compute adaptive optimal block length using autocorrelation and coefficient of variation. Designed for time-varying distributed regression models.
adaptive_block_len(Y_block, theta_block, L0 = 10)adaptive_block_len(Y_block, theta_block, L0 = 10)
Y_block |
Response variable in a single block. |
theta_block |
Parameter sequence in the block. |
L0 |
Base block length. |
A list containing optimal block length, autocorrelation, and coefficient of variation.
Yb <- rnorm(50) tb <- rnorm(50) res <- adaptive_block_len(Yb, tb, L0 = 10) resYb <- rnorm(50) tb <- rnorm(50) res <- adaptive_block_len(Yb, tb, L0 = 10) res
Splits a full dataset into multiple contiguous blocks for distributed estimation.
block_data_split(Y, X, n_blocks)block_data_split(Y, X, n_blocks)
Y |
Response vector |
X |
Design matrix |
n_blocks |
Number of blocks |
List of blocks containing Y and X
Y <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) blks <- block_data_split(Y, X, n_blocks = 4) length(blks)Y <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) blks <- block_data_split(Y, X, n_blocks = 4) length(blks)
Computes key evaluation metrics for parameter estimation and model selection performance.
calc_metrics(theta_est, theta_true, Y_est, Y_true, gamma_est, gamma_true)calc_metrics(theta_est, theta_true, Y_est, Y_true, gamma_est, gamma_true)
theta_est |
Estimated parameter vector. |
theta_true |
True parameter vector. |
Y_est |
Fitted response values. |
Y_true |
True response values. |
gamma_est |
Estimated model indicator vector. |
gamma_true |
True model indicator vector. |
Data frame containing MSE, MAE, R2, and model accuracy (ACC).
te <- c(0.8, 1.1, 0.05) tt <- c(1, 1, 0) ye <- rnorm(50) yt <- rnorm(50) ge <- c(1,1,0) gt <- c(1,1,0) calc_metrics(te, tt, ye, yt, ge, gt)te <- c(0.8, 1.1, 0.05) tt <- c(1, 1, 0) ye <- rnorm(50) yt <- rnorm(50) ge <- c(1,1,0) gt <- c(1,1,0) calc_metrics(te, tt, ye, yt, ge, gt)
High-performance parallel estimation for large-scale distributed data.
dist_parallel_estimate(blocks, gamma, cores = 2)dist_parallel_estimate(blocks, gamma, cores = 2)
blocks |
List of data blocks |
gamma |
Model indicator |
cores |
CPU cores (default 2, limited to 2 for CRAN compatibility) |
List of estimates and runtime
sim <- dsdrm_generate_data(T_total = 200, K = 2, p = 5, W_beta = 0.2) gam <- c(1,1,0,0,0) res <- dist_parallel_estimate(sim$data_block, gamma = gam, cores = 2) str(res)sim <- dsdrm_generate_data(T_total = 200, K = 2, p = 5, W_beta = 0.2) gam <- c(1,1,0,0,0) res <- dist_parallel_estimate(sim$data_block, gamma = gam, cores = 2) str(res)
Implements the distributed quasi-Newton optimization algorithm for parameter estimation in time-varying distributed regression models.
dist_qn_algorithm( data_block, gamma, omega, lambda = 0.2, eps = 1e-06, max_iter = 1000, V = 0.5 )dist_qn_algorithm( data_block, gamma, omega, lambda = 0.2, eps = 1e-06, max_iter = 1000, V = 0.5 )
data_block |
List of distributed data blocks. |
gamma |
Binary model indicator vector. |
omega |
Block weight vector. |
lambda |
L2 regularization parameter. |
eps |
Convergence tolerance. |
max_iter |
Maximum number of iterations. |
V |
Observation noise variance. |
List containing estimated parameters and iteration number.
sim <- dsdrm_generate_data(T_total = 300, K = 3, p = 4, W_beta = 0.1) gam <- c(1,1,0,0) w <- rep(1/3, 3) fit <- dist_qn_algorithm(sim$data_block, gam, w, max_iter = 50) fit$theta_estsim <- dsdrm_generate_data(T_total = 300, K = 3, p = 4, W_beta = 0.1) gam <- c(1,1,0,0) w <- rep(1/3, 3) fit <- dist_qn_algorithm(sim$data_block, gam, w, max_iter = 50) fit$theta_est
Runs the distributed quasi-Newton algorithm and records total execution time.
dist_qn_with_time( data_block, gamma, omega, lambda = 0.2, eps = 1e-06, max_iter = 1000 )dist_qn_with_time( data_block, gamma, omega, lambda = 0.2, eps = 1e-06, max_iter = 1000 )
data_block |
List of distributed data blocks. |
gamma |
Binary model indicator vector. |
omega |
Block weight vector. |
lambda |
L2 regularization parameter. |
eps |
Convergence tolerance. |
max_iter |
Maximum number of iterations. |
List containing parameter estimates, iteration number, and computation time (seconds).
sim <- dsdrm_generate_data(T_total = 200, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.4, 0.6) res <- dist_qn_with_time(sim$data_block, gam, w, max_iter = 30) res$timesim <- dsdrm_generate_data(T_total = 200, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.4, 0.6) res <- dist_qn_with_time(sim$data_block, gam, w, max_iter = 30) res$time
Fits the Distributed Smooth Dynamic Regression Model (DSDRM).
dsdrm_fit(Y, X, n_blocks, gamma, lambda = 0.01)dsdrm_fit(Y, X, n_blocks, gamma, lambda = 0.01)
Y |
Response vector |
X |
Design matrix |
n_blocks |
Number of distributed blocks |
gamma |
Model indicator vector |
lambda |
Regularization parameter |
Fitted DSDRM model object
Y <- rnorm(300) X <- matrix(rnorm(300*4), 300, 4) gam <- c(1,1,0,0) mod <- dsdrm_fit(Y, X, n_blocks = 3, gamma = gam, lambda = 0.01) mod$coefficientsY <- rnorm(300) X <- matrix(rnorm(300*4), 300, 4) gam <- c(1,1,0,0) mod <- dsdrm_fit(Y, X, n_blocks = 3, gamma = gam, lambda = 0.01) mod$coefficients
Generates simulated time series data for distributed dynamic regression models with time-varying coefficients, temporal drift, and distributed block structure.
dsdrm_generate_data(T_total, K, p, W_beta)dsdrm_generate_data(T_total, K, p, W_beta)
T_total |
Total length of the time series. |
K |
Number of data blocks for distributed computing. |
p |
Dimension of covariates. |
W_beta |
Variance of coefficient state noise. |
A list containing:
data_block |
List of data blocks with Y, X, and block length Tk. |
T_total |
Total time length. |
K |
Number of blocks. |
p |
Covariate dimension. |
true_alpha |
True time-varying intercept sequence. |
true_beta |
True time-varying coefficient matrix. |
sim_data <- dsdrm_generate_data(T_total = 200, K = 4, p = 5, W_beta = 0.2) str(sim_data$data_block[[1]])sim_data <- dsdrm_generate_data(T_total = 200, K = 4, p = 5, W_beta = 0.2) str(sim_data$data_block[[1]])
Computes all key metrics for DSDRM estimation.
dsdrm_metrics(y_true, y_pred, theta_est, theta_true, gamma_est, gamma_true)dsdrm_metrics(y_true, y_pred, theta_est, theta_true, gamma_est, gamma_true)
y_true |
True response |
y_pred |
Predicted response |
theta_est |
Estimated parameters |
theta_true |
True parameters |
gamma_est |
Estimated gamma |
gamma_true |
True gamma |
Data frame of metrics
yt <- rnorm(100) yp <- rnorm(100) te <- c(0.9, 1.05, 0.02) tt <- c(1,1,0) ge <- c(1,1,0) gt <- c(1,1,0) dsdrm_metrics(yt, yp, te, tt, ge, gt)yt <- rnorm(100) yp <- rnorm(100) te <- c(0.9, 1.05, 0.02) tt <- c(1,1,0) ge <- c(1,1,0) gt <- c(1,1,0) dsdrm_metrics(yt, yp, te, tt, ge, gt)
Generates predictions using fitted DSDRM model.
dsdrm_predict(model, X_new)dsdrm_predict(model, X_new)
model |
Fitted dsdrm_fit object |
X_new |
New design matrix |
Predicted values
Y <- rnorm(200) X <- matrix(rnorm(200*3), 200, 3) gam <- c(1,1,0) fit_mod <- dsdrm_fit(Y, X, n_blocks = 2, gamma = gam) Xnew <- matrix(rnorm(50*3), 50, 3) pred <- dsdrm_predict(fit_mod, Xnew) head(pred)Y <- rnorm(200) X <- matrix(rnorm(200*3), 200, 3) gam <- c(1,1,0) fit_mod <- dsdrm_fit(Y, X, n_blocks = 2, gamma = gam) Xnew <- matrix(rnorm(50*3), 50, 3) pred <- dsdrm_predict(fit_mod, Xnew) head(pred)
Generates parameter samples using Metropolis-Hastings within distributed framework.
dsdrm_sampling(blocks, gamma, omega, n_sample = 1000)dsdrm_sampling(blocks, gamma, omega, n_sample = 1000)
blocks |
List of data blocks |
gamma |
Model indicator |
omega |
Block weights |
n_sample |
Number of samples |
Matrix of parameter samples
sim <- dsdrm_generate_data(T_total = 150, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5, 0.5) samp_mat <- dsdrm_sampling(sim$data_block, gam, w, n_sample = 100) dim(samp_mat)sim <- dsdrm_generate_data(T_total = 150, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5, 0.5) samp_mat <- dsdrm_sampling(sim$data_block, gam, w, n_sample = 100) dim(samp_mat)
Plots time-varying coefficient estimates from DSDRM.
dynamic_coef_plot(theta_seq, main = "DSDRM Dynamic Coefficients")dynamic_coef_plot(theta_seq, main = "DSDRM Dynamic Coefficients")
theta_seq |
Sequence of coefficient estimates |
main |
Title |
No return value, called for side effect (plotting dynamic coefficient path).
theta_path <- matrix(rnorm(200*3), 200, 3) dynamic_coef_plot(theta_path, main = "Simulated Coefficients")theta_path <- matrix(rnorm(200*3), 200, 3) dynamic_coef_plot(theta_path, main = "Simulated Coefficients")
Calculates optimal normalized weights for distributed blocks based on inverse MSE (mean squared error). Higher weights are assigned to blocks with lower estimation error.
dynamic_opt_omega(mse_vec)dynamic_opt_omega(mse_vec)
mse_vec |
Vector of MSE values from each block. |
Normalized optimal weight vector summing to 1.
mse <- c(0.2, 0.5, 0.3) w <- dynamic_opt_omega(mse) sum(w)mse <- c(0.2, 0.5, 0.3) w <- dynamic_opt_omega(mse) sum(w)
Checks whether the model indicator gamma has converged by comparing the L1 distance between old and new gamma vectors.
gamma_converge(gamma_old, gamma_new, eps_gamma = 0.001)gamma_converge(gamma_old, gamma_new, eps_gamma = 0.001)
gamma_old |
Previous model indicator vector. |
gamma_new |
Updated model indicator vector. |
eps_gamma |
Convergence threshold. |
Logical value (TRUE = converged, FALSE = not converged).
g1 <- c(1,1,0,0) g2 <- c(1,1,0,0) gamma_converge(g1, g2)g1 <- c(1,1,0,0) g2 <- c(1,1,0,0) gamma_converge(g1, g2)
Combines model selection results from all distributed blocks using weighted averaging. Constructs the final optimal model indicator gamma by weighted voting.
gamma_fusion(gamma_list, omega)gamma_fusion(gamma_list, omega)
gamma_list |
List of binary model indicators from each block. |
omega |
Block weight vector. |
Fused optimal binary model indicator vector.
glist <- list(c(1,1,0), c(1,0,0)) w <- c(0.6, 0.4) gamma_fusion(glist, w)glist <- list(c(1,1,0), c(1,0,0)) w <- c(0.6, 0.4) gamma_fusion(glist, w)
Computes the global weighted Fisher information matrix across all distributed blocks for active covariates selected by gamma.
global_info_mat(data_block, gamma, omega, V = 0.5)global_info_mat(data_block, gamma, omega, V = 0.5)
data_block |
List of distributed data blocks. |
gamma |
Binary model indicator vector. |
omega |
Block weight vector. |
V |
Observation noise variance. |
Global information matrix of dimension p_eff x p_eff.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5, 0.5) Gmat <- global_info_mat(sim$data_block, gam, w) Gmatsim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5, 0.5) Gmat <- global_info_mat(sim$data_block, gam, w) Gmat
Implements a global Markov Chain Monte Carlo (MCMC) estimator used as a benchmark for comparison with the proposed DSDRM method.
global_mcmc_estimator(Y, X, iter = 1000)global_mcmc_estimator(Y, X, iter = 1000)
Y |
Response vector. |
X |
Design matrix. |
iter |
Number of MCMC iterations. |
Combined vector of estimated intercept and coefficients.
Y <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) est_mcmc <- global_mcmc_estimator(Y, X, iter = 200) est_mcmcY <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) est_mcmc <- global_mcmc_estimator(Y, X, iter = 200) est_mcmc
Runs the global MCMC benchmark and records execution time.
global_mcmc_with_time(Y, X, iter = 1000)global_mcmc_with_time(Y, X, iter = 1000)
Y |
Response vector. |
X |
Design matrix. |
iter |
Number of MCMC iterations. |
List containing estimated parameters and computation time (seconds).
Y <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) out <- global_mcmc_with_time(Y, X, iter = 300) out$timeY <- rnorm(100) X <- matrix(rnorm(100*3), 100, 3) out <- global_mcmc_with_time(Y, X, iter = 300) out$time
Computes the global posterior probability of model indicator gamma using geometric averaging over all distributed blocks.
global_posterior_gamma(data_block, gamma, theta, omega, V = 0.5)global_posterior_gamma(data_block, gamma, theta, omega, V = 0.5)
data_block |
List of distributed data blocks. |
gamma |
Binary model selection vector. |
theta |
Parameter vector (intercept + coefficients). |
omega |
Block weight vector. |
V |
Observation noise variance. |
Global posterior probability value.
sim <- dsdrm_generate_data(T_total = 120, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1.2, 0.1) w <- c(0.5,0.5) pp <- global_posterior_gamma(sim$data_block, gam, th, w) ppsim <- dsdrm_generate_data(T_total = 120, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1.2, 0.1) w <- c(0.5,0.5) pp <- global_posterior_gamma(sim$data_block, gam, th, w) pp
Computes the global weighted quasi log-likelihood across all distributed blocks using block-specific optimal weights omega.
global_quasi_ll(data_block, theta, gamma, omega, V = 0.5)global_quasi_ll(data_block, theta, gamma, omega, V = 0.5)
data_block |
List of distributed data blocks. |
theta |
Parameter vector. |
gamma |
Binary model indicator vector. |
omega |
Block weight vector. |
V |
Observation noise variance. |
Global weighted quasi log-likelihood value.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1.1, 0.05) w <- c(0.5, 0.5) ll <- global_quasi_ll(sim$data_block, th, gam, w) llsim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1.1, 0.05) w <- c(0.5, 0.5) ll <- global_quasi_ll(sim$data_block, th, gam, w) ll
Computes the global score vector across all distributed blocks for time-varying distributed regression models.
global_score(data_block, theta, gamma, V = 0.5)global_score(data_block, theta, gamma, V = 0.5)
data_block |
List of distributed data blocks. |
theta |
Parameter vector (intercept + coefficients). |
gamma |
Binary model indicator vector. |
V |
Observation noise variance. |
Global score vector.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1, 0) sc <- global_score(sim$data_block, th, gam) scsim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1, 0) sc <- global_score(sim$data_block, th, gam) sc
Initialize Binary Model Indicator Vector Creates a binary (0/1) indicator vector for model selection. Sets 1 for active (true) covariates and 0 for irrelevant covariates.
init_gamma(p, active_idx)init_gamma(p, active_idx)
p |
Total dimension of covariates. |
active_idx |
Indices of active (true) variables. |
A binary 0-1 vector of length p.
g <- init_gamma(p = 5, active_idx = c(1,2)) gg <- init_gamma(p = 5, active_idx = c(1,2)) g
Computes the local marginal likelihood for a single block under model selection indicator gamma.
local_marginal_likelihood(Y, X, gamma, theta, V = 0.5)local_marginal_likelihood(Y, X, gamma, theta, V = 0.5)
Y |
Response vector. |
X |
Design matrix. |
gamma |
Binary model indicator vector. |
theta |
Parameter vector (intercept + coefficients). |
V |
Observation noise variance. |
Scalar value of the marginal likelihood.
Y <- rnorm(50) X <- matrix(rnorm(50*3),50,3) gam <- c(1,1,0) th <- c(1, 1.2, 0.1) ml <- local_marginal_likelihood(Y, X, gam, th) mlY <- rnorm(50) X <- matrix(rnorm(50*3),50,3) gam <- c(1,1,0) th <- c(1, 1.2, 0.1) ml <- local_marginal_likelihood(Y, X, gam, th) ml
Computes the local quasi log-likelihood for a single distributed block based on the selected model (gamma) and parameters (theta).
local_quasi_ll(Y, X, gamma, theta, V = 0.5)local_quasi_ll(Y, X, gamma, theta, V = 0.5)
Y |
Response vector. |
X |
Design matrix. |
gamma |
Binary model indicator vector. |
theta |
Parameter vector (intercept + active coefficients). |
V |
Observation noise variance. |
Scalar quasi log-likelihood value.
Y <- rnorm(50) X <- matrix(rnorm(50*3), 50, 3) gam <- c(1,1,0) th <- c(1, 1.1, 0) ll <- local_quasi_ll(Y, X, gam, th) llY <- rnorm(50) X <- matrix(rnorm(50*3), 50, 3) gam <- c(1,1,0) th <- c(1, 1.1, 0) ll <- local_quasi_ll(Y, X, gam, th) ll
Performs a Metropolis-Hastings step to update the binary model indicator gamma. Used for dynamic model selection in distributed time-varying regression.
mh_gamma_update(gamma_curr, gamma_prop, data_block, theta, omega, V = 0.5)mh_gamma_update(gamma_curr, gamma_prop, data_block, theta, omega, V = 0.5)
gamma_curr |
Current model indicator vector. |
gamma_prop |
Proposed model indicator vector. |
data_block |
List of distributed data blocks. |
theta |
Parameter vector. |
omega |
Block weight vector. |
V |
Observation noise variance. |
List containing updated model indicator and acceptance rate.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) g_curr <- c(1,1,0) g_prop <- c(1,0,0) th <- c(1, 1, 0) w <- c(0.5,0.5) out <- mh_gamma_update(g_curr, g_prop, sim$data_block, th, w) out$gammasim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) g_curr <- c(1,1,0) g_prop <- c(1,0,0) th <- c(1, 1, 0) w <- c(0.5,0.5) out <- mh_gamma_update(g_curr, g_prop, sim$data_block, th, w) out$gamma
Internal helper function for parallel distributed estimation. Computes closed-form OLS estimates for each block given selected model gamma.
parallel_estimate(block, gamma, V = 0.5)parallel_estimate(block, gamma, V = 0.5)
block |
Single data block containing Y and X. |
gamma |
Binary model indicator vector. |
V |
Observation noise variance (not used in closed-form). |
Parameter estimates for the current block.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) blk <- sim$data_block[[1]] gam <- c(1,1,0) est <- parallel_estimate(blk, gam) estsim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) blk <- sim$data_block[[1]] gam <- c(1,1,0) est <- parallel_estimate(blk, gam) est
Computes the L2 penalized global quasi log-likelihood for regularized estimation.
penalized_quasi_ll(data_block, theta, gamma, omega, lambda = 0.01, V = 0.5)penalized_quasi_ll(data_block, theta, gamma, omega, lambda = 0.01, V = 0.5)
data_block |
List of distributed data blocks. |
theta |
Parameter vector. |
gamma |
Binary model indicator vector. |
omega |
Block weight vector. |
lambda |
L2 regularization parameter. |
V |
Observation noise variance. |
Penalized quasi log-likelihood value.
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1, 0) w <- c(0.5,0.5) pll <- penalized_quasi_ll(sim$data_block, th, gam, w, lambda = 0.01) pllsim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) th <- c(1, 1, 0) w <- c(0.5,0.5) pll <- penalized_quasi_ll(sim$data_block, th, gam, w, lambda = 0.01) pll
Performs comprehensive batch simulations to compare estimation performance of DSDRM, Global MCMC, and Static Distributed methods under various settings.
run_batch_simulation( T_list = c(100, 500, 1000), K_list = c(2, 5, 10), W_list = c(0.1, 0.3, 0.5), repeat_num = 5, seed = NULL )run_batch_simulation( T_list = c(100, 500, 1000), K_list = c(2, 5, 10), W_list = c(0.1, 0.3, 0.5), repeat_num = 5, seed = NULL )
T_list |
List of total time series lengths. |
K_list |
List of numbers of distributed blocks. |
W_list |
List of coefficient state noise variances. |
repeat_num |
Number of independent replications for each setting. |
seed |
Optional seed for reproducibility. If NULL (default), no seed is set. |
A data frame containing performance metrics (MSE, MAE, R2, ACC) for all methods under all simulation scenarios.
sim_out <- run_batch_simulation(T_list = c(150), K_list = c(2), W_list = c(0.1), repeat_num = 1) head(sim_out)sim_out <- run_batch_simulation(T_list = c(150), K_list = c(2), W_list = c(0.1), repeat_num = 1) head(sim_out)
Conducts batch experiments for performance comparison among DSDRM, MCMC, Static Distributed, and Parallel DSDRM methods, with computation time recorded.
run_batch_simulation_with_time( T_list = c(1000, 5000, 10000), K_list = c(2, 5, 10), W_list = c(0.1, 0.3, 0.5), cores = 2, repeat_num = 3, seed = NULL )run_batch_simulation_with_time( T_list = c(1000, 5000, 10000), K_list = c(2, 5, 10), W_list = c(0.1, 0.3, 0.5), cores = 2, repeat_num = 3, seed = NULL )
T_list |
Vector of time series lengths |
K_list |
Vector of number of distributed blocks |
W_list |
Vector of state noise variances |
cores |
Number of CPU cores for parallel computing |
repeat_num |
Number of independent replications |
seed |
Optional seed for reproducibility. If NULL (default), no seed is set. |
Data frame containing simulation settings, method name, runtime, and evaluation metrics (MSE, MAE, R2, ACC)
sim_res <- run_batch_simulation_with_time( T_list = c(200), K_list = c(2), W_list = c(0.1), repeat_num = 1 ) head(sim_res)sim_res <- run_batch_simulation_with_time( T_list = c(200), K_list = c(2), W_list = c(0.1), repeat_num = 1 ) head(sim_res)
Accelerates information matrix and score computation using sparse matrices.
sparse_matrix_optim(blocks, gamma, omega)sparse_matrix_optim(blocks, gamma, omega)
blocks |
Data blocks |
gamma |
Model indicator |
omega |
Block weights |
Efficient information matrix
if(requireNamespace("Matrix", quietly = TRUE)){ sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5,0.5) Gsp <- sparse_matrix_optim(sim$data_block, gam, w) Gsp }if(requireNamespace("Matrix", quietly = TRUE)){ sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) gam <- c(1,1,0) w <- c(0.5,0.5) Gsp <- sparse_matrix_optim(sim$data_block, gam, w) Gsp }
Runs the static distributed benchmark estimator and records execution time.
static_dist_with_time(data_block)static_dist_with_time(data_block)
data_block |
List of distributed data blocks. |
List containing estimated parameters and computation time (seconds).
sim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) out <- static_dist_with_time(sim$data_block) out$timesim <- dsdrm_generate_data(T_total = 100, K = 2, p = 3, W_beta = 0.1) out <- static_dist_with_time(sim$data_block) out$time
Implements a static distributed regression estimator as a benchmark. Estimates parameters locally on each block and averages results.
static_distributed_estimator(data_block)static_distributed_estimator(data_block)
data_block |
List of distributed data blocks. |
Averaged parameter vector across all blocks.
sim <- dsdrm_generate_data(T_total = 100, K = 3, p = 3, W_beta = 0.1) est_static <- static_distributed_estimator(sim$data_block) est_staticsim <- dsdrm_generate_data(T_total = 100, K = 3, p = 3, W_beta = 0.1) est_static <- static_distributed_estimator(sim$data_block) est_static