I need to estimate equation (below) via ordered probit and cross-sectionally by fyear. And then, the highest fitted probability of each possible rating has to be generated.
Array
,where "i" is for firm and "t" is for fyear.
"CR" is the numerically transformed credit rating: dependent variable.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte ind int date_f long destr_gvkey int fyear float(IC Debt) byte CR 28 212 1078 2013 .19953124 6.858 17 28 213 1078 2013 .21894777 9.298006 17 28 214 1078 2013 .1949921 9.0503235 17 28 215 1078 2013 .18853165 6.224858 17 28 216 1078 2014 .16914694 8.147954 17 28 217 1078 2014 .17027125 6.1375 17 28 218 1078 2014 .11471515 8.325978 17 28 219 1078 2014 .10805573 6.100311 17 28 212 1209 2013 .031368762 10.418954 16 28 213 1209 2013 .023320094 10.00368 16 28 214 1209 2013 .02394333 10.273672 16 28 215 1209 2013 .02523235 9.781103 16 28 216 1209 2014 .02163526 10.29079 16 28 217 1209 2014 .01986862 10.333612 16 28 218 1209 2014 .018431772 9.45309 16 28 219 1209 2014 .01893234 8.553754 16 13 212 1380 2013 .010476887 4.198065 13 13 213 1380 2013 .017500242 3.5066504 13 13 214 1380 2013 .007661829 4.2382255 13 13 215 1380 2013 .04242878 5.580366 13 13 216 1380 2014 .031093087 3.666009 13 13 217 1380 2014 .05368752 4.610774 13 13 218 1380 2014 .10054912 4.098428 13 13 219 1380 2014 .06335217 5.056588 13 28 212 1602 2013 .4119094 13.890697 17 28 213 1602 2013 .4185136 12.276694 17 28 214 1602 2013 .3952482 13.42004 16 28 215 1602 2013 .29339886 17.1258 16 28 216 1602 2014 .29553458 16.157417 16 28 217 1602 2014 .3766215 13.760529 16 28 218 1602 2014 .3966796 14.376635 16 28 219 1602 2014 .3916301 13.602746 16 13 212 1678 2013 .0040134643 4.3254766 15 13 213 1678 2013 .002904499 4.4871793 15 13 214 1678 2013 .020767277 4.3473935 15 13 215 1678 2013 .030922985 4.3183837 15 13 216 1678 2014 .026881104 3.8941224 15 13 217 1678 2014 .021284595 4.1135206 15 13 218 1678 2014 .00957534 14.982167 15 13 219 1678 2014 .013743923 -7.952617 15 28 212 1794 2013 .03943116 16.838863 10 28 213 1794 2013 .03820096 13.19173 10 28 214 1794 2013 .03100584 14.02459 10 28 215 1794 2013 .02862343 4.942512 10 28 216 1794 2014 .02461821 15.459716 10 28 217 1794 2014 .04028553 21.612904 10 28 218 1794 2014 .04700643 12.70115 10 28 219 1794 2014 .127203 -61.88679 10 13 212 1860 2013 .033244185 9.227638 10 13 213 1860 2013 .03560679 7.853799 10 13 214 1860 2013 .06157583 9.488736 10 13 215 1860 2013 .02427223 8.02013 10 13 216 1860 2014 .032443028 12.039682 10 13 217 1860 2014 .014598052 13.51565 10 13 218 1860 2014 .029073395 11.47729 10 13 219 1860 2014 .017767018 9.906453 10 73 212 1878 2013 .486724 6.490861 13 73 213 1878 2013 .4730661 6.359761 13 73 214 1878 2013 .47680205 7.237634 13 73 215 1878 2013 .4933841 8.184211 13 73 216 1878 2014 .4559867 9.263027 13 73 217 1878 2014 .4053238 8.496018 13 73 218 1878 2014 .4014102 14.589844 13 73 219 1878 2014 .4123896 14.944 13 73 212 1891 2013 .03825292 1.044131 21 73 213 1891 2013 .0430483 .05906067 21 73 214 1891 2013 .04183358 .021473683 21 73 215 1891 2013 .05352345 .6868318 21 73 216 1891 2014 .057355 7.384876 21 73 217 1891 2014 .033651862 .02887921 19 73 218 1891 2014 .04628585 .018615386 19 73 219 1891 2014 .12529133 6.334492 19 13 212 1976 2013 .04054651 5.702127 16 13 213 1976 2013 .04106033 5.708139 16 13 214 1976 2013 .04872836 4.4941063 16 13 215 1976 2013 .05008234 4.2369437 16 13 216 1976 2014 .04301692 4.423379 16 13 217 1976 2014 .04112883 3.931838 16 13 218 1976 2014 .04221074 3.7146466 16 13 219 1976 2014 .06036008 2.830822 16 28 212 2086 2013 .1323457 6.405022 16 28 213 2086 2013 .2521578 9.295267 16 28 214 2086 2013 .094099 8.77638 16 28 215 2086 2013 .10564768 8.45572 16 28 216 2086 2014 .08111318 12.437768 15 28 217 2086 2014 .07280815 -25.546244 15 28 218 2086 2014 .08128937 35.646152 15 28 219 2086 2014 .11286028 42.88018 15 28 212 2316 2013 .11566952 39.87368 6 28 213 2316 2013 .09807305 38.60204 6 28 214 2316 2013 .10080414 36.757282 6 28 215 2316 2013 .13956735 51.69863 6 28 216 2316 2014 .072881356 35.66981 6 28 217 2316 2014 .04752137 34.648647 6 28 218 2316 2014 .04492395 34.232143 6 28 219 2316 2014 .066991016 -116.8 5 28 212 2403 2013 .070443295 8.055102 17 28 213 2403 2013 .07720953 6.823864 17 28 214 2403 2013 .07395935 6.233362 17 28 215 2403 2013 .11725228 6.609005 17 end format %tq date_f
What I coded so far is below; however, I couldn't go further than that.
Code:
forvalues j = 1/`=_N' { capture quietly { oprobit CR IC Debt if ind==ind[`j'] & fyear== fyear[`j'] predict p1 p2 p3 p4 in `j' } }
First, I got error message from the above code: "is not a valid command name"
Second, each industry-fyear has different outcomes.Code:. forvalues j = 1/`=_N' { 2. capture quietly { 3. oprobit CR IC Debt if ind==ind[`j'] & fyear== fyear[`j'] 4. predict p1 p2 p3 p4 in `j' 5. } 6. } is not a valid command name
For example, the combination of ind (13) and fyear (2013) has 4 outcomes: Pr (CR==10), Pr (CR==13), Pr (CR==15), and Pr (CR==16). These are outcomes that I individually execute the commands as follows:
However, if I have different industry and fyear, I have 6 different outcomes: Pr (CR==5), Pr (CR==6), Pr (CR==10), Pr (CR==15), Pr (CR==15), and Pr (CR==17)Code:oprobit CR IC Debt if ind==13 & fyear==2013 predict p1 p2 p3 p4
Code:oprobit CR IC Debt if ind==28 & fyear==2014 predict p1 p2 p3 p4 p5 p6
And, I believe this happens because the dependent variables are different in each industry-fyear.Third, based on the past study, I need to divide each probability by the frequency of that rating in the population.
I need help to write the code that generates the outcomes for each industry-fyear.
For example, if I run the following code:
Code:oprobit CR IC Debt if ind==13 & fyear==2013 predict p1 p2 p3 p4 if ind==13 & fyear==2013 tab CR
Hope what I wrote above makes sense to you all.
The outcomes will be: p1=Pr(CR==10), p2=Pr(CR==13), p3=Pr(CR==15), and p4=Pr(CR==16)
And, each Pr needs to be divided by the frequency of CR in the population.
new_p1=Pr(CR==10)/16
new_p2=Pr(CR==13)/16
new_p3=Pr(CR==15)/12
new_p4=Pr(CR==16)/26
Any help will be greatly appreciated.
Thanks a lot.
0 Response to Predict with oprobit: cross-section by fyear
Post a Comment