simulate.moment {symmoments} | R Documentation |
Method to compute a multivariate moment using Monte Carlo integration
Description
Computes a multivariate normal moment by Monte Carlo integration
Usage
## S3 method for class 'moment'
simulate(object,nsim,seed,Mean,Sigma,...)
Arguments
object |
object of class 'moment' representing E[X1**k1,...,Xn**kn] |
nsim |
the number of samples to generate in computing the integral |
seed |
integer for random number generator (set.seed) |
Mean |
the mean of (X1,...,Xn) |
Sigma |
covariance of (X1**k1,...,Xn**kn), dimension nXn, expressed as a vector by row |
... |
Included only for consistency with generic function |
Value
Approximate value of the moment
Note
Non-central moments can be approximated by specifying Mean. For central moments, set Mean to a vector of 0s.
The mvtnorm package must be loaded for the function rmvnorm.
Author(s)
Kem Phillips <kemphillips@comcast.net>
References
Rizzo ML (2008). Statistical Computing with R. Chapman & Hall/CRC
See Also
callmultmoments and the methods toLatex and evaluate from symmoments
Examples
# Using 10000 samples, estimate the central moment for the moment c(2,4) at the covariance matrix
# 2 1
# 1 4
# and mean (0,0)
library(mvtnorm)
simulate(callmultmoments(c(2,4)),10000,NULL,c(0,0),c(2,1,1,4))