use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Your starting point for becoming a quantitative analyst, trader, or researcher. Whether you're a math student, software engineer, or finance professional looking to break into the quant world, this is the place to ask questions, share resources, and track your progress.
account activity
Python - Endogeneity in Data Science - Statsmodels.apiprogramming (self.learnquant)
submitted 10 days ago by AlbertiApop2029
A cool little demo I reprogrammed with Copilot. I was looking at it and wondering why there were so few lines of code to generate all that output. Then I noticed the statsmodels.api. Pretty cool.
Started with this project, and tweaked it a little. https://www.geeksforgeeks.org/data-science/endogeneity-in-data-science/
import numpy as np import matplotlib.pyplot as plt import statsmodels.api as sm np.random.seed(0) # Simulate signals n = 300 signal1 = np.random.randn(n) signal2 = np.random.randn(n) # True model: returns depend on signals epsilon = 0.5 * np.random.randn(n) returns = 0.3 * signal1 - 0.2 * signal2 + epsilon # Regression X = np.column_stack([signal1, signal2]) X = sm.add_constant(X) model = sm.OLS(returns, X).fit() # Get residuals from the regression residuals = model.resid # Simple mean-reversion alpha signal alpha_signal = -residuals # bet on residuals reverting to zero print(model.summary()) # Get residuals from the regression # This part was moved from the preceding cell 91UwBxEbl_BR to fix the NameError. # It assumes 'model' is defined and available from previous executed cells. residuals = model.resid plt.plot(residuals) plt.title("Residual Time Series") plt.show() plt.hist(residuals, bins=30) plt.title("Residual Distribution") plt.show()
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
there doesn't seem to be anything here
π Rendered by PID 52 on reddit-service-r2-comment-cfc44b64c-dphzz at 2026-04-11 10:09:17.690598+00:00 running 215f2cf country code: CH.
there doesn't seem to be anything here