Joint transition probability
Re: Joint transition probability
Everything's observable. For each combination, just count up R(t),S(t),R(t-1),S(t-1) and divide by the number of R(t-1),S(t-1).
Re: Joint transition probability
Hi Tom,
I have an unrelated question would like to ask. I am trying to generate yearly recession dummy from 1875 to 2010 by using @nbercycles(downs=recession). However, I found that the generated recession dummy misses the period depression (1929-1939) and some other recession periods. I am not sure why this is thew case. Could you please kindly help me find out what went wrong? Thank you in advance
I have an unrelated question would like to ask. I am trying to generate yearly recession dummy from 1875 to 2010 by using @nbercycles(downs=recession). However, I found that the generated recession dummy misses the period depression (1929-1939) and some other recession periods. I am not sure why this is thew case. Could you please kindly help me find out what went wrong? Thank you in advance
Code: Select all
OPEN DATA "C:\Users\Sam\Desktop\condition prob yearly.xlsx"
CALENDAR(A) 1875:1
DATA(FORMAT=XLSX,ORG=COLUMNS) 1875:01 2010:01 year yearofpres afterelec elec dem rep
@nbercycles(downs=recession)
print / recession
Re: Joint transition probability
The NBER cycle dating doesn't go down to annual data. They give months and quarters. (Some recessions are over within a year).
Re: Joint transition probability
Thank you for the explanation. I am tryingto estimate the transition matrix and I am facing a error message "## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points" . I am not sure what caused the error. So I am seeking for you help. The following is my primitive codeTomDoan wrote:The NBER cycle dating doesn't go down to annual data. They give months and quarters. (Some recessions are over within a year).
Code: Select all
nonlin p11 p12 p13 p14 p21 p22 p23 p24 p31 p32 p33 p34 p41 p42 p43 p44 $
p11.ge.0. p12.ge.0. p13.ge.0. p11+p12+p13+p14==1.0 $
p21.ge.0. p22.ge.0. p23.ge.0. p21+p22+p23+p24==1.0 $
p31.ge.0. p32.ge.0. p33.ge.0. p31+p32+p33+p34==1.0 $
p41.ge.0. p42.ge.0. p43.ge.0. p41+p42+p43+p44==1.0
frml l = s1{1}*log(p11)*s1+s1{1}*log(p12)*s2+s1{1}*log(p13)*s3+s1{1}*log(p14)*s4 $
+s2{1}*log(p21)*s1+s2{1}*log(p22)*s2+s2{1}*log(p23)*s3+s2{1}*log(p24)*s4 $
+s3{1}*log(p31)*s1+s3{1}*log(p32)*s2+s3{1}*log(p33)*s3+s3{1}*log(p34)*s4 $
+s4{1}*log(p41)*s1+s4{1}*log(p42)*s2+s4{1}*log(p43)*s3+s4{1}*log(p44)*s4
compute p11=0.9, p12=0.08, p13=0.02, p14=0.0, p21=0.15, p22=0.78, p23=0.0, p24=0.07, $
p31=0.0, p32=0.0, p33=0.85, p34=0.15, p41=0.0, p42=0.03, p43=0.11, p44=0.86
max(method=simplex,iters=5) l 1875:02 1945:04
max(iters=200) l 1875:02 1945:04
In addition, I would like to know how I can estimate the ps by using P matrix and S vector directly in Rats.
Happy New Year!!!
- Attachments
-
- transition matrix.xlsx
- (31.71 KiB) Downloaded 780 times
-
- transition matrix.docx
- (15.08 KiB) Downloaded 736 times
Re: Joint transition probability
Your guess values have p14=0, so log(p14) is NA.
I don't understand why you don't compute those by counting up. You really can't use variational methods to estimate those probabilities since at least some of the combinations probably have 0 counts.
I have no idea what your last question means.
I don't understand why you don't compute those by counting up. You really can't use variational methods to estimate those probabilities since at least some of the combinations probably have 0 counts.
I have no idea what your last question means.
Re: Joint transition probability
Dear Tom, Thank you for your reply. The reason why I don't compute the transition probabilities by counting up is because that I would like to reduce the number of parameters to estimated. As you can see in the attached file, there are 16 parameters, ranging from Pd11,Pd01,Pr11,Pr00 to P11, P12 until P43, need to be estimated. As suggested by my professor, I would reduce the number of estimates based on certain assumptions. Such as, if the economic transition is assumed to independent from political transition, then I can set Pd11 = P11/(P11+P12), Pd01=P21/(P21+P22), Pr11=P33/(P33+P34), and Pr01=P43/(P43+P44).TomDoan wrote:Your guess values have p14=0, so log(p14) is NA.
I don't understand why you don't compute those by counting up. You really can't use variational methods to estimate those probabilities since at least some of the combinations probably have 0 counts.
I have no idea what your last question means.
In my case, the counts for S1, S2,S3, S4 are all greater than 0 counts. But, I do have 0 counts for combinations of S1,S2,S3,S4. For example, I have 0 counts for (S2,S1) for election period, in other words, P21 =0. Are you suggesting I can't use variational methods to estimate probabilities because of (S2,S1) have 0 counts?
P.S., I found that sstats can't use with %if function. Would you kindly suggest what Rats instruction I can use to obtain the transition from S1 to S2.
Finally, I would like to know how I can write the log likelihood function in Rats in terms of matrix and vector format, instead of in such form:
Code: Select all
frml l = s1{1}*log(p11)*s1+s1{1}*log(p12)*s2+s1{1}*log(p13)*s3+s1{1}*log(p14)*s4 $
+s2{1}*log(p21)*s1+s2{1}*log(p22)*s2+s2{1}*log(p23)*s3+s2{1}*log(p24)*s4 $
+s3{1}*log(p31)*s1+s3{1}*log(p32)*s2+s3{1}*log(p33)*s3+s3{1}*log(p34)*s4 $
+s4{1}*log(p41)*s1+s4{1}*log(p42)*s2+s4{1}*log(p43)*s3+s4{1}*log(p44)*s4
- Attachments
-
- transition matrix.docx
- (15.96 KiB) Downloaded 724 times
Re: Joint transition probability
Go back and look at https://estima.com/forum/viewtopic.php?p=13364#p13364. If the S transition doesn't depend upon R, the first factor collapses to just P(S(t)|S(t-1)). You can compute those probabilities (there are just two free ones) using all the data (doesn't matter whether it's an election or not, since R doesn't enter it). The second factor can be computed using the election years only.
SSTATS with %IF works fine if done correctly. Obviously, you're doing something wrong---perhaps you're not allowing for the fact that you don't have a lagged value for entry 1.
Variational methods will work even with some cells having 0 probability, but you can't start with a true 0 as 0 x log(0) produces NA, not 0. It will estimate it to some very small number. The estimated standard error on the 0 probability won't be correct since it's at a boundary.
Given that you already have the FRML written out, there's no real point to writing it in matrix form.
SSTATS with %IF works fine if done correctly. Obviously, you're doing something wrong---perhaps you're not allowing for the fact that you don't have a lagged value for entry 1.
Variational methods will work even with some cells having 0 probability, but you can't start with a true 0 as 0 x log(0) produces NA, not 0. It will estimate it to some very small number. The estimated standard error on the 0 probability won't be correct since it's at a boundary.
Given that you already have the FRML written out, there's no real point to writing it in matrix form.
Re: Joint transition probability
Thank you, Tom. I have a new question and I am seeking for your help. As you know that my S = (X, Y), I am wondering is it possible to express the transition of S in something like VAR structure of (X, Y)?TomDoan wrote:Go back and look at https://estima.com/forum/viewtopic.php?p=13364#p13364. If the S transition doesn't depend upon R, the first factor collapses to just P(S(t)|S(t-1)). You can compute those probabilities (there are just two free ones) using all the data (doesn't matter whether it's an election or not, since R doesn't enter it). The second factor can be computed using the election years only.
SSTATS with %IF works fine if done correctly. Obviously, you're doing something wrong---perhaps you're not allowing for the fact that you don't have a lagged value for entry 1.
Variational methods will work even with some cells having 0 probability, but you can't start with a true 0 as 0 x log(0) produces NA, not 0. It will estimate it to some very small number. The estimated standard error on the 0 probability won't be correct since it's at a boundary.
Given that you already have the FRML written out, there's no real point to writing it in matrix form.
Re: Joint transition probability
I have no idea what you mean. Those are all dummies. You have to have probability statements which is what the joint transition function is.