# SLR_FORE - Forecasting for Simple Linear Regression Model

Calculates the forecast value, error and confidence interval for a regression model.

## Syntax

SLR_FORE(X, Y, Intercept, Target, Return_type, Alpha)
X
is the independent (aka explanatory or predictor) variable data array (one dimensional array of cells (e.g. rows or columns)).
Y
is the response or the dependent variable data array (one dimensional array of cells (e.g. rows or columns)).
Intercept
is the constant or the intercept value to fix (e.g. zero). If missing, an intercept will not be fixed and is computed normally.
Target
is the value of the explanatory variable.
Return_type
is a switch to select the return output (1 = forecast (default), 2 = error, 3 = upper limit, 4 = lower limit).
Method Description
1 Mean Value
2 Standard Error
3 Upper Limit
4 Lower Limit
Alpha
is the statistical significance of the test (i.e. alpha). If missing or omitted, an alpha value of 5% is assumed.

## Remarks

1. The underlying model is described here.
2. The SLR_FORE function computes the prediction interval (aka confidence interval) for a given value of the explanatory variable.
3. The mean prediction values are computed by:
$$E[Y_f|X_f] = \alpha + \beta \times X_f$$
Where:
• $E[Y_f|X_f]$ is the conditional prediction mean value of $Y$.
• $X_f$ is the value of the explanatory variable.
• $E[.|X_f]$ is the conditional expectation operator.
4. The prediction error is driven by the regression mean error and the value of $X_f$ itself.
$$\mathrm{Var}(e_f=Y_f - \hat Y_f)=\mathrm{MSE}\times\left(1+\frac{1}{N}+\frac{(X_f-\bar X)^2}{\sum_{i=1}^N(X_i-\bar X)^2} \right )$$
Where:
• $N$ is the number of observations.
• $\bar X$ is the empirical sample average for the explanatory variable ($X$).
• $\mathrm{MSE} = \frac{\mathrm{SSE}}{N-2}= \frac{\sum_{i=1}^N (Y_i - \hat Y_i)^2}{N-2}$
5. The sample data may include missing values.
6. Each column in the input matrix corresponds to a separate variable.
7. Each row in the input matrix corresponds to an observation.
8. Observations (i.e. rows) with missing values in X or Y are removed.
9. The number of rows of the response variable (Y) must be equal to the number of rows of the explanatory variable (X).
10. The SLR_FORE function is available starting with version 1.60 APACHE.