add_data: Add data to object of class 'gsmar' defining a GMAR, StMAR,...

Description Usage Arguments Value References See Also Examples

View source: R/GSMARconstructor.R

Description

add_data adds or updates data to object of class 'gsmar' that defines a GMAR, StMAR, or G-StMAR model. Also calculates empirical mixing weights, conditional moments, and quantile residuals accordingly.

Usage

1
2
3
4
5
6
7
8
add_data(
  data,
  gsmar,
  calc_qresiduals = TRUE,
  calc_cond_moments = TRUE,
  calc_std_errors = FALSE,
  custom_h = NULL
)

Arguments

data

a numeric vector or class 'ts' object containing the data. NA values are not supported.

gsmar

a class 'gsmar' object, typically generated by fitGSMAR or GSMAR.

calc_qresiduals

should quantile residuals be calculated? Default is TRUE iff the model contains data.

calc_cond_moments

should conditional means and variances be calculated? Default is TRUE iff the model contains data.

calc_std_errors

should approximate standard errors be calculated?

custom_h

A numeric vector with same the length as the parameter vector: i:th element of custom_h is the difference used in central difference approximation for partial differentials of the log-likelihood function for the i:th parameter. If NULL (default), then the difference used for differentiating overly large degrees of freedom parameters is adjusted to avoid numerical problems, and the difference is 6e-6 for the other parameters.

Value

Returns an object of class 'gsmar' defining the GMAR, StMAR, or G-StMAR model with the data added to the model. If the object already contained data, the data will be updated. Does not modify the 'gsmar' object given as argument!

References

See Also

fitGSMAR, GSMAR, iterate_more, get_gradient, get_regime_means, swap_parametrization, stmar_to_gstmar

Examples

1
2
3
4
5
6
7
8
9
# G-StMAR model without data
params42gs <- c(0.04, 1.34, -0.59, 0.54, -0.36, 0.01, 0.06, 1.28, -0.36,
                0.2, -0.15, 0.04, 0.19, 9.75)
gstmar42 <- GSMAR(p=4, M=c(1, 1), params=params42gs, model="G-StMAR")
gstmar42

# Add data to the model
gstmar42 <- add_data(data=M10Y1Y, gsmar=gstmar42)
gstmar42

uGMAR documentation built on Jan. 24, 2022, 5:10 p.m.