simulate {dbd} | R Documentation |
Simulate data from a db or beta binomial distribution.
Description
Simulate one or more data sets from a db or beta binomial
distribution. The parameters of the distribution may be
equal to those obtained from fitting the distibution to data,
using mleDb()
or mleBb()
. They may also be
specified by the user via the function makeDbdpars()
or makeBbdpars()
.
Usage
## S3 method for class 'mleDb'
simulate(object, nsim = 1, seed = NULL, ...,
ndata = NULL, drop = TRUE)
## S3 method for class 'mleBb'
simulate(object, nsim = 1, seed = NULL, ...,
ndata = NULL, drop = TRUE)
## S3 method for class 'Dbdpars'
simulate(object, nsim = 1, seed = NULL, ...,
ndata = NULL, drop = TRUE)
## S3 method for class 'Dbdpars'
simulate(object, nsim = 1, seed = NULL, ...,
ndata = NULL, drop = TRUE)
Arguments
object |
An object of class |
nsim |
The number of data sets to simulate. |
seed |
Integer vector of seeds for random number generation. It should
be of length either 1 or |
... |
Not used. |
ndata |
Integer vector specifying the lengths of the data sets to
be simulated. If it is of length less than |
drop |
Logical scalar; if |
Details
The actual simulation is done by rdb()
or by the
rbetabinom()
function from the rmutil
package.
Value
A list, of length nsim
, whose entries are integer
vectors, the length of of the i
th entry being equal to
ndata[i]
. Each entry has an attribute "seed"
which
is the random number generation seed that was used in the generation
of the data in that entry. If nsim==1
and if drop
is
TRUE
, then the value is simply an integer vector
(of length ndata[1]
).
See Also
Examples
X <- hmm.discnp::Downloads
fit <- mleDb(X,ntop=15,zeta=TRUE)
s1 <- simulate(fit)
s2 <- simulate(fit,nsim=5) # All data sets of length 267.
s3 <- simulate(fit,nsim=5,ndata=100*(2:6))
obj <- makeDbdpars(alpha=2,beta=3,ntop=20,zeta=TRUE,ndata=500)
s4 <- simulate(obj,nsim=5,seed=1:5)