helske / bssm

Bayesian Inference of State Space Models
42 stars 14 forks source link

Mat::init(): size is fixed and hence cannot be changed #35

Open Lxr-China opened 3 weeks ago

Lxr-China commented 3 weeks ago

image

Lxr-China commented 3 weeks ago

Hello, I intend to construct a nonlinear state space model using the BSSM package. N represents the number of economies, with the state vector having 11N dimensions and the observable vector having 2N dimensions. I have written C++ functions for Z, T, H, R, etc., based on the vignette template. However, the model encounters errors during the final runtime, as depicted in the figure. What should I do next? Thank you for your assistance.

Lxr-China commented 3 weeks ago

ssm.zip My CPP document and R script are both included in this compressed file.

helske commented 3 weeks ago

It sounds like one of your C++ functions tries to modify the size of the model matrices. Maybe try calling those C++ functions like H_fn separately from R with properly sized inputs and see which one causes the error, and then debug inside the function by adding some Rcout calls to spot the exact line.

Lxr-China commented 1 week ago

Thank you very much for your reply, which has provided me with insights into solving the problem. I wish you success in your work and happiness in your life.