Learn R Programming

cTMed (version 1.0.4)

Trajectory: Simulate Trajectories of Variables

Description

This function simulates trajectories of variables without measurement error or process noise. Total corresponds to the total effect and Direct corresponds to the portion of the total effect where the indirect effect is removed.

Usage

Trajectory(mu0, time, phi, med)

Value

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

call

Function call.

args

Function arguments.

fun

Function used ("Trajectory").

output

A data frame of simulated data.

Arguments

mu0

Numeric vector. Initial values of the variables.

time

Positive integer. Number of time points.

phi

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

med

Character vector. Name/s of the mediator variable/s in phi.

See Also

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

Examples

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

traj <- Trajectory(
  mu0 = c(3, 3, -3),
  time = 150,
  phi = phi,
  med = "m"
)
plot(traj)

# Methods -------------------------------------------------------------------
# Trajectory has a number of methods including
# print, summary, and plot

traj <- Trajectory(
  mu0 = c(3, 3, -3),
  time = 25,
  phi = phi,
  med = "m"
)
print(traj)
summary(traj)
plot(traj)

Run the code above in your browser using DataLab