Learn R Programming

mgcv (version 0.8-1)

SANtest: Example of simple additive GAM using penalized regression splines.

Description

Provides an example of the use of mgcv() and GAMsetup() for simple GAM modelling with penalized regression splines. Truth is simulated as the sum of 3 univariate functions of 3 covariates: normal errors are added to produce simulated data. A GAM is then fitted using mgcv() (including one spurious covariate). Scatter plots of data against the 4 covariates and plots of true and reconstructed functions are produced.

Of little interest for practical analysis (see gam instead).

Usage

SANtest(n=100, sig2=-1)

Arguments

n
n is the number of data to simulate.
sig2
The magnitude of sig2 gives the error variance to use for simulation of data. If sig2 is greater than zero the UBRE is used with the error variance, $\sigma^2$, given by sig2, otherwise GCV is used.

Value

  • An estimate of the error variance used for simulation (GCV), or the error variance (UBRE).

See Also

mgcv gam

Examples

Run this code
set.seed(0)
SANtest(300,-1) # use GCV with 300 data point example, variance 1
SANtest(300,0.5) # use UBRE 300 data, variance 0.5

Run the code above in your browser using DataLab