-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add the exp(cubic spline) function to the deterministic model? #205
Comments
That's something that is quite easily accomplished. As the help page ( Keep in mind that C has syntax that is different from that of R. In particular, your R-style call to
Try your hand at using the An alternative approach, which may prove faster, is to define the B-spline basis as a matrix using a call to |
Very emotional your reply, I tried to build the following simple model, but encountered a problem in estimating parameters with maximum likelihood, I don't know if it is a problem with my model or a problem with the optimization function optim, thank you again!
|
And I can't use bspline_eval function in a C fragment, only periodic_bspline_basis_eval function, I don't understand what the reason is. |
I'm not sure what the precise problem was, since you included no error message, but I can see that you are not accessing the seasonality covariates you defined. The array Before posting, please read FAQ 1.1. Also, note that I have edited your code for clarity. Finally, I see that you are constructing an objective function for trajectory matching. Why not use pomp's facility for this, |
Thank you very much for your guidance, but when I use the function bspline_eval, the program reports an error, but when I use the function periodic_bspline_basis_eval, the program can run and get the result, the code is as follows:
But my goal is to use a cubic spline function to construct the infectious term beta in the model, and then calculate beta through parameter estimation. There is no need for periodic spline functions to construct. I have reviewed the file you recommended, but only have examples of periodic spline basis functions. I am not sure which function to use to find a simple cubic spline basis function. Could you please give me a simple example? |
Why not follow my advice (as I gave you above) and construct the bsplines using If you want to access the I don't know why the issue of periodic splines is entering into your thinking. I did not mention anything about them in my last reply and I understand that you want ordinary (non-periodic) splines. |
Thank you very much for your suggestion, I have successfully solved the problem. At the same time, I have the following small question:
Looking forward to your response |
After building an exp(spline) beta model, I had some problems with parameter estimation. The following code works and the fit works fine,
but when I set gamma to 0.2, S to 49999 and estimate the other parameters, I get the following error. I just changed the values of two parameters, and the result was that I didn't get the correct result and got a warning message. I don't understand what is the reason for this, is it because after changing the parameters, the integrator does not work? And when using traj_objfun functions to make estimates, the following problems will also be encountered.
|
With respect to the questions you ask above,
It might be possible, but this is not the case for which the algorithm is best suited. When the latent state process is deterministic, I recommend you use trajectory matching, via the
In principle, the answer is "yes". Note that the goal of an rprocess C snippet is different from that of a skeleton C snippet. Read the manual for details. Now for the more recent questions. Before addressing the issue you ran into, note that you can streamline your workflow quite a bit (and eliminate sources of common errors) by using
Now we fit to the data.
With fixed
Note that the issue you encountered no longer appears. The warnings you were seeing were generated by the ODE integrator. Presumably, the problem was due to inadmissible values in your parameters or initial conditions. These in turn were probably due to the inappropriate parameter transformations you were applying. |
Thank you very much for your reply and the code modification. After successfully estimating the parameters b0-b8, I tried to visualize beta(t), but I found that R0=beta/gamma is always less than 1, is this phenomenon reasonable?
|
How are you computing I am closing this issue now. Feel free to reopen if you have more issues with pomp, or to move to the Discussions forum. |
I have encountered some problems again. When I use pomp to build a stochastic model to simulate the COVID-19 epidemic, no matter how I change the model parameters, the following error is reported in pfilter:
The error is as follows, but I am not sure why the value of state S is NA. Is it a problem with the model parameter settings or the transition probability between models.
|
Thanks for providing sufficiently so that I can easily reproduce the problem. Notice that something is already not right in the
I looked into it a little. Examine the following code. It prints the values of the
Observe that I also changed the code in two places to (1) eliminate a needless |
I am closing this issue now. Feel free to reopen if more discussion is warranted. |
Dear Professor, I'm a big fan of pomp. I want to add the time-varying function beta=exp(cubic spline) to a simple deterministic SIR model, I tried many times but failed, I would like to ask for your help. Can you give me some advice or give me a simple example?
The text was updated successfully, but these errors were encountered: