Skip to content

Places where the book computes by hand, or only in R, what process_improve already provides #285

Description

@kgdunn

Collected while executing every Python case against the library (#274). None of these are errors: every number listed here reproduces. They are places where the book and its companion package have drifted apart in coverage rather than in results, so a reader following the text does not meet the function that exists for the job. Each is an editorial call, hence one issue rather than a pull request.

Solutions given only in R. least-squares-modelling/least-squares-exercises.rst is the largest case. All of these were checked against process_improve and reproduce the quoted figures exactly:

  • The prediction intervals at 430, 480 and 520 degrees F (line ~78) are described as "calculating this term manually, or using predict(model, newdata=, int='p') in R". OLS.prediction_interval returns a Bunch with predicted, lower and upper and gives all three intervals to the printed digits. There is no Python version of this solution today.
  • The 1/T model (lines ~118-146), including both standard errors.
  • The RMSEP, influence plot and point-removal exercise (lines ~186-198): OLS with leverage_ and influence_ reproduces the slope, the residual standard error, both confidence intervals and both RMSEP values.
  • summary-of-steps-to-build-and-investigate-a-linear-model.rst gives steps 2 to 8 only in R. print(OLS().fit(X, y)) renders the summary(lm(...)) layout the steps describe, and conf_intervals_, residuals_, fitted_values_ and prediction_interval cover the rest.

Computed by hand where the library has it.

  • multiple-linear-regression.rst recomputes adjusted R-squared from R-squared (line ~315); adj_r2_ holds it, and agrees to three decimals.
  • The same chapter forms residuals as y - predict(...); residuals_ holds them, NaN-padded to the original row count so they align with the raw frame.
  • outliers-...rst fits the same model twice, once with OLS for leverage and Cook's distance and once with statsmodels for the studentized residuals. OLSInfluence supplies all three; alternatively a studentized_residuals_ attribute on OLS would remove the second fit, which is a library request rather than a book one.
  • univariate-review and process-monitoring do their interval and chart arithmetic with scipy throughout. univariate.t_value, univariate.confidence_interval, monitoring.ControlChart and monitoring.calculate_cpk cover much of it. This is the largest surface and the one where the case for changing is weakest: the chapters are teaching the arithmetic, so showing it explicitly may be the point.

Style, not coverage. Several least-squares blocks pass .values into OLS.fit, which discards the column names the class is built to display; passing the frame makes print(model) show formula: VapourPressure ~ InvTemp3 and label the coefficient row, which is closer to the R output the prose compares against.

Now that every case runs in CI, any of these can be converted with the numbers checked as part of the change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions