Closed audrey-b closed 5 years ago
How about we add an argument to sims called something like latent.
By default latent = FALSE and monitor only applies to data variables. If latent = TRUE then monitor only applies to latent variables and if latent = NA then monitor applies to both (the current behaviour)
What do you think?
Sounds great!
done
also I added stochastic = TRUE argument to control whether stochastic nodes monitored
When monitor=".*" is set in sims_simulate, both the data and the latent variables are saved but only the data can be taken as input for an analysis.
Example:
sims_simulate("Y ~ dnorm(N, 1) N ~ dnorm(mu, 1) mu ~ dnorm(0, 1)")
$N [1] -0.1351718
$Y [1] -0.1492502
$mu [1] -0.1449531
an nlists object of 100 nlist objects each with 3 natomic elements
Here, only Y is data, so the output of sims_simulate cannot be analysed directly. Instead, one needs to specify monitor="Y" manually, which could get cumbersome with many data variables.
It seems that it would be better to change the default value of monitor in sims_simulate to only keep the data. Nodes that are data can be identified by the fact that they are never used on the right hand side of a ~ or <-
I suggest adding a function to sims that would take code as input and output a list of
This way if for some reason someone is interested in the latent parameters, they can easily get the names of all such parameters and use them as monitor.