MCPhiSigma {cTMed}R Documentation

Generate Random Drift Matrices and Process Noise Covariance Matrices Using the Monte Carlo Method

Description

This function generates random drift matrices \boldsymbol{\Phi} and process noise covariabces matrices \boldsymbol{\Sigma} using the Monte Carlo method.

Usage

MCPhiSigma(
  phi,
  sigma,
  vcov_theta,
  R,
  test_phi = TRUE,
  ncores = NULL,
  seed = NULL
)

Arguments

phi

Numeric matrix. The drift matrix (\boldsymbol{\Phi}). phi should have row and column names pertaining to the variables in the system.

sigma

Numeric matrix. The process noise covariance matrix (\boldsymbol{\Sigma}).

vcov_theta

Numeric matrix. The sampling variance-covariance matrix of \mathrm{vec} \left( \boldsymbol{\Phi} \right) and \mathrm{vech} \left( \boldsymbol{\Sigma} \right)

R

Positive integer. Number of replications.

test_phi

Logical. If test_phi = TRUE, the function tests the stability of the generated drift matrix \boldsymbol{\Phi}. If the test returns FALSE, the function generates a new drift matrix \boldsymbol{\Phi} and runs the test recursively until the test returns TRUE.

ncores

Positive integer. Number of cores to use. If ncores = NULL, use a single core. Consider using multiple cores when number of replications R is a large value.

seed

Random seed.

Details

Monte Carlo Method

Let \boldsymbol{\theta} be a vector that combines \mathrm{vec} \left( \boldsymbol{\Phi} \right), that is, the elements of the \boldsymbol{\Phi} matrix in vector form sorted column-wise and \mathrm{vech} \left( \boldsymbol{\Sigma} \right), that is, the unique elements of the \boldsymbol{\Sigma} matrix in vector form sorted column-wise. Let \hat{\boldsymbol{\theta}} be a vector that combines \mathrm{vec} \left( \hat{\boldsymbol{\Phi}} \right) and \mathrm{vech} \left( \hat{\boldsymbol{\Sigma}} \right). Based on the asymptotic properties of maximum likelihood estimators, we can assume that estimators are normally distributed around the population parameters.

\hat{\boldsymbol{\theta}} \sim \mathcal{N} \left( \boldsymbol{\theta}, \mathbb{V} \left( \hat{\boldsymbol{\theta}} \right) \right)

Using this distributional assumption, a sampling distribution of \hat{\boldsymbol{\theta}} which we refer to as \hat{\boldsymbol{\theta}}^{\ast} can be generated by replacing the population parameters with sample estimates, that is,

\hat{\boldsymbol{\theta}}^{\ast} \sim \mathcal{N} \left( \hat{\boldsymbol{\theta}}, \hat{\mathbb{V}} \left( \hat{\boldsymbol{\theta}} \right) \right) .

Value

Returns an object of class ctmedmc which is a list with the following elements:

call

Function call.

args

Function arguments.

fun

Function used ("MCPhiSigma").

output

A list simulated drift matrices.

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Continuous Time Mediation Functions: BootBeta(), BootBetaStd(), BootIndirectCentral(), BootMed(), BootMedStd(), BootTotalCentral(), DeltaBeta(), DeltaBetaStd(), DeltaIndirectCentral(), DeltaMed(), DeltaMedStd(), DeltaTotalCentral(), Direct(), DirectStd(), Indirect(), IndirectCentral(), IndirectStd(), MCBeta(), MCBetaStd(), MCIndirectCentral(), MCMed(), MCMedStd(), MCPhi(), MCTotalCentral(), Med(), MedStd(), PosteriorBeta(), PosteriorIndirectCentral(), PosteriorMed(), PosteriorTotalCentral(), Total(), TotalCentral(), TotalStd(), Trajectory()

Examples

set.seed(42)
phi <- matrix(
  data = c(
    -0.357, 0.771, -0.450,
    0.0, -0.511, 0.729,
    0, 0, -0.693
  ),
  nrow = 3
)
colnames(phi) <- rownames(phi) <- c("x", "m", "y")
sigma <- matrix(
  data = c(
    0.24455556, 0.02201587, -0.05004762,
    0.02201587, 0.07067800, 0.01539456,
    -0.05004762, 0.01539456, 0.07553061
  ),
  nrow = 3
)
MCPhiSigma(
  phi = phi,
  sigma = sigma,
  vcov_theta = 0.1 * diag(15),
  R = 100L # use a large value for R in actual research
)


[Package cTMed version 1.0.6 Index]