Description
Hello,
I have been using and modifying the mlVARsim()
function for a simulation study and want to make some minor suggestions for improvement.
Random Effects Standard Deviation
The following line code currently creates the SD for the Omega matrix:
SD <- runif(nNode + nTemporal,
c(rep(mu_SD[1],nNode),rep(init_beta_SD[1],nNode)),
c(rep(mu_SD[2],nNode),rep(init_beta_SD[2],nNode)))
If I’m not mistaken, nNode
should be replaced with nTemporal
for the init_beta_SD
, as these are the random effects for the temporal parameters:
SD <- runif(nNode + nTemporal,
c(rep(mu_SD[1],nNode),rep(init_beta_SD[1],nTemporal)),
c(rep(mu_SD[2],nNode),rep(init_beta_SD[2],nTemporal)))
The current code therefore alternates between using the mu_SD
and init_beta_SD
to create the random effects SD, which seems incorrect. This can also be seen in example output of mlVARsim()
, where every second column has a different SD:
set.seed(2024)
library(mlVAR)
sim <- mlVARsim(
nPerson = 100,
nNode = 4,
nTime = 100,
init_beta_SD = c(2, 2)
)
sim$model$Beta$SD[,,1]
[,1] [,2] [,3] [,4]
[1,] 0.2431533 0.1215767 0.2431533 0.1215767
[2,] 0.2431533 0.1215767 0.2431533 0.1215767
[3,] 0.2431533 0.1215767 0.2431533 0.1215767
[4,] 0.2431533 0.1215767 0.2431533 0.1215767
Minor Additional Suggestions
Currently, the sparsity of the temporal and contemporaneous networks is fixed to .5, and the SD of the fixed temporal effects is fixed to 1. For simulation purposes, letting the user modify these arguments (with defaults set to the current fixed values) could be helpful.
I’d be happy to prepare a pull request to implement these changes if you find them useful. Thank you for your work on this very useful package!