-
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
Trajectory Fitting issue #149
Comments
The workflow as of pomp version 2 is to construct an objective function that is then optimized using any general-purpose optimization tool. The optimization function created is stateful in that it remembers the point at which it was last evaluated. For example, the following fits four parameters from an SIR model to simulated data (the model and data are those from the example included in the package).
The chunk beginning with |
I've tried to streamline your code down to focus on the essentials. Since you are doing trajectory matching, your
Note that the
I am not sure where the warnings are coming from. You are postulating a Poisson measurement model: are the data all integers, as this model assumes? If not, this may be your problem. If they are, then perhaps you can include the data ( |
One thing does occur to me: you define
which ensures that these state variables do not change their values. More elegantly (and efficiently), you could make these three quantities into model parameters (or globals, using the |
Your responses have been very helpful! I have the model working! Another issue has arisen though. So far I have been fitting to data capturing Vs and Vb over time (measured daily). However, I also have data capturing T, but this is not measured as often (every 4 days). Is there a way to include all the data when doing the fitting? I tried to follow what was written in https://kingaa.github.io/pomp/FAQ.html under the heading "3.3 How do I deal with missing data?", but this doesn't seem to work. This is how I rewrote dmeasure:
It seems like since there are NAs in some of the N_T data, it ignores N_T entirely. I've attached an example of what the data looks like. |
I don't immediately see anything wrong with your code. Do you see error messages? On what basis do you conclude that |
I also note that your data variables |
Yes, you are right that N_Vs and N_Vb are not integers. We are infecting mice with a luciferase-tagged virus that emits light, and putting these mice in a bioimager. The values represent the amount of light emitted by the virus in units of photons/s. For simplicity, I'm assuming that each virus emits 1 photon/s. There is also some background signal in this measurement which I am also trying to account for. Perhaps a gamma distribution would be better. I've definitely been having some issues with writing an appropriate dmeasure and rmeasure. N_T represents CD8 T cell amounts. I think the issue I was having with fitting is not only due to perhaps a poorly written dmeasure expression, but also due to the fact that the values of N_Vs/N_Vb and N_T are on vastly different scales. Because the viral load measures are so large, it leads to large errors between the data and model-predicted values that outweigh any error related to T cells. As a result, the model fits the viral data well, and the T cell data poorly. Could this be what's happening? |
The Poisson is a discrete distribution: It is defined only on the non-negative integers. I think it would be wise were you to give some more thought to the measurement model. For example: what are the errors you expect to see on these measurements? Do you think the error is better conceived of as additive or multiplicative?
The weight given to each distinct data stream is a function of the distribution of errors. If you are assuming that the error on the fluorescence values is small or large, then these will be given heavy or light weights, respectively. In other words, it is not the magnitudes per se but the scaling of the error relative to this magnitude (e.g., the coefficient of variation) that determines the relative weighting of the data streams.
It might, but I have no way of answering this question without more information from you. |
I'm closing this issue now, but feel free to re-open if more discussion is warranted. |
Hello,
I am trying to work through a pomp model vignette that involves fitting ecological data to a system of ODEs.
#51
I'm really struggling with the trajectory matching part as the function traj.match that is used in this model I believe is depreciated. In the example I'm referring to, the code is:
How should this be written now? I think the function is now traj_objfun(), but I can't get it to work. Any help would be greatly appreciated!
Thanks
The text was updated successfully, but these errors were encountered: