Learn R Programming

VGAM (version 0.9-4)

simulate.vlm: Simulate Responses for VGLMs and VGAMs

Description

Simulate one or more responses from the distribution corresponding to a fitted model object.

Usage

## S3 method for class 'vlm':
simulate(object, nsim = 1, seed = NULL, \dots)

Arguments

object
an object representing a fitted model. Usually an object of class vglm-class or vgam-class.
nsim, seed
Same as simulate.
...
additional optional arguments.

Value

  • Similar to simulate. Note that many VGAM family functions can handle multiple responses. This can result in a longer data frame with more rows (nsim multiplied by n rather than the ordinary n). In the future an argument may be available so that there is always n rows no matter how many responses were inputted.

newcommand

\CRANpkg

href

http://CRAN.R-project.org/package=#1

pkg

#1

Details

This is a methods function for simulate and hopefully should behave in a very similar manner. Only VGAM family functions with a simslot slot have been implemented for simulate.

See Also

Currently the VGAM family functions with a simslot slot are: alaplace1, alaplace2, amh, betabinomial, betabinomial.ab, beta.ab, betaff, bifrankcop, bilogistic4, binomialff, binormal, binormalcop, biclaytoncop, cauchy, cauchy1, chisq, dirichlet, dagum, erlang, exponential, fgm, fisk, gamma1, gamma2, gamma2.ab, gengamma, geometric, gompertz, gumbelII, hzeta, invlomax, invparalogistic, kumar, lgammaff, lgamma3ff, lindley, lino, logff, logistic1, logistic2, lognormal, lognormal3, lomax, makeham, negbinomial, negbinomial.size, paralogistic, perks, poissonff, posnegbinomial, posnormal, pospoisson, polya, posbinomial, rayleigh, riceff, simplex, sinmad, slash, studentt, studentt2, studentt3, triangle, uninormal, yulesimon, zageometric, zageometricff, zanegbinomial, zanegbinomialff, zapoisson, zapoissonff, zigeometric, zigeometricff, zinegbinomial, zipf, zipoisson, zipoissonff.

See also RNG about random number generation in R, vglm, vgam for model fitting.

Examples

Run this code
nn <- 10; mysize <- 20
set.seed(123)
bdata <- data.frame(x2 = rnorm(nn))
bdata <- transform(bdata,
  y1   = rbinom(nn, size = mysize, p = logit(1+x2, inverse = TRUE)),
  y2   = rbinom(nn, size = mysize, p = logit(1+x2, inverse = TRUE)),
  f1   = factor(as.numeric(rbinom(nn, size = 1,
                                   p = logit(1+x2, inverse = TRUE)))))
(fit1 <- vglm(cbind(y1, aaa = mysize - y1) ~ x2,  # Matrix response (2-colns)
              binomialff, data = bdata))
(fit2 <- vglm(f1 ~ x2,  # Factor response
              binomialff, model = TRUE, data = bdata))

set.seed(123)
simulate(fit1, nsim = 8)

set.seed(123)
c(simulate(fit2, nsim = 3))  # Use c() when model = TRUE

Run the code above in your browser using DataLab