Reputation: 4292
I have variables, y
and x
, and I have run a regression to obtain the slope of the regression line. I can retrieve the p value (and other parameters) from the regression model using the method described in https://journals.sagepub.com/doi/pdf/10.1177/1536867X0800700408, such as:
regress y x
local t = _b[x]/_se[x]
local p = 2*ttail(e(df_r),abs(`t'))
I want to produce a plot of the same data with a line predictor such as:
graph twoway (lfitci x y) (scatter x y), note("Simple regression p value = `p'")
However, in the above case, the p value that is presented in the plot's note area is expressed to full precision (and without the leading zero). How can I restrict the number of decimal places in the plot to a sensible number? I've tried including %9.3f but haven't been able to work out the correct syntax.
Upvotes: 0
Views: 191
Reputation: 37358
local p : di %04.3f `p'
If you want spaces in front, put spaces in front.
Examples of similar technique can be found inside the code for aaplot
on SSC.
Upvotes: 1