## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 5
)

## ----setup--------------------------------------------------------------------
library(simplexgof)

## -----------------------------------------------------------------------------
data(ammonia)
head(ammonia)

## -----------------------------------------------------------------------------
X <- cbind(1, ammonia$corr_ar, ammonia$temp_agua,
           ammonia$corr_ar * ammonia$temp_agua)
Z <- cbind(1, ammonia$temp_agua,
           ammonia$corr_ar * ammonia$temp_agua)

fit <- simplex_fit(ammonia$perda, X, Z)
fit

## -----------------------------------------------------------------------------
coef(fit)

## -----------------------------------------------------------------------------
dg <- simplex_diag(fit)
dg$Tn
dg$Un

## ----fig.alt = "Influence index plot for the ammonia model"-------------------
plot_influence(dg)

## -----------------------------------------------------------------------------
set.seed(42)
gof <- simplex_gof(ammonia$perda, X, Z, B = 50, alpha = 0.01,
                    verbose = FALSE)
gof

## ----fig.alt = "Bootstrap distribution of Un for the ammonia model"-----------
plot_gof_boot(gof)

## ----eval = FALSE-------------------------------------------------------------
# plot_envelope(fit, B = 99)

## ----eval = FALSE-------------------------------------------------------------
# plot(fit, which = "influence")
# plot(gof, which = "boot")

