Repository: statsmodels/statsmodels

Issue:
Module statsmodels.stats.contingency_tables: printed wrong  confidence interval for risk ratio
```
lcb1, ucb1 = self.oddsratio_confint(alpha, method)
lcb2, ucb2 = self.log_oddsratio_confint(alpha, method)
lcb3, ucb3 = self.riskratio_confint(alpha, method)
lcb4, ucb4 = self.log_riskratio_confint(alpha, method)

data = [[fmt(x) for x in [self.oddsratio, "", lcb1, ucb1, self.oddsratio_pvalue()]],
                [fmt(x) for x in [self.log_oddsratio, self.log_oddsratio_se, lcb2, ucb2,
                                  self.oddsratio_pvalue()]],
                [fmt(x) for x in [self.riskratio, "", lcb2, ucb2, self.riskratio_pvalue()]],
                [fmt(x) for x in [self.log_riskratio, self.log_riskratio_se, lcb4, ucb4,
                                  self.riskratio_pvalue()]]]
```

risk ratio should be:
`self.riskratio, "", lcb3, ucb3, self.riskratio_pvalue()]`


Discussion:
Can you explain a bit? What's the problem, the expected results and the wrong result?
This would help so we don't have to figure it out from scratch or second guess.

**edit** after reformatting the issue it is clear
Sure.
So if you have a contingency table:    table= [ [9 41],
                                                                   [20 29]]
ans you want to calculate the risk ratio, odds ratio and so on with confidence interval, you call the functions:
t22 = sm.stats.Table2x2(table)
print(t22.summary())

Please see below the screen shot
![image](https://user-images.githubusercontent.com/15914134/28356299-d9bfddda-6c67-11e7-8f0a-4170685916a8.png)

The confidence interval of the Risk ratio is not correct, it is the same of the Log odds ratio.
The calculation is correct, but in the summary function you print it wrongly.
This error is also  visible in the webpage: http://www.statsmodels.org/dev/contingency_tables.html

Hope is more clear now.

@LiciaMila  Thanks, that is clear now and it only takes a minute to find the bug

summary uses lcb2, ucb2 instead of lcb3, ucb3
```
[fmt(x) for x in [self.riskratio, "", lcb2, ucb2,
                                  self.riskratio_pvalue()]],
```

Do you want to open a PR, with that fix? 
We don't have unit tests for the content of summary in most cases
What PR stands for?
"pull request" to make changes to the statsmodels code

If you are not familiar with git, then I can fix the bug it.
(For a simple change like this, you might be able to use the github interface to edit the file.)

in any case, thank you for finding and reporting the bug
Oh right! Yes i use git, but i never edited in github. Good to know. 
If you can fix it this time is good with me. I'll definitely do it next time.

Have  a nice day!

Resolving patch:
diff --git a/statsmodels/stats/contingency_tables.py b/statsmodels/stats/contingency_tables.py
--- a/statsmodels/stats/contingency_tables.py
+++ b/statsmodels/stats/contingency_tables.py
@@ -884,7 +884,7 @@ def fmt(x):
                                   self.oddsratio_pvalue()]],
                 [fmt(x) for x in [self.log_oddsratio, self.log_oddsratio_se,
                                   lcb2, ucb2, self.oddsratio_pvalue()]],
-                [fmt(x) for x in [self.riskratio, "", lcb2, ucb2,
+                [fmt(x) for x in [self.riskratio, "", lcb3, ucb3,
                                   self.riskratio_pvalue()]],
                 [fmt(x) for x in [self.log_riskratio, self.log_riskratio_se,
                                   lcb4, ucb4, self.riskratio_pvalue()]]]


Test patch:
diff --git a/statsmodels/stats/tests/test_contingency_tables.py b/statsmodels/stats/tests/test_contingency_tables.py
--- a/statsmodels/stats/tests/test_contingency_tables.py
+++ b/statsmodels/stats/tests/test_contingency_tables.py
@@ -542,6 +542,10 @@ def test_from_data(self):
         assert_equal(self.tbl_obj.summary().as_text(),
                      self.tbl_data_obj.summary().as_text())
 
+    def test_summary(self):
+
+        assert_equal(self.tbl_obj.summary().as_text(),
+                     self.summary_string)
 
 
 class Test2x2_1(Check2x2Mixin):
@@ -569,3 +573,11 @@ def __init__(self):
                                   3.9984381579173824]
         self.log_riskratio_confint = [-1.3859038243496782,
                                       1.3859038243496782]
+        ss = [  '               Estimate   SE   LCB    UCB   p-value',
+                '---------------------------------------------------',
+                'Odds ratio        1.000        0.063 15.988   1.000',
+                'Log odds ratio    0.000 1.414 -2.772  2.772   1.000',
+                'Risk ratio        1.000        0.250  3.998   1.000',
+                'Log risk ratio    0.000 0.707 -1.386  1.386   1.000',
+                '---------------------------------------------------']
+        self.summary_string = '\n'.join(ss)