| Title: | Semiparametric Spatiotemporal Model with Mixed Frequencies |
|---|---|
| Description: | Fits a semiparametric spatiotemporal model for data with mixed frequencies, specifically where the response variable is observed at a lower frequency than some covariates. The estimation uses an iterative backfitting algorithm that combines a non-parametric smoothing spline for high-frequency data, parametric estimation for low-frequency and spatial neighborhood effects, and an autoregressive error structure. Methodology based on Malabanan, Lansangan, and Barrios (2022) <https://scienggj.org/2022/SciEnggJ%202022-vol15-no02-p90-107-Malabanan%20et%20al.pdf>. |
| Authors: | Jezzu Morrisen Quimosing [aut, cre, cph] (ORCID: <https://orcid.org/0009-0001-4302-7946>) |
| Maintainer: | Jezzu Morrisen Quimosing <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-06-04 07:31:52 UTC |
| Source: | https://github.com/jzeuzs/semiparmf |
Plots the Mean Squared Prediction Error (MSPE) across iterations.
## S3 method for class 'semiparMF' plot(x, ...)## S3 method for class 'semiparMF' plot(x, ...)
x |
An object of class |
... |
Additional graphical parameters. |
No return value, called for side effects (plotting).
Generates predictions for new data. Reference: "Predicted values are calculated by simply adding up the scores... and the linear combination".
## S3 method for class 'semiparMF' predict(object, new_high_freq, new_z, new_w, ...)## S3 method for class 'semiparMF' predict(object, new_high_freq, new_z, new_w, ...)
object |
An object of class |
new_high_freq |
Numeric array (N x T_new x K) for the high-frequency covariate. |
new_z |
Numeric matrix (N x T_new) for the parametric covariate. |
new_w |
Numeric matrix (N x T_new) for the neighborhood covariate. |
... |
Additional arguments. |
A matrix (N x T_new) of predicted values.
Print Method for SemiparMF
## S3 method for class 'semiparMF' print(x, ...)## S3 method for class 'semiparMF' print(x, ...)
x |
An object of class |
... |
Additional arguments. |
The input object x is returned invisibly.
Print Summary for SemiparMF
## S3 method for class 'summary.semiparMF' print(x, ...)## S3 method for class 'summary.semiparMF' print(x, ...)
x |
An object of class |
... |
Additional arguments. |
The input object x is returned invisibly.
Fits a spatiotemporal model where the response variable is observed at a lower frequency (e.g., quarterly) than a non-parametric covariate (e.g., monthly). The model combines a non-parametric component for the high-frequency predictor, parametric components for low-frequency predictors and spatial neighborhood effects, and an autoregressive error structure.
semiparMF( formula, data_sf, high_freq_data, time_col, id_col, w_matrix = NULL, ... )semiparMF( formula, data_sf, high_freq_data, time_col, id_col, w_matrix = NULL, ... )
formula |
A |
data_sf |
An |
high_freq_data |
A numeric array of dimensions (N x T x K), where:
|
time_col |
Character string. The name of the column in |
id_col |
Character string. The name of the column in |
w_matrix |
Optional numeric matrix (N x T). A pre-calculated spatial weight or neighborhood variable.
If |
... |
Additional arguments passed to the internal backfitting function (e.g., |
An object of class semiparMF containing:
coefficients |
A list of estimated parameters: |
nonparam |
A list containing the fitted smoothing spline and the aggregated non-parametric component |
residuals |
Matrix (N x T) of model residuals. |
fitted.values |
Matrix (N x T) of the fitted values (structural part only). |
dims |
Dimensions of the data (N, T). |
meta |
Metadata containing location IDs and time indices. |
history |
Convergence history (MSPE per iteration). |
call |
The function call. |
Malabanan, V. A., Lansangan, J. R. G., & Barrios, E. B. (2022). Semiparametric Spatiotemporal Model with Mixed Frequencies: With Application in Crop Forecasting. Science & Engineering Journal, 15(2), 90-107.
# Simulate data using the package's included simulation function sim <- simulate_semipar_data(n_side = 4, t_len = 20, k = 3, rho_error = 0.5) # Fit the model fit <- semiparMF( formula = Y ~ Z, data_sf = sim$data, high_freq_data = sim$X_high, time_col = "time_id", id_col = "location_id" ) # Inspect results summary(fit)# Simulate data using the package's included simulation function sim <- simulate_semipar_data(n_side = 4, t_len = 20, k = 3, rho_error = 0.5) # Fit the model fit <- semiparMF( formula = Y ~ Z, data_sf = sim$data, high_freq_data = sim$X_high, time_col = "time_id", id_col = "location_id" ) # Inspect results summary(fit)
Generates a synthetic dataset for testing the SemiparMF model. Structure follows Equation (7) in Malabanan et al. (2022).
simulate_semipar_data( n_side = 6, t_len = 50, k = 3, rho_error = 0.5, beta = 0.5, gamma = 0.3 )simulate_semipar_data( n_side = 6, t_len = 50, k = 3, rho_error = 0.5, beta = 0.5, gamma = 0.3 )
n_side |
Integer. Grid side length. Total locations N = n_side^2. |
t_len |
Integer. Length of the time series (T). |
k |
Integer. Frequency ratio (e.g., 3 months per quarter). |
rho_error |
Numeric. Autocorrelation coefficient for the error term (default 0.5). |
beta |
True coefficient for covariate Z (default 0.5). |
gamma |
True coefficient for neighborhood variable W (default 0.3). |
A list containing:
data |
An |
X_high |
An array (N x T x K) of high-frequency covariates. |
true_params |
List of true parameters used for generation. |
# Generate a small dataset sim <- simulate_semipar_data(n_side = 4, t_len = 10, k = 3) # Check dimensions dim(sim$data) # 160 x 5 (16 locations * 10 time points) dim(sim$X_high) # 16 x 10 x 3# Generate a small dataset sim <- simulate_semipar_data(n_side = 4, t_len = 10, k = 3) # Check dimensions dim(sim$data) # 160 x 5 (16 locations * 10 time points) dim(sim$X_high) # 16 x 10 x 3
Summary Method for SemiparMF
## S3 method for class 'semiparMF' summary(object, ...)## S3 method for class 'semiparMF' summary(object, ...)
object |
An object of class |
... |
Additional arguments. |
A list of class summary.semiparMF containing:
coefficients |
A list of estimated parameters (beta, gamma, rho). |
last_mspe |
The Mean Squared Prediction Error from the final iteration. |
residuals_summary |
Summary statistics of the residuals. |
iterations |
Total number of iterations performed. |
call |
The function call. |