Learn R Programming

scorematchingad (version 0.1.1)

rppi: 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)

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:

  • sample A matrix of the simulated samples (n rows)

  • p The number of components of the model

  • theta The PPI parameter vector

  • AL The \(A_L\) parameter matrix

  • bL The \(b_L\) parameter vector

  • beta The \(\beta\) parameter vector

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 @scealy2023scscorematchingad.

maxmemorysize

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

Functions

  • rppi_egmodel(): Simulates the 3-component PPI model from @Section 2.3, @scealy2023scscorematchingad and returns both simulations and model parameters.

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 @scealy2023scscorematchingad. 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.

References

See Also

Other PPI model tools: dppi(), ppi(), ppi_param_tools, ppi_robust()

Examples

Run this code
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)

Run the code above in your browser using DataLab