## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(mcgf)
data(sim1)

x <- mcgf(
    sim1$data,
    locations = sim1$locations
)

x <- add_acfs(x, lag_max = 5)
x <- add_ccfs(x, lag_max = 5)

## ----fit-base-----------------------------------------------------------------
fit_sep <- fit_base(
    x,
    model = "sep",
    lag = 5,
    par_init = c(
        c = 0.001,
        gamma = 0.5,
        a = 0.3,
        alpha = 0.5
    ),
    par_fixed = c(nugget = 0)
)

x <- add_base(x, fit_base = fit_sep)

## ----new-location-------------------------------------------------------------
new_location <- matrix(
    colMeans(sim1$locations),
    nrow = 1
)
rownames(new_location) <- "New_site"

new_location

## ----predict-new--------------------------------------------------------------
pred <- krige_new(
    x,
    locations_new = new_location,
    model = "base",
    interval = TRUE
)

dim(pred$fit)

## ----inspect-new--------------------------------------------------------------
new_index <- dim(pred$fit)[2]

head(pred$fit[, new_index])
head(pred$lower[, new_index])
head(pred$upper[, new_index])

