Exercise

Variation Around the Trend

The data need not be perfectly linear, and there may be some random variation or "spread" in the measurements, and that does translate into variation of the model parameters. This variation is in the parameter is quantified by "standard error", and interpreted as "uncertainty" in the estimate of the model parameter.

In this exercise, you will use ols from statsmodels to build a model and extract the standard error for each parameter of that model.

Instructions

100 XP
  • Store the preloaded data in a DataFrame df, labeling x_data as times and y_data as distances.
  • Use model_fit = ols().fit() to fit a linear model or the form formula="distances ~ times" to the data=df.
  • Extract the estimated intercept model_fit.params['Intercept'] and the standard error of the slope from model_fit.bse['Intercept'].
  • Repeat for the slope, and then print all 4 with meaningful names.