R equivalencies in Python.

What I did

What I learned

from scipy import stats
slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)

According to the documentation, the p_value returns a “Two-sided p-value for a hypothesis test whose null hypothesis is that the slope is zero, using Wald Test with t-distribution of the test statistic.” Essentially, what is the probability of obtaining a result at least as extreme as the measured slope, assuming the null hypothesis of zero. For a 2-tailed test, the p-value is:

\[\text{p value} = 2P(Z > |z_0|) \\ \text{where } Z_0 = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}}\]
import statsmodels.formula.api as sfm
# regress acc onto dist
mod = sfm.ols(formula='accuracy ~ avg_dist', data = df) 
res=mod.fit()
print(res.summary())

What I Will do next