Skip to content
Technical & algorithm documentationSource reviewed

Correlation and regression

Explore associations or model continuous and binary outcomes with explicit variable roles.

Overview

Correlation quantifies pairwise association. Regression estimates conditional relationships between a specified outcome and predictors. Survlytics supports Pearson and Spearman correlation, OLS linear regression and binary logistic regression.

Theoretical foundation

Pearson correlation standardises covariance; Spearman correlation applies Pearson correlation to ranks. OLS minimises squared residuals. Logistic regression estimates log odds through a binomial likelihood. Regression inference and out-of-sample prediction are different goals.

Key equations

OLS estimator
\hat{\boldsymbol\beta}=(X^\top X)^{-1}X^\top y
Logistic link
\log\frac{p}{1-p}=\beta_0+\sum_{j=1}^{p}\beta_jx_j

Algorithm and computation

Pearson and Spearman coefficients and two-sided p-values use SciPy. Pearson intervals use Fisher’s z transform; Spearman intervals are unavailable. Linear regression uses statsmodels OLS with conventional or HC3 covariance, R², adjusted R², F tests, VIF, Breusch–Pagan, residual and influence diagnostics. Logistic regression uses statsmodels Logit with odds ratios, likelihood-based fit, ROC and classification diagnostics. Designs are complete-case after dummy coding categorical predictors with the first observed category dropped.

Required data

Numeric pairs for correlation; a numeric continuous outcome for OLS; a binary outcome with a declared positive event for logistic regression; explicit predictors and controls.

Assumptions

Independent observations and a correctly specified functional form are central. Conventional OLS inference assumes homoskedastic errors; HC3 relaxes that covariance assumption but does not repair misspecification. Logistic models require an identifiable, non-separated design.

Available settings

Pearson or Spearman; listwise or pairwise correlation; conventional or HC3 covariance for OLS; intercept; categorical predictors; confidence level; classification threshold.

Worked example

Synthetic example: satisfaction is modelled from trust and tenure. The trust coefficient is interpreted conditionally on tenure, with its interval and diagnostics; it is not described as a causal effect.

Limitations and non-claims

Correlation does not imply causation. No penalised regression, mixed models, survey weights, time-series errors, imputation or automatic variable selection are implemented.

Validation notes

Regression and correlation outputs are covered by numerical unit tests using SciPy/statsmodels calculations. No cross-software frozen benchmark is claimed for every diagnostic.

How Surv.lytics computes Correlation
EstimatorPearson or Spearman association
LibrariesSciPy 1.17.0
Missing dataListwise or pairwise
ValidationImplemented and covered by tests
Defaults{'method': 'pearson', 'confidence': 0.95}
Open full technical documentation
How Surv.lytics computes Linear regression
EstimatorOLS with conventional or HC3 covariance
Librariesstatsmodels 0.14.6
Missing dataComplete design rows
ValidationImplemented and covered by tests
Defaults{'cov_type': 'nonrobust', 'intercept': True}
Open full technical documentation
How Surv.lytics computes Logistic regression
EstimatorBinary maximum-likelihood Logit
Librariesstatsmodels 0.14.6
Missing dataComplete design rows
ValidationImplemented and covered by tests
Defaults{'threshold': 0.5, 'intercept': True}
Open full technical documentation

Was this article helpful?

Your response helps the methodology team improve this documentation.