Learn R Programming

glmSTARMA (version 1.0.0)

dglmstarma.sim: Simulate spatial time-series based on double generalized linear models

Description

Generates a simulated multivariate time series based on a GLM-like model (see dglmstarma for details)

Usage

dglmstarma.sim(
  ntime,
  parameters_mean,
  parameters_dispersion,
  model_mean,
  model_dispersion,
  mean_family = NULL,
  dispersion_link = c("log", "identity", "inverse"),
  wlist = NULL,
  mean_covariates = list(),
  dispersion_covariates = list(),
  pseudo_observations = c("deviance", "pearson"),
  wlist_past_mean = NULL,
  wlist_covariates = NULL,
  wlist_pseudo_obs = NULL,
  wlist_past_dispersion = NULL,
  wlist_covariates_dispersion = NULL,
  n_start = 100L,
  control = list()
)

Value

a named list with the following elements:

  • observations (numeric matrix): The simulated time series

  • link_values (numeric matrix): The underlying linear predictor resulting from the model and simulation

  • pseudo_observations (numeric matrix): The pseudo-observations generated for the dispersion model

  • dispersion_values (numeric matrix): The dispersion values resulting from the dispersion model

  • mean_model (list): The mean model used for the simulation

  • dispersion_model (list): The dispersion model used for the simulation

  • parameters_mean (list): The true parameters used for the mean model

  • parameters_dispersion (list): The true parameters used for the dispersion model

Arguments

ntime

Number of observation times to be simulated

parameters_mean

a named list specifying the parameters of the model to be simulated:

  • intercept (numeric): Intercept parameter. If an inhomogeneous model is simulated, a value must be specified for each component of the time series.

  • past_obs (numeric matrix): Parameter values for the past observations.

  • past_mean (numeric matrix): Parameter values for the past means.

  • covariates (numeric matrix): Parameter values for the covariates.

parameters_dispersion

a named list specifying the parameters of the dispersion model to be simulated, with the same possible elements as in parameters_mean.

model_mean

a named list specifying the model for the linear predictor, which can be of the following elements:

  • intercept (character): 'homogenous' (default) for a homogenous model, i.e. the same intercept for all components, 'inhomogenous' for inhomogenous models, i.e. an individual intercept for each component.

  • past_obs (integer vector/binary matrix): Maximal spatial orders for the time lags in past_obs_time_lags. A binary matrix can be passed as an alternative, with the entry in row \(i\) and column \(j\) indicating whether the \((i - 1)\)-spatial lag for the \(j\)-th time lag is included in the model. If not specified, no regression on past observations is performed.

  • past_obs_time_lags (optional integer vector) indicates the time lags for regression on past observations. Defaults are seq(length(past_obs)) (for vectors) and seq(ncol(past_obs)) (for a matrix)

  • past_mean (integer vector/binary matrix): Spatial orders for the regression on the (latent) feedback process. Values can be entered in the same format as in past_obs. If not specified, no regression to the feedback process is performed.

  • past_mean_time_lags (optional integer vector) indicates the time lags for regression on past values of the feedback process. Defaults are seq(length(past_mean)) (for vectors) and seq(ncol(past_mean)) (for a matrix)

  • covariates (integer vector/binary matrix) spatial orders for the covariate processes passed in the argument covariates. The values can be passed as in past_obs and past_means, where the \(j\)-th entry or column represents the \(j\)-th covariable. If no values are specified but covariates are included, the spatial order 0 is used by default, which corresponds to the first matrix in argument wlist_covariates.

model_dispersion

a named list specifying the model for the dispersion linear predictor, with the same possible elements as in model_mean. Orders supplied in past_obs are applied to the pseudo-observations.

mean_family

An object of class stfamily that specifies the marginal distributions of the observations and the link-function for the mean model.

dispersion_link

Link function for the dispersion model. Possible values are "log" (default), "identity", and "inverse".

wlist

A list of quadratic matrices, with the same dimension as the time series, which describe the spatial dependencies. Row-normalized matrices are recommended.

mean_covariates

List of covariates included in the mean model, containing matrices or returns of the covariate functions of this package (see also TimeConstant, SpatialConstant).

dispersion_covariates

List of covariates included in the dispersion model.

pseudo_observations

Method to generate the pseudo-observations for the dispersion model. Possible values are "deviance" (default) and "pearson".

wlist_past_mean

(Optional) List of matrices, which describes spatial dependencies for the past mean. If this is NULL, the matrices from wlist are used.

wlist_covariates

(Optional) List of matrices, which describes spatial dependencies for the covariates. If this is NULL, the matrices from wlist are used.

wlist_pseudo_obs

(Optional) List of matrices, which describes spatial dependencies for the pseudo-observations in the dispersion model. If this is NULL, the matrices from wlist are used.

wlist_past_dispersion

(Optional) List of matrices, which describes spatial dependencies for the past dispersion in the dispersion model. If this is NULL, the matrices from wlist are used.

wlist_covariates_dispersion

(Optional) List of matrices, which describes spatial dependencies for the covariates in the dispersion model. If this is NULL, the matrices from wlist are used.

n_start

Number of observations to be used for the burn-in period

control

A list of parameters for controlling the fitting process. This list is passed to dglmstarma.control.

Examples

Run this code
set.seed(42)
n_obs <- 200L
W <- generateW("rectangle", 100, 2, 10)
model_orders_mean <- list(intercept = "homogeneous", 
                          past_obs = 2, past_mean = 1, 
                          covariates = c(0, 0))
model_orders_dispersion <- list(intercept = "homogeneous", 
                                past_obs = 1, 
                                covariates = c(0, 0))

covariates_mean <- list(season = SpatialConstant(sin(2 * pi / 12 * seq(n_obs))),
                  location = TimeConstant(rnorm(100, sd = 0.81)))

covariates_dispersion <- list(season = SpatialConstant(sin(2 * pi / 24 * seq(n_obs))),
                        location = TimeConstant(runif(100)))

params_mean <- list(intercept = 0.6, 
                    past_mean = matrix(c(0.2, 0.1), nrow = 2), 
                    past_obs = matrix(c(0.2, 0.1, 0.05), nrow = 3), 
                    covariates = matrix(c(0.9, 0.2), ncol = 2))
params_dispersion <- list(intercept = 0.5, 
                    past_obs = matrix(c(0.5, 0.2), nrow = 2), 
                    covariates = matrix(c(0.1, 0.75), ncol = 2))
family <- vnormal(copula = "frank", copula_param = 2)
dglmstarma.sim(n_obs, params_mean, params_dispersion, model_orders_mean, 
              model_orders_dispersion, mean_family = family, 
              wlist = W, pseudo_observations = "deviance", 
              mean_covariates = covariates_mean, 
              dispersion_covariates = covariates_dispersion)

Run the code above in your browser using DataLab