benjann / estout

Stata module to make regression tables
http://repec.sowi.unibe.ch/stata/estout/index.html
MIT License
71 stars 18 forks source link

Report "< .001" when p is lower than 0.001; otherwise report actual p value #32

Closed jolyphil closed 2 years ago

jolyphil commented 3 years ago

Thanks for this great package that has made my work much easier over the last years!

I am trying to reproduce an APA table. See Table 3: https://apastyle.apa.org/style-grammar-guidelines/tables-figures/sample-tables#regression

I roughly get what I want with the following commands:

sysuse auto, clear
reg price weight length
estout, cells("b(label(Estimate)) se(label(SE)) ci(label(95% CI) par([ , ])) p")

The only thing I am missing is a way to dynamically convert a p value under 0.001 with "< .001". If the the p value is over 0.001, the actual value should be reported.

Is there a way to do this with estout?

Many thanks!

benjann commented 3 years ago

I do not have a very elegant solution for you but here's a trick using substitute():


sysuse auto, clear reg price weight length estout, cells("b p(par(p=) f(3))") substitute("p=.000" " <.001""p=" " ") nolz


The result is not necessarily entirely correct, because values lower than .001 that are rounded up to .001 are displayed as .001 and not as <.001.

So you would also do something like the following:


sysuse auto, clear

reg price weight length mat pval = r(table) mat pval = pval["pvalue",1...] forv i = 1 / =colsof(pval)' { if (pval[1,i']<.001) mat pval[1,`i'] = .a } estadd matrix pval

estout, cells("b pval(f(3))") substitute(" .a" "<.001") nolz


ben

On 19 Oct 2021, at 16:29, Philippe Joly @.***> wrote:

Thanks for this great package that has facilitated my life enormously over the last years!

I am trying to reproduce an APA table. See Table 3: https://apastyle.apa.org/style-grammar-guidelines/tables-figures/sample-tables#regression

I roughly get what I want with the following commands:

sysuse auto, clear reg price weight length estout, cells("b(label(Estimate)) se(label(SE)) ci(label(95% CI) par([ , ])) p")

The only thing I am missing is a way to dynamically convert a p value under 0.001 with "p < .001". If the the p value is over 0.001, the actual value should be reported.

Is there a way to do this with estout?

Many thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

jolyphil commented 3 years ago

Using substitute in combination with .a was a great idea! Thanks a lot. I am wondering if there would be a demand for a wrapper around estout similar to the apa_table() function in the papaja R package. Anyhow thanks for your quick response!

benjann commented 3 years ago

Feel free to write such a wrapper ;)

NilsEnevoldsen commented 2 years ago

@benjann I think it would be appropriate to close this issue.

fredericky123 commented 2 years ago

If in the correlation table, we can set such notes, that will be great. All correlations with absolute values above 0.050 have p-values below 0.010

This is the requirement from APA