kingaa / pomp

R package for statistical inference using partially observed Markov processes
https://kingaa.github.io/pomp
GNU General Public License v3.0
114 stars 27 forks source link

manual on rw.sd schedule #121

Closed bogaotory closed 4 years ago

bogaotory commented 4 years ago

https://github.com/kingaa/pomp/blob/344ecc2230eff9722cb6fe905a6ed77a9045ec05/manual/mif2.html#L207-L211

I wonder if there are a couple of typos here for b and d the correct versions should be:

b=ifelse(time>=time[1], 0.2,0),
d=ifelse(time>=time[13],0.2,0),

Also, I wonder if there is a way to extract the parameter value over time in the last iteration? Similar to the way eff.sample size and cond.logLik can be applied to mif2 to get trace of the last iteration for the diagnostics plot. Thank you

kingaa commented 4 years ago

Not sure why you think there's a typo. The code matches the text description, no?

You get the parameter value at the last mif2 iteration using coef.

bogaotory commented 4 years ago

For b, firstly I'm not quite sure if b=ifelse(0.2, time==time[1], 0) is a correct ifelse expression? Secondly, in the text b and c are equivalent as in "parameter b and c both get perturbations of s.d. 0.2 only before the first observation". Therefore I think the correct expression is b=ifelse(time<=time[1], 0.2, 0) (small correction from my first message)

For d, I actually think the text is wrong too because you have e=ivp(0.2, lag=13) which syntax-wise has no error. But that means for e the first 13 observations had no perturbation. This contradicts your text which says "Parameters d and e, by contrast, get perturbations of s.d. 0.2 only before the thirteenth observation." What I think you meant is that the perturbation of s.d. 0.2 start only after the thirteenth observation. Which leads me to think that the correct expression for d is d=ifelse(time>=time[13], 0.2,0)

coef gives the values at the end of the iteration. I wondered if there is a way to extract the time series like those in the diagnostics plots? But I can use print to get around this for debugging purposes.

kingaa commented 4 years ago

@bogaotory:

For b, firstly I'm not quite sure if b=ifelse(0.2, time==time[1], 0) is a correct ifelse expression?

Whoops, yes, you are right.

Secondly, in the text b and c are equivalent as in "parameter b and c both get perturbations of s.d. 0.2 only before the first observation". Therefore I think the correct expression is b=ifelse(time<=time[1], 0.2, 0) (small correction from my first message)

Perhaps I should say "only just before".

For d, I actually think the text is wrong too because you have e=ivp(0.2, lag=13) which syntax-wise has no error. But that means for e the first 13 observations had no perturbation. This contradicts your text which says "Parameters d and e, by contrast, get perturbations of s.d. 0.2 only before the thirteenth observation." What I think you meant is that the perturbation of s.d. 0.2 start only after the thirteenth observation. Which leads me to think that the correct expression for d is d=ifelse(time>=time[13], 0.2,0)

You misunderstand: ivp(0.2,lag=13) causes the perturbation to be applied only once, just before the observation at time[13]. If you wanted perturbations to begin at that time and continue afterward, your expression would do that.

coef gives the values at the end of the iteration. I wondered if there is a way to extract the time series like those in the diagnostics plots? But I can use print to get around this for debugging purposes.

Yes. Use traces. This gives particle movements against IF2 iteration.

If you want the particles' movements against time, I don't think there is currently a way of doing that.

bogaotory commented 4 years ago

For d, I actually think the text is wrong too because you have e=ivp(0.2, lag=13) which syntax-wise has no error. But that means for e the first 13 observations had no perturbation. This contradicts your text which says "Parameters d and e, by contrast, get perturbations of s.d. 0.2 only before the thirteenth observation." What I think you meant is that the perturbation of s.d. 0.2 start only after the thirteenth observation. Which leads me to think that the correct expression for d is d=ifelse(time>=time[13], 0.2,0)

You misunderstand: ivp(0.2,lag=13) causes the perturbation to be applied only once, just before the observation at time[13]. If you wanted perturbations to begin at that time and continue afterward, your expression would do that.

Ah, I see. That makes sense since ivp(0) simply keeps the parameter at the initial guess. Somehow I didn't make that connection in my head. Great, thanks very much for your help!

kingaa commented 4 years ago

And thanks for reporting the typo. It's fixed in the release going out in a few minutes.