# NDK_REGRESSION

 int __stdcall NDK_REGRESSION ( double * X, size_t nX, double * Y, size_t nY, WORD nRegressType, WORD POrder, double intercept, double target, WORD nRetType, double alpha, double * retVal )

calculates the value of the regression function for an intermediate x-value.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Remarks
1. NxTrend supports the following trend functions: \begin{cases} \mathrm{Linear} & Y=\alpha + \beta \times X \\ \mathrm{Polynomial} & Y=\alpha + \beta_1 \times X + \beta_2 \times X^2 + \cdots + \beta_N \times X^N \\ \mathrm{Exponential:} & Y= \alpha \times e^{\beta \times X} \\ \mathrm{Logarithm:} & Y= \alpha + \beta \times \ln(X) \\ \mathrm{Power:} & Y= \alpha \times X^{\beta} \\ \end{cases}
2. For exponential and logarithmic trends, the intercept value is not permitted to be fixed, and thus is ignored.
3. The Excel trend built-in function (i.e. "TREND") is a different function, not part of NumXL, and should not be confused with NxTrend.
4. The polynomial order argument must be a positive integer.
5. The trend function's coefficients that best fit your data are estimated using the "least squares" method.
6. The time series may include missing values (e.g. #N/A) at either end.
Parameters
 [in] X is the x-component of the input data table (a one dimensional array). [in] nX is the number of elements in X. [in] Y is the y-component (i.e. function) of the input data table (a one dimensional array). [in] nY is the number of elements in Y [in] nRegressType is the model description flag for the trend function (1 = Linear (default), 2 = Polynomial, 3 = Exponential, 4 = Logarithmic, 5 = Power). [in] POrder is the polynomial order. This is only relevant for a polynomial type of trend and is ignored for all others. If missing, POrder = 1. [in] intercept is the constant or the intercept value to fix (e.g. zero). If missing (NaN), an intercept will not be fixed and is computed normally. [in] target is the desired x-value to calculate regression value for (a single value). [in] nRetType is a switch to select the return output (1 = Forecast value (default), 2 = Upper limit, 3 = Lower Limit, 4 = R-Squared). [in] alpha is the statistical significance or confidence level (i.e. alpha). If missing or omitted, an alpha value of 5% is assumed [out] retVal is the calculated value
Requirements
 Namespace: NumXLAPI Class: SFSDK Scope: Public Lifetime: Static
 NDK_REGRESSION ( double X, UIntPtr nX, double[] Y, UIntPtr nY, short nRegressType, short POrder, double intercept, double target, UInt16 nRetType, double alpha, ref double retVal )

calculates the value of the regression function for an intermediate x-value.

Return Value

a value from NDK_RETCODE enumeration for the status of the call.

 NDK_SUCCESS operation successful Error Error Code
Remarks
1. NxTrend supports the following trend functions: \begin{cases} \mathrm{Linear} & Y=\alpha + \beta \times X \\ \mathrm{Polynomial} & Y=\alpha + \beta_1 \times X + \beta_2 \times X^2 + \cdots + \beta_N \times X^N \\ \mathrm{Exponential:} & Y= \alpha \times e^{\beta \times X} \\ \mathrm{Logarithm:} & Y= \alpha + \beta \times \ln(X) \\ \mathrm{Power:} & Y= \alpha \times X^{\beta} \\ \end{cases}
2. For exponential and logarithmic trends, the intercept value is not permitted to be fixed, and thus is ignored.
3. The Excel trend built-in function (i.e. "TREND") is a different function, not part of NumXL, and should not be confused with NxTrend.
4. The polynomial order argument must be a positive integer.
5. The trend function's coefficients that best fit your data are estimated using the "least squares" method.
6. The time series may include missing values (e.g. #N/A) at either end.
Parameters
 [in] X is the x-component of the input data table (a one dimensional array). [in] nX is the number of elements in X. [in] Y is the y-component (i.e. function) of the input data table (a one dimensional array). [in] nY is the number of elements in Y [in] nRegressType is the model description flag for the trend function (1 = Linear (default), 2 = Polynomial, 3 = Exponential, 4 = Logarithmic, 5 = Power). [in] POrder is the polynomial order. This is only relevant for a polynomial type of trend and is ignored for all others. If missing, POrder = 1. [in] intercept is the constant or the intercept value to fix (e.g. zero). If missing (NaN), an intercept will not be fixed and is computed normally. [in] target is the desired x-value to calculate regression value for (a single value). [in] nRetType is a switch to select the return output (1 = Forecast value (default), 2 = Upper limit, 3 = Lower Limit, 4 = R-Squared). [in] alpha is the statistical significance or confidence level (i.e. alpha). If missing or omitted, an alpha value of 5% is assumed [out] retVal is the calculated value
Exceptions
Exception Type Condition
None N/A
Requirements
Namespace NumXLAPI SFSDK Public Static NumXLAPI.DLL
Examples

References
* Hamilton, J .D.; Time Series Analysis , Princeton University Press (1994), ISBN 0-691-04289-6
* Tsay, Ruey S.; Analysis of Financial Time Series John Wiley & SONS. (2005), ISBN 0-471-690740
* D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906
* Box, Jenkins and Reisel; Time Series Analysis: Forecasting and Control; John Wiley & SONS.; 4th edition(Jun 30, 2008), ISBN: 470272848