# rig: Generate inverse Gaussian random deviates In mgcv: Mixed GAM Computation Vehicle with Automatic Smoothness Estimation

 rig R Documentation

## Generate inverse Gaussian random deviates

### Description

Generates inverse Gaussian random deviates.

### Usage

``````rig(n,mean,scale)
``````

### Arguments

 `n` the number of deviates required. If this has length > 1 then the length is taken as the number of deviates required. `mean` vector of mean values. `scale` vector of scale parameter values (lambda, see below)

### Details

If x if the returned vector, then E(x) = `mean` while var(x) = `scale*mean^3`. For density and distribution functions see the `statmod` package. The algorithm used is Algorithm 5.7 of Gentle (2003), based on Michael et al. (1976). Note that `scale` here is the scale parameter in the GLM sense, which is the reciprocal of the usual ‘lambda’ parameter.

### Value

A vector of inverse Gaussian random deviates.

### Author(s)

Simon N. Wood simon.wood@r-project.org

### References

Gentle, J.E. (2003) Random Number Generation and Monte Carlo Methods (2nd ed.) Springer.

Michael, J.R., W.R. Schucany & R.W. Hass (1976) Generating random variates using transformations with multiple roots. The American Statistician 30, 88-90.

### Examples

``````require(mgcv)
set.seed(7)
## An inverse.gaussian GAM example, by modify `gamSim' output...
dat <- gamSim(1,n=400,dist="normal",scale=1)
dat\$f <- dat\$f/4 ## true linear predictor
Ey <- exp(dat\$f);scale <- .5 ## mean and GLM scale parameter
## simulate inverse Gaussian response...
dat\$y <- rig(Ey,mean=Ey,scale=.2)