Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to report t-statistics (similar to R's 'report' option) #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions stargazer/stargazer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def reset_params(self):
self.show_sig = True
self.sig_levels = [0.1, 0.05, 0.01]
self.sig_digits = 3
self.t_statistic = False
self.confidence_intervals = False
self.show_footer = True
self.custom_lines = defaultdict(list)
Expand Down Expand Up @@ -207,6 +208,10 @@ def significant_digits(self, digits):
assert type(digits) == int, 'The number of significant digits must be an int'
assert digits < 10, 'Whoa hold on there bud, maybe use fewer digits'
self.sig_digits = digits

def show_t_statistic(self, show):
assert type(show) == bool, 'Please input True/False'
self.t_statistic = show

def show_confidence_intervals(self, show):
assert type(show) == bool, 'Please input True/False'
Expand Down Expand Up @@ -472,7 +477,9 @@ def generate_cov_precision(self, cov_name, spacing):
for md in self.model_data:
if cov_name in md['cov_names']:
cov_text += f'<td{spacing}>('
if self.confidence_intervals:
if self.t_statistic:
cov_text += self._float_format(md['cov_values'][cov_name] / md['cov_std_err'][cov_name])
elif self.confidence_intervals:
cov_text += self._float_format(md['conf_int_low_values'][cov_name]) + ' , '
cov_text += self._float_format(md['conf_int_high_values'][cov_name])
else:
Expand Down Expand Up @@ -724,7 +731,9 @@ def generate_cov_precision(self, cov_name):
for md in self.model_data:
if cov_name in md['cov_names']:
cov_text += '& ('
if self.confidence_intervals:
if self.t_statistic:
cov_text += self._float_format(md['cov_values'][cov_name] / md['cov_std_err'][cov_name])
elif self.confidence_intervals:
cov_text += self._float_format(md['conf_int_low_values'][cov_name]) + ' , '
cov_text += self._float_format(md['conf_int_high_values'][cov_name])
else:
Expand Down