add_base.mcgf_rs function

Add base model outputted from fit_base() to an mcgf_rs object.

Add base model outputted from fit_base() to an mcgf_rs object.

## S3 method for class 'mcgf_rs' add_base(x, fit_base_ls, fit_s_ls, fit_t_ls, sep = FALSE, old = FALSE, ...)

Arguments

  • x: An mcgf_rs` object.

  • fit_base_ls: Output from the fit_base() function.

  • fit_s_ls: Pure spatial model outputted from the fit_base() function. Used only when sep = TRUE.

  • fit_t_ls: Pure temporal model outputted from the fit_base()

    function. Used only when sep = TRUE.

  • sep: Logical; TRUE if spatial and temporal models are fitted separately.

  • old: Logical; TRUE if the old base model needs to be kept. The lag and horizon of the new model are assumed to be the same as that of the old model.

  • ...: Additional arguments. Not in use.

Returns

x with newly added attributes of the base model.

Details

After fitting the base model by fit_base(), the results can be added to x by add_base(). To supply the base model directly, use base<- to add the base model; the value must contain the same output as add_base.mcgf() or add_base.mcgf_rs().

Examples

data(sim2) sim2_mcgf <- mcgf_rs(sim2$data, dists = sim2$dists, label = sim2$label) sim2_mcgf <- add_acfs(sim2_mcgf, lag_max = 5) sim2_mcgf <- add_ccfs(sim2_mcgf, lag_max = 5) # Fit a regime-switching pure spatial model fit_spatial <- fit_base( sim2_mcgf, lag_ls = 5, model_ls = "spatial", par_init_ls = list(c(c = 0.00005, gamma = 0.5)), par_fixed_ls = list(c(nugget = 0)) ) # Fit a regime-switching pure temporal model fit_temporal <- fit_base( sim2_mcgf, lag_ls = 5, model_ls = "temporal", par_init_ls = list( list(a = 0.8, alpha = 0.8), list(a = 0.1, alpha = 0.1) ) ) # Store the fitted models to 'sim2_mcgf' sim2_mcgf <- add_base(sim2_mcgf, fit_s_ls = fit_spatial, fit_t_ls = fit_temporal, sep = TRUE ) # Fit a regime-switching separable model fit_sep <- fit_base( sim2_mcgf, lag_ls = 5, model_ls = "sep", par_init_ls = list(list( c = 0.00005, gamma = 0.5, a = 0.5, alpha = 0.5 )), par_fixed_ls = list(c(nugget = 0)) ) # Store the newly fitted model, and keep the old fit sim2_mcgf <- add_base(sim2_mcgf, fit_base_ls = fit_sep, old = TRUE) model(sim2_mcgf, model = "base", old = TRUE)

See Also

Other functions on fitting an mcgf_rs: add_lagr.mcgf_rs(), fit_base.mcgf_rs(), fit_lagr.mcgf_rs(), krige.mcgf_rs(), krige_new.mcgf_rs()