data(sim1)
sim1_mcgf <- mcgf(sim1$data, dists = sim1$dists)
sim1_mcgf <- add_acfs(sim1_mcgf, lag_max = 5)
sim1_mcgf <- add_ccfs(sim1_mcgf, lag_max = 5)
# Fit a pure spatial model
fit_spatial <- fit_base(
sim1_mcgf,
model = "spatial",
lag = 5,
par_init = c(c = 0.001, gamma = 0.5),
par_fixed = c(nugget = 0)
)
# Fit a pure temporal model
fit_temporal <- fit_base(
sim1_mcgf,
model = "temporal",
lag = 5,
par_init = c(a = 0.3, alpha = 0.5)
)
# Store the fitted models to 'sim1_mcgf'
sim1_mcgf <-
add_base(sim1_mcgf,
fit_s = fit_spatial,
fit_t = fit_temporal,
sep = TRUE
)
# Fit a separable model
fit_sep <- fit_base(
sim1_mcgf,
model = "sep",
lag = 5,
par_init = c(
c = 0.001,
gamma = 0.5,
a = 0.3,
alpha = 0.5
),
par_fixed = c(nugget = 0)
)
# Store the newly fitted model, and keep the old fit
sim1_mcgf <- add_base(sim1_mcgf, fit_base = fit_sep, old = TRUE)
model(sim1_mcgf, model = "base", old = TRUE)
Run the code above in your browser using DataLab