# Linear regression (/docs/analyses/linear-regression)



## When to use it [#when-to-use-it]

Use linear regression when you want an equation: how many exam points go with one extra study hour, holding anxiety constant? Correlation only says the columns move together. Regression gives the slope.

## Assumptions [#assumptions]

The outcome is numeric. The straight-line model is a fair summary, the spread of residuals is roughly even, and the rows are independent. Residual plots and collinearity diagnostics are how Tensr shows those checks. They are not a formal hypothesis test of the assumptions.

## Running it in Tensr [#running-it-in-tensr]

<Steps>
  <Step>
    Analyze → Regression → Linear. In chat: “Regress score on hours and anxiety.”
  </Step>

  <Step>
    Dependent is the outcome. Independents are the predictors. At least one predictor is required.
  </Step>

  <Step>
    Method starts at enter, which puts every predictor in at once. Confidence level starts at 0.95. Include constant starts on.
  </Step>
</Steps>

## Options [#options]

<TypeTable
  type="{
  dependent: {
    type: 'string',
    description: 'Numeric outcome.',
  },
  independents: {
    type: 'string[]',
    description: 'Predictors. At least one.',
  },
  confidence_level: {
    type: 'number',
    description: 'Confidence level for coefficient intervals.',
    default: '0.95',
  },
  include_constant: {
    type: 'boolean',
    description: 'Fit an intercept.',
    default: 'true',
  },
  method: {
    type: 'string',
    description: 'enter, forward, backward, or stepwise. See Stepwise regression below.',
    default: 'enter',
  },
  missing_values: {
    type: 'string',
    description: 'listwise or pairwise.',
    default: 'listwise',
  },
  residual_plots: {
    type: 'string',
    description: 'none, residuals_fitted, qq, or both.',
    default: 'none',
  },
  collinearity_diagnostics: {
    type: 'boolean',
    description: 'Request body default is false. With two or more predictors, the dispatcher turns this on unless you set it yourself.',
    default: 'false',
  },
  decimal_places: {
    type: '0–6',
    description: 'Report output. Decimal places.',
    default: '3',
  },
  apa_format: {
    type: 'boolean',
    description: 'Report output. APA-style p-values.',
    default: 'true',
  },
  include_charts: {
    type: 'boolean',
    description: 'Report output. Shared chart switch.',
    default: 'true',
  },
}"
/>

`cluster_by`, `scales`, `reference_levels`, and `derive_mean_log_rt` are accepted for advanced and agent runs. They are not the main dialog.

## Reading the output [#reading-the-output]

Exam score predicted from hours and anxiety. Both slopes were built to be moderate. A noise column, practice, is not in this model.

| Term      | Estimate | p-value | 95% CI low | 95% CI high |
| --------- | -------: | ------: | ---------: | ----------: |
| Intercept |   71.518 | \< .001 |     63.003 |      80.034 |
| hours     |    2.062 |    .001 |      0.832 |       3.292 |
| anxiety   |   -2.092 | \< .001 |     -3.162 |      -1.021 |

| Metric                | Value |
| --------------------- | ----: |
| RMSE                  | 7.246 |
| Durbin-Watson         | 1.929 |
| Jarque-Bera statistic | 0.394 |
| Jarque-Bera p-value   |  .821 |
| Residual skewness     |  0.09 |
| Residual kurtosis     | 2.743 |

OLS regression (enter) predicting `score` from 2 predictor(s), n = 96. Inferential test: t. The primary result is significant (p = \< .001). This is large enough, in this sample, to treat the comparison this page is about as a real association rather than noise. Metrics: R² = 0.231; Adj. R² = 0.215; Observations = 96; F p-value = \< .001.

## Reporting (APA 7) [#reporting-apa-7]

## Stepwise regression [#stepwise-regression]

The same scores with method set to stepwise. Hours and anxiety are the two candidates.

| Step | Variable entered/removed |    R² |   ΔR² | F change |       p |
| ---: | ------------------------ | ----: | ----: | -------: | ------: |
|    1 | entered: anxiety         |  0.14 |  0.14 |   15.268 | \< .001 |
|    2 | entered: hours           | 0.231 | 0.092 |   11.083 |    .001 |

OLS regression (stepwise) predicting `score` from 2 predictor(s), n = 96. Inferential test: t.

OLS regression (enter) predicting `score` from 2 predictor(s), n = 96. Inferential test: t. This result is significant (p = \< .001). The effect is moderate, so report its size with the p-value.

## Coming from SPSS [#coming-from-spss]

Analyze → Regression → Linear.

SPSS Method offers Enter, Stepwise, Remove, Backward, and Forward. Tensr’s `method` values are enter, stepwise, backward, and forward. SPSS Statistics also offers collinearity and plots from the same dialog. Tensr’s switches are `collinearity_diagnostics` and `residual_plots`.

## Related [#related]

Associations without slopes are [bivariate correlation](/docs/analyses/correlation). Adding predictors in blocks you choose is [hierarchical regression](/docs/analyses/hierarchical-regression). A product term is [moderation](/docs/analyses/moderation-analysis).
