# Correctbias

### Purpose

Adjusts a regression model for bias and slope errors.

### Synopsis

- [model_adj,intercept,slope] = correctbias(x,y,model);
- [model_adj,intercept,slope] = correctbias(x,y,model,useslope);
- model_adj = correctbias(x,y,model,0); %do NOT correct for slope

### Description

Given test data (**x**, **y**) and a regression model (**model**), this function calculates bias and, optionally, slope of the predictions and adjusts model to give unbiased predictions.

The output is the model structure with corrections added so that re-application to the same test data will give a slope of unity (1) and offset of zero. Whether or not these corrections are appropriate depends on the validity of the test data. This correction works best when the test data includes many samples and covers a wide range of predictive values.

If only one sample is provided, or all samples have the same measured **y** value, or the optional input **useslope** is set to zero, only a bias correction will be done.

#### Inputs

**x**= X-block test data appropriate for the model.**y**= Y-block test data corresponding to x.**model**= Standard PLS_Toolbox regression model (PLS, PCR, MLR, NPLS, etc.)

#### Optional Inputs

**useslope**= Flag indicating that a slope correction should be included in the correction. Slope is NOT used when set to "false", or 0 (zero). Default is to use slope correction ("true".)

#### Outputs

**model_adj**= Model with adjustments to give unbiased predictions.**intercept**= intercept observed for test data.**slope**= slope observed for test data.