Closed janosg closed 2 years ago
here for discussion of rounding to significant digits
That link is not quite it, I think. Only looks to the right of the decimal separator, right?
One of my (and many others') pet peeves is that false sense of precision created by many tables. Like you see mean income of 38,234 Euros. Nobody cares about the 34 bit. People will start interpreting that (despite standard errors on the magnitude of hundreds), however, and miss the important parts.
Here is a function I have been using, probably got that from SO at some point, but cannot find the source.
def nsf(num, n=3):
"""n-Significant Figures"""
numstr = ("{0:.%ie}" % (n - 1)).format(num)
return float(numstr)
It is \sisetup{input-symbols=()}
, see here https://github.com/OpenSourceEconomics/estimagic/issues/253#issuecomment-974103608
Another trivial but useful return type would be df
. Should probably be the default even.
That is, return a dataframe with all the formatting of *** etc, which then takes advantage of the html rendering in a notebook. Currently, html looks ugly in notebooks.
Instead of return_type='python'
, maybe 'modifiable'
or something like that? 'elements'
?
Thinking of it, why think of it as two functions?
One may want to think of a short-hand again, but conceptually this might make sense?
I checked out the version at the branch improve_estimation_table
. A few remarks:
number_format
is currently also applied to "Observations". This statistic should, however, never be rounded.tabular_tex
this is already possible. But it would be great if tabular_tex
had some default values (as estimation_table
already has).estimation_table
is used in a project? (-> just PM me)
Issues with current version estimation table
sig_digits
does not actually implement a rounding to significant digits, but a simple rounding to a fixed number of decimal points. No other kind of rounding is implemented.left_decimals
is confusing and actually rather a hack to achieve padding that anything related to rounding.sig_levels
is too abbreviatedTo-Do Code
left_decimals
to padding and incorporate the information that is currently only in the Notes into the description of that argumentsig_levels
tosignificance_levels
sig_digits
argumentnumber_format
. The following things would be valid for that argument:add_trailing_zeros
. If True, all numbers that are not formatted in scientific notation after applyingnumber_format
are padded with zeros to the right until all numbers have the same amount of decimal points.add_leading_zeros
(analogous to trailing zeros)Suggested default for number formatting
add_trailing_zeros
=Trueadd_leading_zeros
=Falsenumber_format
=("{0:.3g}", "{0:.5f}", "{0:.5g}")
, i.e.To-Do Documentation
The current documentation should be almost completely replaced by the following:
return_type="python"
, does a modification to the DataFrame (e.g. drop a few rows and add a row called "controls" that has a checkmark in some columns and a cross in the others.Moreover we should do the following:
sisetup
code snippet is fixed everywhere (e.g. here and here). One uses a_
and one a-
and only one of them can be correct.Discussion