http://repec.sowi.unibe.ch/stata/coefplot/
Instead of using the default confidence intervals that are relevant for a two-tailed test, I would like to show the relevant confidence intervals for a one-tailed test. In practice, that means that for the relevant confidence intervals for a one-tailed test based from an OLS regression with alpha = 0.5, I can use the results of the same OLS with alpha = 0.1 to define the lower or upper bound depending on the alternative hypothesis. In the graph, that means that the confidence interval will extend all the way to one of the margins of the graph.
Here is an example of the data I'm working with:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float dep byte indep -.005 1 1.75 0 1.75 1 -.005 0 .005 1 1.75 0 .875 1 .005 0 .005 1 .875 0 -.13 0 1.75 1 .875 1 -.875 0 .625 0 .005 0 .875 1 -1.25 1 .005 1 4 0 end
Code:
regress dep indep estimates store A1 coefplot A1, drop(_cons) xline(0)
In the graph above, for a one-tailed test, the line would extend to one of the margins depending on the H1.
The authors of coefplot documented how the program retrieves the CIs in here:
http://repec.sowi.unibe.ch/stata/coe...rvals.html#h-3
In general, they compute the CIs using standard formulas based on estimation results. There is also the option to include custom variances, degrees of freedom, and standard errors. I do not think any of this options would work to graph the relevant one-tailed confidence interval. The other alternative is to directly provide confidence intervals using the option ci(). I've explored this option without success. Their example uses precomputed confidence intervals from bootstrap. The authors described how to use the option here:
http://repec.sowi.unibe.ch/stata/coe...tml#stlog-1-ci
Here is the relevant text:
"ci(spec) specifies the source from which to collect confidence intervals. Default is to compute confidence intervals for the levels specified in levels() using variances/standard errors (and, possibly, degrees of freedom). The ci() option is useful to plot confidence intervals that have been provided by the estimation command (such as, e.g., bootstrap). spec is cispec [cispec ...] where cispec is name to get the lower and upper confidence limits from rows 1 and 2 of e(name) (or matrix name), respectively. Alternatively, cispec may be (mspec mspec) to identify the lower and upper confidence limits, with mspec as above for b(). For example, after bootstrap, ci(ci_bc) would get bias-corrected confidence intervals from rows 1 and 2 of e(ci_bc). The same could be achieved by ci((ci_bc[1] ci_bc[2]))."
First, I tried to just create a matrix with the lower and upper bound for the confidence intervals:
Code:
matrix A = ( -1 \ 1 ) coefplot A1, drop(_cons) xline(0) ci(A)
(A1: e(A) not found)
(A1: e(A) not found)
(A1: could not determine CI1)
I might be misunderstanding what they meant by "matrix name". Then I tried to put the lower and upper bound in either e(b) or e(V). The issue with e(b) is that the coefplot needs to read the lower bound from [1,1] and the upper bound from [2,1], but e(b) is a vector. To change e(V), I tried with:
Code:
program define oneTailedCI, eclass version 14.2 matrix a = e(V) matrix b = (0.037 , 0.4 ) matrix a[1,1] = b[1,1] matrix a[2,1] = b[1,2] matrix a[1,2] = b[1,2] ereturn repost V = a, ADDCONS end
I've exhausted my options and would appreciate any pointer to something that might work. Ideally, I would end up with a graph like this:
Code:
sysuse auto, clear regress price mpg coefplot, drop(_cons) xline(0) msymbol(d) mcolor(white) /// levels(99 95 90 80 70) ciopts(lwidth(3 ..) lcolor(*.2 *.4 *.6 )) /// legend(order(1 "99" 2 "95" 3 "90") rows(1))
But the dark blue in the center would extend all the way to one of the margins to reflect the one-tailed test.
Thanks!
0 Response to Custom one-tailed confidence intervals for coefplot
Post a Comment