| Title: | Estimate Functional and Stochastic Parameters of Linear Models with Correlated Residuals and Missing Data |
|---|---|
| Description: | Implements the Generalized Method of Wavelet Moments with Exogenous Inputs estimator (GMWMX) presented in Voirol, L., Xu, H., Zhang, Y., Insolia, L., Molinari, R. and Guerrier, S. (2024) <doi:10.48550/arXiv.2409.05160>. The GMWMX estimator allows to estimate functional and stochastic parameters of linear models with correlated residuals in presence of missing data. The 'gmwmx2' package provides functions to load and plot Global Navigation Satellite System (GNSS) data from the Nevada Geodetic Laboratory and functions to estimate linear model model with correlated residuals in presence of missing data. |
| Authors: | Lionel Voirol [aut, cre] (ORCID: <https://orcid.org/0000-0003-1696-1407>), Haotian Xu [aut] (ORCID: <https://orcid.org/0000-0001-8336-4536>), Yuming Zhang [aut] (ORCID: <https://orcid.org/0000-0003-2293-9601>), Luca Insolia [aut] (ORCID: <https://orcid.org/0000-0003-4169-5446>), Roberto Molinari [aut] (ORCID: <https://orcid.org/0000-0001-8766-6902>), Stéphane Guerrier [aut] (ORCID: <https://orcid.org/0000-0003-0002-8794>) |
| Maintainer: | Lionel Voirol <[email protected]> |
| License: | AGPL-3 |
| Version: | 0.0.5 |
| Built: | 2026-05-20 09:53:34 UTC |
| Source: | https://github.com/smac-group/gmwmx2 |
sum_model objectAdd to a sum_model object
## S3 method for class 'sum_model' e1 + e2## S3 method for class 'sum_model' e1 + e2
e1 |
Left operand. |
e2 |
Right operand. |
A sum_model.
m1 <- wn(sigma2 = 1) m2 <- ar1(phi = 0.8, sigma2 = 0.5) m3 <- pl(kappa = 0.3, sigma2 = 2) model <- (m1 + m2) + m3m1 <- wn(sigma2 = 1) m2 <- ar1(phi = 0.8, sigma2 = 0.5) m3 <- pl(kappa = 0.3, sigma2 = 2) model <- (m1 + m2) + m3
time_series_model objectCombines time_series_model and/or sum_model into a sum_model.
## S3 method for class 'time_series_model' e1 + e2## S3 method for class 'time_series_model' e1 + e2
e1 |
Left operand. |
e2 |
Right operand. |
A sum_model.
m1 <- wn(sigma2 = 1) m2 <- ar1(phi = 0.8, sigma2 = 0.5) model <- m1 + m2 modelm1 <- wn(sigma2 = 1) m2 <- ar1(phi = 0.8, sigma2 = 0.5) model <- m1 + m2 model
time_series_model)Constructs a time_series_model for a stationary AR(1) process with parameter
phi and innovation variance sigma2.
The model is
.
The autocovariance is
.
ar1(phi = NULL, sigma2 = NULL)ar1(phi = NULL, sigma2 = NULL)
phi |
AR(1) coefficient in (-1, 1). |
sigma2 |
Innovation variance (> 0). |
A time_series_model object.
mod <- ar1(phi = 0.8, sigma2 = 1) modmod <- ar1(phi = 0.8, sigma2 = 1) mod
Estimated northward and eastward velocity and standard deviation for a subset of 1202 GNSS station with more than 10 years of daily data.
df_estimated_velocities_gmwmxdf_estimated_velocities_gmwmx
A data frame with 1202 rows and 12 variables:
Name of the GNSS station.
Estimated northward velocity trend (in meters per day).
Standard deviation of the estimated northward velocity trend.
Estimated eastward velocity trend (in meters per day).
Standard deviation of the estimated eastward velocity trend.
Length of the signal (in days).
Scaled estimated northward velocity trend (multiplying by 365.25 for yearly values).
Scaled standard deviation of the estimated northward velocity trend.
Scaled estimated eastward velocity trend (multiplying by 365.25 for yearly values).
Scaled standard deviation of the estimated eastward velocity trend.
Latitude of the GNSS station.
Longitude of the GNSS station.
Download all stations name and location from the Nevada Geodetic Laboratory
download_all_stations_ngl(verbose = FALSE)download_all_stations_ngl(verbose = FALSE)
verbose |
A |
Return a data.frame with all stations name, latitude, longitude and heights.
df_all_stations <- download_all_stations_ngl() head(df_all_stations)df_all_stations <- download_all_stations_ngl() head(df_all_stations)
Download estimated velocities using the MIDAS estimator provided by the Nevada Geodetic Laboratory for all stations.
download_estimated_velocities_ngl(verbose = FALSE)download_estimated_velocities_ngl(verbose = FALSE)
verbose |
A |
Return a data.frame with all stations name, information about the time series for each station, estimated velocities and estimated standard deviation of the estimated velocities.
df_estimated_velocities <- download_estimated_velocities_ngl() head(df_estimated_velocities)df_estimated_velocities <- download_estimated_velocities_ngl() head(df_estimated_velocities)
Download GNSS position time series and steps reference from the Nevada Geodetic Laboratory with IGS14 or IGS20 reference frame.
download_station_ngl(station_name, verbose = FALSE, reference_frame = "IGS20")download_station_ngl(station_name, verbose = FALSE, reference_frame = "IGS20")
station_name |
A |
verbose |
A |
reference_frame |
A |
A list of class gnss_ts_ngl that contains three data.frame: The data.frame df_position which contains the position time series extracted from the .tenv3 file available from the Nevada Geodetic Laboratory, the
data.frame df_equipment_software_changes which specify the equipment or software changes for that stations and the data.frame df_earthquakes that specify the earthquakes associated with that station.
station_1LSU <- download_station_ngl("1LSU") attributes(station_1LSU)station_1LSU <- download_station_ngl("1LSU") attributes(station_1LSU)
time_series_model)Constructs a time_series_model for flicker noise with
variance sigma2.
The process has spectral density
. Hence, (Bos et al., 2008).
The process is non-stationary and its covariance matrix is assumed to be
given by
where is an upper-triangular
Toeplitz matrix with entries
The coefficients define a causal linear filter and
are given recursively by
flicker(sigma2 = NULL)flicker(sigma2 = NULL)
sigma2 |
Innovation variance (> 0). |
A time_series_model object.
Bos MS, Fernandes RMS, Williams SDP, Bastos L (2008). "Fast error analysis of continuous GPS observations." Journal of Geodesy, 82, 157-166.
mod <- flicker(sigma2 = 1) modmod <- flicker(sigma2 = 1) mod
time_series_model or sum_model objectGenerate a time series from a time_series_model or sum_model object
generate(object, n, seed = NULL, ...)generate(object, n, seed = NULL, ...)
object |
A |
n |
Length of series to generate. |
seed |
Optional integer seed for reproducibility. |
... |
Passed to method. |
A generated_time_series (single model) or
generated_composite_model_time_series (sum model).
# Single model m1 <- ar1(phi = 0.8, sigma2 = 1) y1 <- generate(m1, n = 200, seed = 123) plot(y1) # Composite model m2 <- wn(sigma2 = 1) + pl(kappa = 0.3, sigma2 = 2) y2 <- generate(m2, n = 200, seed = 123) plot(y2)# Single model m1 <- ar1(phi = 0.8, sigma2 = 1) y1 <- generate(m1, n = 200, seed = 123) plot(y1) # Composite model m2 <- wn(sigma2 = 1) + pl(kappa = 0.3, sigma2 = 2) y2 <- generate(m2, n = 200, seed = 123) plot(y2)
Implements the Generalized Method of Wavelet Moments (GMWM) estimator
to fit a time_series_model, a sum_model or a numeric vector.
gmwm2(x, model, omega = NULL, method = "L-BFGS-B", control = list(), ...)gmwm2(x, model, omega = NULL, method = "L-BFGS-B", control = list(), ...)
x |
Numeric vector, or a |
model |
A |
omega |
Optional weighting matrix. If |
method |
Optimization method passed to |
control |
Optional list of control parameters for |
... |
Additional arguments passed to |
The GMWM estimator solves a weighted least-squares criterion of the form
where denotes the empirical wavelet
variance and
the corresponding theoretical wavelet variance implied by the model
parameters . The weighting matrix
defaults to a diagonal matrix with entries proportional to the
inverse squared width of the empirical WV asymptotic confidence intervals. Provide
omega to use a custom weighting (e.g., from a theoretical covariance).
An object of class gmwm2_fit with elements:
theta_hat (real space), theta_domain (constrained space),
model, empirical_wvar, theoretical_wvar, optim, and n.
Guerrier, S., Skaloud, J., Stebler, Y., and Victoria-Feser, M.-P. (2013). Wavelet-variance-based estimation for composite stochastic processes. Journal of the American Statistical Association, 108(503), 1021-1030. doi:10.1080/01621459.2013.799920.
n = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1()) fit plot(fit)n = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1()) fit plot(fit)
Dispatches either to the generic regression interface (design matrix + response)
or to a gnss_ts_ngl workflow.
Convenience wrapper that selects the missing or non-missing implementation
based on the presence of NA values in y.
gmwmx2(X, ...) ## Default S3 method: gmwmx2(X, y, model, omega = NULL, method = "L-BFGS-B", control = list(), ...) ## S3 method for class 'gnss_ts_ngl' gmwmx2( X, n_seasonal = 2, vec_earthquakes_relaxation_time = NULL, component = NULL, model = NULL, omega = NULL, method = "L-BFGS-B", control = list(), ... )gmwmx2(X, ...) ## Default S3 method: gmwmx2(X, y, model, omega = NULL, method = "L-BFGS-B", control = list(), ...) ## S3 method for class 'gnss_ts_ngl' gmwmx2( X, n_seasonal = 2, vec_earthquakes_relaxation_time = NULL, component = NULL, model = NULL, omega = NULL, method = "L-BFGS-B", control = list(), ... )
X |
A |
... |
Reserved for future extensions. |
y |
Response vector for a generic regression interface. |
model |
Stochastic model specification. |
omega |
Optional weighting matrix. If |
method |
Optimization method passed to |
control |
Control list passed to |
n_seasonal |
Number of seasonal signals. |
vec_earthquakes_relaxation_time |
Relaxation time for each earthquake. |
component |
Component to estimate ("N", "E", or "V"). |
A fitted model object.
A fitted model object.
A fitted model object.
missingness_model)Constructs a missingness_model representing a two-state Markov process
for missing/observed indicators. The process takes values in {0, 1},
where 1 indicates observed and 0 indicates missing.
markov_two_states(p1 = NULL, p2 = NULL)markov_two_states(p1 = NULL, p2 = NULL)
p1 |
Transition probability from observed (1) to missing (0). |
p2 |
Transition probability from missing (0) to observed (1). |
A missingness_model object.
mod <- markov_two_states(p1 = 0.05, p2 = 0.95) mod z <- generate(mod, n = 200, seed = 123) plot(z)mod <- markov_two_states(p1 = 0.05, p2 = 0.95) mod z <- generate(mod, n = 200, seed = 123) plot(z)
time_series_model)Constructs a time_series_model for a Matern covariance process with
variance sigma2, range lambda, and smoothness alpha.
The autocovariance is
where is the modified Bessel function of the second kind of order .
matern(sigma2 = NULL, lambda = NULL, alpha = NULL)matern(sigma2 = NULL, lambda = NULL, alpha = NULL)
sigma2 |
Marginal variance (> 0). |
lambda |
Range/scale parameter (> 0). |
alpha |
Smoothness parameter in (1/2, 10). |
A time_series_model object.
Lilly JM, Sykulski AM, Early JJ, Olhede SC (2017). "Fractional Brownian motion, the Matérn process, and stochastic modeling of turbulent dispersion." Nonlinear Processes in Geophysics, 24(3), 481-514.
mod <- matern(sigma2 = 1, lambda = 0.2, alpha = 1.0) modmod <- matern(sigma2 = 1, lambda = 0.2, alpha = 1.0) mod
time_series_model)Constructs a time_series_model representing a stationary power-law
process with parameters kappa and sigma2.
In the frequency domain, a power-law process is often described by a
spectrum (Bos et al., 2008), where is the frequency, is a constant and is the spectral index.
Note that we use the convention that the power spectral density satisfies
, where ensures second-order
stationarity. This corresponds to the alternative notation
with .
The autocovariance used here (Hosking, 1981) is
,
and for
.
pl(kappa = NULL, sigma2 = NULL)pl(kappa = NULL, sigma2 = NULL)
kappa |
Power-law parameter in (-1, 1). |
sigma2 |
Process variance (> 0). |
A time_series_model object.
Bos MS, Fernandes RMS, Williams SDP, Bastos L (2008). "Fast error analysis of continuous GPS observations." Journal of Geodesy, 82, 157-166.
Hosking JRM (1981). "Fractional differencing." Biometrika, 68(1), 165-176.
mod <- pl(kappa = -0.5, sigma2 = 2) modmod <- pl(kappa = -0.5, sigma2 = 2) mod
generated_composite_model_time_series objectProduces stacked line plots for each component and the sum for a
generated_composite_model_time_series object.
## S3 method for class 'generated_composite_model_time_series' plot(x, ...)## S3 method for class 'generated_composite_model_time_series' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
Invisibly returns x.
m2 <- wn(sigma2 = 1) + ar1(phi = 0.8, sigma2 = 0.5) y2 <- generate(m2, n = 200, seed = 123) plot(y2)m2 <- wn(sigma2 = 1) + ar1(phi = 0.8, sigma2 = 0.5) y2 <- generate(m2, n = 200, seed = 123) plot(y2)
generated_missingness objectProduces a step plot for a generated_missingness object.
## S3 method for class 'generated_missingness' plot(x, ...)## S3 method for class 'generated_missingness' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
Invisibly returns x.
m0 <- markov_two_states(p1 = 0.05, p2 = 0.9) z0 <- generate(m0, n = 200, seed = 123) plot(z0)m0 <- markov_two_states(p1 = 0.05, p2 = 0.9) z0 <- generate(m0, n = 200, seed = 123) plot(z0)
generated_time_series objectProduces a single line plot for a generated_time_series object.
## S3 method for class 'generated_time_series' plot(x, ...)## S3 method for class 'generated_time_series' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
Invisibly returns x.
m1 <- wn(sigma2 = 1) y1 <- generate(m1, n = 200, seed = 123) plot(y1)m1 <- wn(sigma2 = 1) y1 <- generate(m1, n = 200, seed = 123) plot(y1)
gmwm2_fit objectPlots empirical wavelet variance with the fitted theoretical curve and, for sum models, component-implied theoretical curves.
## S3 method for class 'gmwm2_fit' plot( x, show_ci = TRUE, col_emp = "black", col_theo = "darkorange", col_ci = "#e6f7fb", lwd = 2, pch_emp = 16, pch_theo = 21, cex_theo = 1.4, legend_pos = "auto", ... )## S3 method for class 'gmwm2_fit' plot( x, show_ci = TRUE, col_emp = "black", col_theo = "darkorange", col_ci = "#e6f7fb", lwd = 2, pch_emp = 16, pch_theo = 21, cex_theo = 1.4, legend_pos = "auto", ... )
x |
A |
show_ci |
Logical; if TRUE and available, show empirical CI bars. |
col_emp |
Color for empirical WV points/line. |
col_theo |
Color for theoretical WV line. |
col_ci |
Color for empirical WV CI band. |
lwd |
Line width for theoretical curve. |
pch_emp |
Plotting character for empirical points. |
pch_theo |
Plotting character for theoretical points. |
cex_theo |
Size for theoretical points. |
legend_pos |
Legend position (e.g., "topleft") or "auto". |
... |
Additional arguments passed to |
The input object, invisibly.
n = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1() ) fit plot(fit)n = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1() ) fit plot(fit)
gmwmx2_fit_gnss_ts_ngl objectPlot a gmwmx2_fit_gnss_ts_ngl object
## S3 method for class 'gmwmx2_fit_gnss_ts_ngl' plot(x, ...)## S3 method for class 'gmwmx2_fit_gnss_ts_ngl' plot(x, ...)
x |
A |
... |
Additional graphical parameters. |
No return value. Plot a gmwmx2_fit_gnss_ts_ngl object.
station_data = gmwmx2::download_station_ngl("1LSU") # fit station with WN and AR1 fit1 <- gmwmx2( station_data, n_seasonal = 2, model = wn() + ar1(), component = "N" ) fit1 plot(fit1) # fit station with WN and PL fit2 <- gmwmx2( station_data, n_seasonal = 2, model = wn() + pl(), component = "N" ) fit2 plot(fit2) # fit station with WN and Matern fit3 = gmwmx2( station_data, n_seasonal = 2, model = wn() + matern(), component = "N" ) fit3 plot(fit3)station_data = gmwmx2::download_station_ngl("1LSU") # fit station with WN and AR1 fit1 <- gmwmx2( station_data, n_seasonal = 2, model = wn() + ar1(), component = "N" ) fit1 plot(fit1) # fit station with WN and PL fit2 <- gmwmx2( station_data, n_seasonal = 2, model = wn() + pl(), component = "N" ) fit2 plot(fit2) # fit station with WN and Matern fit3 = gmwmx2( station_data, n_seasonal = 2, model = wn() + matern(), component = "N" ) fit3 plot(fit3)
gnss_ts_ngl objectPlot a gnss_ts_ngl object
## S3 method for class 'gnss_ts_ngl' plot(x, component = NULL, ...)## S3 method for class 'gnss_ts_ngl' plot(x, component = NULL, ...)
x |
A |
component |
A |
... |
Additional graphical parameters. |
No return value. Plot a gnss_ts_ngl object.
station_1LSU <- download_station_ngl("1LSU") plot(station_1LSU) plot(station_1LSU, component = "N") plot(station_1LSU, component = "E") plot(station_1LSU, component = "V")station_1LSU <- download_station_ngl("1LSU") plot(station_1LSU) plot(station_1LSU, component = "N") plot(station_1LSU, component = "E") plot(station_1LSU, component = "V")
gmwm2_fit objectPrint method for a gmwm2_fit object
## S3 method for class 'gmwm2_fit' print(x, digits = 4, show_initial_parameters = FALSE, ...)## S3 method for class 'gmwm2_fit' print(x, digits = 4, show_initial_parameters = FALSE, ...)
x |
A |
digits |
Significant digits for printing. |
show_initial_parameters |
Logical; if TRUE, also show the initial parameters used for optimization. |
... |
Unused. |
The input object, invisibly.
n = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1() ) fitn = 10000 mod = wn(20) + ar1(phi = .995, sigma2 = .2) y = generate(mod, n = n, seed = 123) plot(y) fit = gmwm2(y, model = wn() + ar1() ) fit
gmwmx2_fit objectDisplays a table of regression coefficients with standard errors and summarizes the fitted stochastic model with estimated parameters.
## S3 method for class 'gmwmx2_fit' print(x, digits = 4, ...)## S3 method for class 'gmwmx2_fit' print(x, digits = 4, ...)
x |
A |
digits |
Significant digits to display. |
... |
Passed to print methods. |
The input object, invisibly.
gmwmx2_fit_gnss_ts_ngl objectDisplays regression coefficients with standard errors and confidence intervals, along with the fitted stochastic and missingness models.
## S3 method for class 'gmwmx2_fit_gnss_ts_ngl' print(x, digits = 4, ...)## S3 method for class 'gmwmx2_fit_gnss_ts_ngl' print(x, digits = 4, ...)
x |
A |
digits |
Significant digits to display. |
... |
Passed to print methods. |
The input object, invisibly.
time_series_model)Constructs a time_series_model for a random walk with innovation
variance sigma2. The autocovariance returned is the mean of the
diagonal and super-diagonals of the covariance matrix.
The model is
.
rw(sigma2 = NULL)rw(sigma2 = NULL)
sigma2 |
Innovation variance (> 0). |
A time_series_model object.
mod <- rw(sigma2 = 1) modmod <- rw(sigma2 = 1) mod
time_series_model)Constructs a time_series_model for white noise with variance sigma2.
The process is defined as
with autocovariance
wn(sigma2 = NULL)wn(sigma2 = NULL)
sigma2 |
Innovation variance (> 0). |
A time_series_model object.
mod <- wn(sigma2 = 1) modmod <- wn(sigma2 = 1) mod