I am running a synthetic control analysis using the user-created "synth2" command. I am running a unit-level placebo test and want Stata to extract the p-value generated by this test automatically.
As an example, in the following analysis, I would want to extract the value 0.2000 from the output "Note: The probability of obtaining a post/pre-treatment MSPE ratio as large as 1's is 0.2000" and store it in a matrix:
If there's a simple way to do this automatically, that'd be great. Alternatively, I may have to calculate the p-value myself. Doing so would require some matrix manipulation that I'm not sure how to code. I will try to explain the process I need help completing.
The following output matrix lists the ratio of post-treatment MSPE to pre-treatment MSPE in column 3:
What I need to do is calculate the ordinal rank of the treated unit's ratio and divide it by the number of units studied. In this case, the ratio for the treated unit (1) is the largest of the 5 ratios, so it gets rank 1. If we then divide it by the total number of units studied (5), we get the desired 0.2000. If anyone knows how to write code to tell Stata to do this, it'd be much appreciated!
Thanks!
As an example, in the following analysis, I would want to extract the value 0.2000 from the output "Note: The probability of obtaining a post/pre-treatment MSPE ratio as large as 1's is 0.2000" and store it in a matrix:
Code:
* Load data webuse nlswork.dta, clear * Keep subset of data to ensure balanced panel keep if (year == 73 | year == 75 | year == 77 | year == 78) keep if (idcode == 1 | idcode == 2 | idcode == 5 | idcode == 6 | idcode == 9) * Declare panel tsset idcode year * Run analysis synth2 ln_wage ln_wage(75) ln_wage(73), trunit(1) trperiod(77) placebo(unit) * Set up matrix to store result in mat pval = J(1,1,.) * Store result (with help from Statalist community)...
The following output matrix lists the ratio of post-treatment MSPE to pre-treatment MSPE in column 3:
Code:
mat li e(mspe)
Thanks!
Comment