gamsim: Simulate example datasets from a generalized additive models...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/gamsim.R

Description

This function is a modification from example 7 of the gamSim function available in the mgcv package (Wood, 2017), which is turn is Gu and Wahba 4 univariate example with correlated predictors. Please see the source code for exactly what is simulated. The function is primarily used as the basis for conducting the simulation studies in Hui et al., (2018).

Usage

1
gamsim(n = 400, extra.X = NULL, beta = NULL, dist = "normal", scale = 1, offset = NULL)

Arguments

n

Sample size.

extra.X

Extra covariates, including critically an intercept if is to be included in the linear predictor for the GAM.

beta

Regression coefficient estimates.

dist

Currently only the "normal", "poisson" or "binomial" corresponding to the binomial distributions are available.

scale

Scale parameter in the Normal distribution.

offset

This can be used to specify an a-priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to n.

Value

A data frame containing information such as the simulated responses, covariates, each of the 4 "truth" smooths, and the overall linear predictor.

Author(s)

Han Lin Shang [aut, cre, cph] (<https://orcid.org/0000-0003-1769-6430>), Francis K.C. Hui [aut] (<https://orcid.org/0000-0003-0765-3533>)

References

See Also

vagam for the main fitting function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
normal_dat = gamsim(n = 40, dist = "normal", 
                    extra.X = data.frame(int = rep(1,40), trt = rep(c(0,1), each = 20)),
                    beta = c(-1, 0.5))

pois_dat = gamsim(n = 40, dist = "poisson", 
                  extra.X = data.frame(int = rep(1, 40), trt = rep(c(0,1), each = 20)),
                  beta = c(-1, 0.5))

binom_dat = gamsim(n = 40, dist = "binomial",
                   extra.X = data.frame(int = rep(1, 40), trt = rep(c(0,1), each = 20)),
                   beta = c(0, 0.5))

## Please see examples in the help file for the vagam function.

Example output

Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
Loading required package: gamm4
Loading required package: Matrix
Loading required package: lme4

Attaching package:lme4The following object is masked frompackage:nlme:

    lmList

This is gamm4 0.2-6

Loading required package: mvtnorm
Loading required package: truncnorm

vagam documentation built on Dec. 7, 2019, 1:06 a.m.