# NDK_GLM_RESID

 int __stdcall NDK_GLM_RESID ( double * Y, size_t nSize, double ** X, size_t nVars, double * betas, size_t nBetas, double phi, WORD Lvk, WORD retType )

Returns the standardized residuals/errors of a given GLM.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Parameters
 [in] Y is the response or the dependent variable data array (one dimensional array) [in] nSize is the number of observations [in] X is the independent variables data matrix, such that each column represents one variable [in] nVars is the number of independent variables (or columns in X) [in] betas are the coefficients of the GLM model (a one dimensional array) [in] nBetas is the number of the coefficients in betas. Note that nBetas must be equal to nVars+1 [in] phi is the GLM dispersion parameter. Phi is only meaningful for Binomial (1/batch or trial size) and for Gaussian (variance). Binomial : phi = Reciprocal of the batch/trial size. Gaussian : phi = variance. Poisson : phi = 1.0 [in] Lvk is the link function that describes how the mean depends on the linear predictor (see GLM_LINK_FUNC). Identity (default) Log Logit Probit Complementary log-log [in] retType is a switch to select a residuals-type:raw or standardized. see RESID_RETVAL_FUNC
Remarks
1. The underlying model is described here.
2. The GLM residuals are defined as follow: $\left[\epsilon\right]= \left[Y\right] - g^{-1}(X\beta)$
3. GLM_RESID returns an array of size equal to number of rows in the input response (Y) or explanatory variables (X).
4. The number of rows in response variable (Y) must be equal to number of rows of the explanatory variables (X).
5. The betas input is optional, but if the user provide one, the number of betas must equal to the number of explanatory variables (i.e. X) plus one (intercept).
6. For GLM with Poisson distribution,
• The values of response variable must be non-negative integers.
• The value of the dispersion factor (Phi) value must be either missing or equal to one.
7. For GLM with Binomial distribution,
• The values of the response variable must be non-negative fractions between zero and one, inclusive.
• The value of the dispersion factor (Phi) must be a positive fraction (greater than zero, and less than one).
8. For GLM with Gaussian distribution, the dispersion factor (Phi) value must be positive.
Requirements
Header SFSDK.H SFSDK.LIB SFSDK.DLL
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