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 ppi_paramvec

AL

Either NULL, a p-1 x p-1 symmetric matrix, a number, or "diag". If NULL then all A_L elements will be set to NA. If a single number, then A_L will be fixed as a matrix of the given value. If "diag" then the non-diagonal elements of A_L will be fixed to 0, and the diagonal will be NA.

bL

Either NULL, a number, or a vector of length p-1. If NULL, then all elements of b_L will be set to NA. If a single number, then b_L will be fixed at the supplied value.

beta

Either NULL, a number, or a vector of length p. If NULL then all elements of \beta will be set to NA. If a single number then the \beta elements will be fixed at the given number.

betaL

Either NULL, a number, or a vector of length p-1. If NULL then the 1...(p-1)th \beta elements will be set to NA. If a single number then the 1...(p-1)th \beta elements will be fixed at the given number.

betap

Either NULL or a number. If NULL then the pth element of \beta will be set to NA, and ppi() will estimate it. If a number, then the pth element of \beta will be fixed at the given value.

p

The number of components. If NULL then p will be inferred from other inputs.

Astar

The A^* matrix (a p by p symmetric matrix)

paramvec

The PPI parameter vector, created easily using ppi_paramvec() and also returned by ppi(). Use paramvec instead of ....

maxden

This is the constant log(C) in (Appendix A.1.3 Scealy and Wood 2023).

maxmemorysize

Advanced use. The maximum size, in bytes, for matrices containing simulated Dirchlet samples. The default of 1E5 corresponds to 100 mega bytes.

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:

Functions

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)

[Package scorematchingad version 0.0.67 Index]