how to calculate transition probability matrix in rats
how to calculate transition probability matrix in rats
hi Tom,
I have dummy variables for both economic recessions and expansion in the U.S. for 30 years. I could like to calculate the transition probability matrix but I do not know how to do it in rats. Could you please kindly let me know what instructions I should use?
I have dummy variables for both economic recessions and expansion in the U.S. for 30 years. I could like to calculate the transition probability matrix but I do not know how to do it in rats. Could you please kindly let me know what instructions I should use?
Re: how to calculate transition probability matrix in rats
Use SSTATS. For instance
sstats(smpl=recession{1},mean) / recession>>prr .not.recession>>prx
sstats(smpl=.not.recession{1},mean) / recession>>pxr .not.recession>>pxx
Equivalently, you can use SSTATS across the whole data range (i.e. no SMPL option) and count all four combinations of recession vs .not.recession .AND. with recession{1} vs .not.recession{1} and convert to probabilities within each lagged value.
sstats(smpl=recession{1},mean) / recession>>prr .not.recession>>prx
sstats(smpl=.not.recession{1},mean) / recession>>pxr .not.recession>>pxx
Equivalently, you can use SSTATS across the whole data range (i.e. no SMPL option) and count all four combinations of recession vs .not.recession .AND. with recession{1} vs .not.recession{1} and convert to probabilities within each lagged value.
Re: how to calculate transition probability matrix in rats
Thank you for the quick reply. I tried the suggested instructions but I could not see any output in rats. Is it because I missed something? By the way, if I would like to calculate the transition probability for different subsamples such as one for before 1970 and another for after 1970, can I still use smpl option? Thank you.TomDoan wrote:Use SSTATS. For instance
sstats(smpl=recession{1},mean) / recession>>prr .not.recession>>prx
sstats(smpl=.not.recession{1},mean) / recession>>pxr .not.recession>>pxx
Equivalently, you can use SSTATS across the whole data range (i.e. no SMPL option) and count all four combinations of recession vs .not.recession .AND. with recession{1} vs .not.recession{1} and convert to probabilities within each lagged value.
Re: how to calculate transition probability matrix in rats
That's correct. SSTATS does the "query" calculation, but what you do with the results is up to you. The probabilities are in the PRR, etc. variables. Yes. You can use either SMPL or the start and end parameters on SSTATS to restrict the range.
Re: how to calculate transition probability matrix in rats
thank you for the reply. Can I ask one more question? In additional to the economic conditions (recessions, expansions), I also have dummy variables for political regimes(Demos. and Reps.). I would like to know how I can calculate the transition probability based on those two conditional states (economic state and political state) in rats. What instructions I should use? Many ThanksTomDoan wrote:That's correct. SSTATS does the "query" calculation, but what you do with the results is up to you. The probabilities are in the PRR, etc. variables. Yes. You can use either SMPL or the start and end parameters on SSTATS to restrict the range.
Re: how to calculate transition probability matrix in rats
Just add clauses to the SMPL to restrict to the subsample that you want.
Re: how to calculate transition probability matrix in rats
Thank you for the reply. I tried to add clauses to the smpl but always got error messages. Could you please kindly look at my code and point out my mistake?TomDoan wrote:Just add clauses to the SMPL to restrict to the subsample that you want.
Code: Select all
sstats(smpl=contraction{1},mean) (smpl=demo{1},mean) / contraction>>prr .not.contraction>>prx .not.demo>>pdr
Re: how to calculate transition probability matrix in rats
sstats(smpl=contraction{1}.and.demo{1},mean) / contraction>>prr .not.contraction>>prx .not.demo>>pdr
However, you might not want to convert those to means, as that will eliminate the information about the total number of items. You're better off populating a table of the four by four transition counts and adding them up and dividing later to get the various probabilities.
However, you might not want to convert those to means, as that will eliminate the information about the total number of items. You're better off populating a table of the four by four transition counts and adding them up and dividing later to get the various probabilities.
Re: how to calculate transition probability matrix in rats
HI, Tom. Thank you for the suggestion. To get the transition counts, I should use the following instructions:TomDoan wrote:sstats(smpl=contraction{1}.and.demo{1},mean) / contraction>>prr .not.contraction>>prx .not.demo>>pdr
However, you might not want to convert those to means, as that will eliminate the information about the total number of items. You're better off populating a table of the four by four transition counts and adding them up and dividing later to get the various probabilities.
Code: Select all
sstats(smpl=contraction{1}.and.demo{1}) / contraction.and.demo>>pdrrd .not.contraction.and.demo>>pdrxd contraction.and..not.demo>>pdrrr .not.contraction.and..not.demo>>pdrxr
sstats(smpl=.not.contraction{1}.and.demo{1}) / contraction.and.demo>>pdxrd .not.contraction.and.demo>>pdxxd contraction.and..not.demo>>pdxrr .not.contraction.and..not.demo>>pdxxr
sstats(smpl=contraction{1}.and..not.demo{1}) / contraction.and.demo>>prrrd .not.contraction.and.demo>>prxrd contraction.and..not.demo>>prrrr .not.contraction.and..not.demo>>prrxr
sstats(smpl=.not.contraction{1}.and..not.demo{1}) / contraction.and.demo>>prxrd .not.contraction.and.demo>>prxxd contraction.and..not.demo>>prxrr .not.contraction.and..not.demo>>prxxr
add up all the transition accounts to get the total transition accounts and dividing the total transition accounts for the probabilities.
Please kindly let me know whether my understanding is correct or not.
Last edited by fan on Thu Sep 03, 2015 11:20 pm, edited 1 time in total.
Re: how to calculate transition probability matrix in rats
Except for the missing SSTATS instruction names, that looks correct.
Re: how to calculate transition probability matrix in rats
Thank you so much for the quick replyTomDoan wrote:Except for the missing SSTATS instruction names, that looks correct.
Re: how to calculate transition probability matrix in rats
Hi Tom, How can I estimate the transition probability of the political regime switch by using the Hamilton method? Particularly, I am interested in knowing transition probability after the president served his first term and second term individually. Many ThanksTomDoan wrote:Except for the missing SSTATS instruction names, that looks correct.
Re: how to calculate transition probability matrix in rats
Transition probablity of what? All the examples you've had above have been transition probabilities between observable regimes. The Hamilton model is for hidden state models.fan wrote: Hi Tom, How can I estimate the transition probability of the political regime switch by using the Hamilton method? Particularly, I am interested in knowing transition probability after the president served his first term and second term individually. Many Thanks
Re: how to calculate transition probability matrix in rats
Hi, Tom. Thanks for the quick reply. My question actually is that given the initial condition such as the president is democratic and serving his first term, which is the probability the new president will be from the same party before knowing the election result?TomDoan wrote:Transition probablity of what? All the examples you've had above have been transition probabilities between observable regimes. The Hamilton model is for hidden state models.fan wrote: Hi Tom, How can I estimate the transition probability of the political regime switch by using the Hamilton method? Particularly, I am interested in knowing transition probability after the president served his first term and second term individually. Many Thanks
Re: how to calculate transition probability matrix in rats
Using what information? In the post-war period, you only have Truman, Johnson(?), Carter, Clinton, Obama. Depending upon whether you count Johnson, it's either 3/4 or 4/5. There is a literature that predicts results based upon economic trends, and it probably gets it right about as often as a coin flip.