Learn R Programming

gratia (version 0.8.1)

data_sim: Simulate example data for fitting GAMs

Description

A tidy reimplementation of the functions implemented in mgcv::gamSim() that can be used to fit GAMs. An new feature is that the sampling distribution can be applied to all the example types.

Usage

data_sim(
  model = "eg1",
  n = 400,
  scale = 2,
  theta = 3,
  dist = c("normal", "poisson", "binary", "negbin", "tweedie"),
  seed = NULL
)

Arguments

model

character; either "egX" where X is an integer 1:7, or the name of a model. See Details for possible options.

n

numeric; the number of observations to simulate.

scale

numeric; the level of noise to use.

theta

numeric; the dispersion parameter \(\theta\) to use. The default is entirely arbitrary, chosen only to provide simulated data that exhibits extra dispersion beyond that assumed by under a Poisson.

dist

character; a sampling distribution for the response variable.

seed

numeric; the seed for the random number generator. Passed to base::set.seed().

Examples

Run this code
# \dontshow{
set.seed(1)
op <- options(pillar.sigfig = 5, cli.unicode = FALSE)
# }
data_sim("eg1")
options(op)

Run the code above in your browser using DataLab