| rppi {scorematchingad} | R Documentation |
Simulate from a PPI Model
Description
Given parameters of the PPI model, generates independent samples.
Usage
rppi(n, ..., paramvec = NULL, maxden = 4, maxmemorysize = 1e+05)
rppi_egmodel(n, maxden = 4)
Arguments
n |
Number of samples to generate |
... |
Arguments passed on to
|
paramvec |
The PPI parameter vector, created easily using |
maxden |
This is the constant |
maxmemorysize |
Advanced use. The maximum size, in bytes, for matrices containing simulated Dirchlet samples. The default of |
Details
We recommend running rppi() a number of times to ensure the choice of maxden is good. rppi() will error when maxden is too low.
The simulation uses a rejection-sampling algorithm with Dirichlet proposal (Appendix A.1.3 Scealy and Wood 2023).
Initially n Dirichlet proposals are generated. After rejection there are fewer samples remaining, say n^*.
The ratio n^*/n is used to guess the number of new Dirichlet proposals to generate until n samples of the PPI model are reached.
Advanced use: The number of Dirichlet proposals created at a time is limited such that the matrices storing the Dirchlet proposals are always smaller than maxmemorysize bytes (give or take a few bytes for wrapping).
Larger maxmemorysize leads to faster simulation so long as maxmemorysize bytes are reliably contiguously available in RAM.
Value
A matrix with n rows and p columns. Each row is an independent draw from the specified PPI distribution.
rppi_egmodel returns a list:
-
sampleA matrix of the simulated samples (nrows) -
pThe number of components of the model -
thetaThe PPI parameter vector -
ALTheA_Lparameter matrix -
bLTheb_Lparameter vector -
betaThe\betaparameter vector
Functions
-
rppi_egmodel: Simulates the 3-component PPI model from (Section 2.3, Scealy and Wood 2023) and returns both simulations and model parameters.
References
Scealy JL, Wood ATA (2023). “Score matching for compositional distributions.” Journal of the American Statistical Association, 118(543), 1811–1823. doi:10.1080/01621459.2021.2016422.
See Also
Other PPI model tools:
dppi(),
ppi_param_tools,
ppi_robust(),
ppi()
Examples
beta0=c(-0.8, -0.8, -0.5)
AL = diag(nrow = 2)
bL = c(2, 3)
samp <- rppi(100,beta=beta0,AL=AL,bL=bL)
rppi_egmodel(1000)