From 2814b6d1f5d2356c770a67ba97113ee49f178fdc Mon Sep 17 00:00:00 2001 From: Evan Petersen Date: Wed, 27 Nov 2024 14:49:48 -0500 Subject: [PATCH] Added robust standard errors to the multicollinearity section --- media/js/src/simulations/simulation3/generatedData.json | 4 ++-- metricsmentor/main/views.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/media/js/src/simulations/simulation3/generatedData.json b/media/js/src/simulations/simulation3/generatedData.json index 5b67753c..692b2ea6 100644 --- a/media/js/src/simulations/simulation3/generatedData.json +++ b/media/js/src/simulations/simulation3/generatedData.json @@ -15,7 +15,7 @@ "intercept": -10.546, "rvalue": 0.731, "pvalue": 0, - "stderr": [0.087,0.055], + "stderr": [0.100,0.009], "yRange": [30.549,140.994] }, "x3": { @@ -25,7 +25,7 @@ "intercept": -10.547, "rvalue": 0.731, "pvalue": 0, - "stderr": [0.121,0.011], + "stderr": [0.072,0.046], "yRange": [46.917,201.349] }, "xRange": [64,236], diff --git a/metricsmentor/main/views.py b/metricsmentor/main/views.py index d32a113c..bd57dca8 100644 --- a/metricsmentor/main/views.py +++ b/metricsmentor/main/views.py @@ -234,7 +234,11 @@ def calculate_multiple_regression(request): if x1_values.size and x2_values.size and y_values.size: X = sm.add_constant(np.column_stack((x1_values, x2_values))) model = sm.OLS(y_values, X) - result = model.fit() + if data.get('robust', False) is True: + cov_type = 'HC3' + else: + cov_type = 'nonrobust' + result = model.fit(cov_type=cov_type) # Convert NumPy arrays to Python lists stderr_list = result.bse.tolist()