Open chriscmr opened 2 months ago
The following could be issues with your model.
// Initial conditions for state and latent using the mean and variance of 'x'
init_shk <- prep.initial(
values.inistate = c(mean_x), # Mean as starting value
params.inistate = c('mu_1'),
values.inicov = matrix(c(var_x*), ncol = 1, byrow = TRUE), # Variance as initial covariance
params.inicov = matrix(c('c_11'), ncol = 1, byrow = TRUE)
)
The above code freely estimates the initial mean and variance. For single-subject data, these parameters are not identified. You cannot estimate them for single-subject data. For multi-subject data you can estimate them. A typical solution for single-subject data is to have a fixed initial mean of zero and a fixed initial variance of some reasonably large value (i.e., diffuse initial conditions).
// Dynamics preparation
dynm_shk <- prep.matrixDynamics(
values.dyn = matrix(c(1), ncol = 1, byrow = TRUE), # Transition matrix
params.dyn = matrix(c('b_11'), ncol = 1, byrow = TRUE),
isContinuousTime = FALSE
)
The above code starts the autoregressive dynamics at the boundary of stability. The AR coefficient is 1.0 (i.e. a random walk). This is usually a bad spot to start your parameter optimization. I suggest an AR starting value in the range of -.3 to +.3.
I'd also recommend setting lower and upper bounds on most of your free parameters.
Finally for dynr.taste
, if the initial model does not yield reasonable parameter estimates and standard errors, then I would not proceed with dynr.taste
. I'm not sure what exactly is causing your errors, but the warnings are because the standard errors are all messed up.
Good day. I am working on a model using the dynr package and encountering several issues related to NaNs being produced during the fitting process. Below is the code I am using, along with the warnings and errors I keep encountering.
When running the above code, I consistently receive the following warning messages:
I proceed with the second part of the analysis, which involves computing shocks and chi-square using dynr.taste, followed by re-fitting the state-space model using dynr.taste2.
When I run this second part, I get the following warning and error messages:
What I Have Tried: