Syntax
C# |
---|
public static void g02gp( string errfn, string link, string mean, string offset, string weight, int n, double[,] x, int m, int[] isx, int ip, double[] t, double[] off, double[] wt, double s, double a, double[] b, double[] cov, bool vfobs, double[] eta, double[] seeta, double[] pred, double[] sepred, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g02gp ( _ errfn As String, _ link As String, _ mean As String, _ offset As String, _ weight As String, _ n As Integer, _ x As Double(,), _ m As Integer, _ isx As Integer(), _ ip As Integer, _ t As Double(), _ off As Double(), _ wt As Double(), _ s As Double, _ a As Double, _ b As Double(), _ cov As Double(), _ vfobs As Boolean, _ eta As Double(), _ seeta As Double(), _ pred As Double(), _ sepred As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g02gp( String^ errfn, String^ link, String^ mean, String^ offset, String^ weight, int n, array<double,2>^ x, int m, array<int>^ isx, int ip, array<double>^ t, array<double>^ off, array<double>^ wt, double s, double a, array<double>^ b, array<double>^ cov, bool vfobs, array<double>^ eta, array<double>^ seeta, array<double>^ pred, array<double>^ sepred, [OutAttribute] int% ifail ) |
F# |
---|
static member g02gp : errfn : string * link : string * mean : string * offset : string * weight : string * n : int * x : float[,] * m : int * isx : int[] * ip : int * t : float[] * off : float[] * wt : float[] * s : float * a : float * b : float[] * cov : float[] * vfobs : bool * eta : float[] * seeta : float[] * pred : float[] * sepred : float[] * ifail : int byref -> unit |
Parameters
- errfn
- Type: System..::..StringOn entry: indicates the distribution used to model the dependent variable, .
- The binomial distribution is used.
- The gamma distribution is used.
- The Normal (Gaussian) distribution is used.
- The Poisson distribution is used.
Constraint: , , or .
- link
- Type: System..::..StringOn entry: indicates which link function to be used.
- A complementary log-log link is used.
- An exponent link is used.
- A logistic link is used.
- An identity link is used.
- A log link is used.
- A probit link is used.
- A reciprocal link is used.
- A square root link is used.
Details on the functional form of the different links can be found in the G02 class.Constraints:- if , , or ;
- otherwise , , , or .
- mean
- Type: System..::..StringOn entry: indicates if a mean term is to be included.
- A mean term, intercept, will be included in the model.
- The model will pass through the origin, zero-point.
Constraint: or .
- offset
- Type: System..::..StringOn entry: indicates if an offset is required.Constraint: or .
- weight
- Type: System..::..StringOn entry: if indicates if weights are used, otherwise weight is not referenced.
- No weights are used.
- Weights are used and must be supplied in wt.
Constraint: if , or .
- n
- Type: System..::..Int32On entry: , the number of observations.Constraint: .
- x
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, dim2]Note: dim1 must satisfy the constraint:Note: the second dimension of the array x must be at least .On entry: must contain the th observation for the th independent variable, for and .
- m
- Type: System..::..Int32On entry: , the total number of independent variables.Constraint: .
- isx
- Type: array<System..::..Int32>[]()[][]An array of size [m]On entry: indicates which independent variables are to be included in the model.If , the th independent variable is included in the regression model.
- ip
- Type: System..::..Int32On entry: the number of independent variables in the model, including the mean or intercept if present.Constraint: .
- t
- Type: array<System..::..Double>[]()[][]An array of size [_lt]Note: the dimension of the array must be at least if , and at least otherwise.On entry: if , must contain the binomial denominator, , for the th observation.Otherwise t is not referenced.Constraint: if , , for .
- off
- Type: array<System..::..Double>[]()[][]An array of size [_lof]Note: the dimension of the array must be at least if , and at least otherwise.On entry: if , must contain the offset , for the th observation.Otherwise off is not referenced.
- wt
- Type: array<System..::..Double>[]()[][]An array of size [_lwt]Note: the dimension of the array must be at least if and , and at least otherwise.On entry: if and , must contain the weight, , for the th observation.If the variance of future observations is not included in the standard error of the predicted variable, wt is not referenced.Constraint: if and , ., for .
- s
- Type: System..::..DoubleOn entry: if or and , the scale parameter, .Otherwise s is not referenced and .Constraint: if or and , .
- a
- Type: System..::..Double
Constraint: if , .
- b
- Type: array<System..::..Double>[]()[][]An array of size [ip]
- cov
- Type: array<System..::..Double>[]()[][]An array of size []On entry: the upper triangular part of the variance-covariance matrix, , of the model parameters. This matrix should be supplied packed by column, i.e., the covariance between parameters and , that is the values stored in and , should be supplied in , for and .Constraint: the matrix represented in cov must be a valid variance-covariance matrix.
- vfobs
- Type: System..::..BooleanOn entry: if , the variance of future observations is included in the standard error of the predicted variable (i.e., ), otherwise .
- eta
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the linear predictor, .
- seeta
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the standard error of the linear predictor, .
- pred
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the predicted value, .
- sepred
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the standard error of the predicted value, . If could not be calculated, then g02gp returns , and is set to .
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
A generalized linear model consists of the following elements:
(i) | A suitable distribution for the dependent variable . |
(ii) | A linear model, with linear predictor , where is a matrix of independent variables and a column vector of parameters. |
(iii) | A link function between the expected value of and the linear predictor, that is . |
In order to predict from a generalized linear model, that is estimate a value for the dependent variable, , given a set of independent variables , the matrix must be supplied, along with values for the parameters and their associated variance-covariance matrix, . Suitable values for and are usually estimated by first fitting the prediction model to a training dataset with known responses, using for example g02ga, g02gb, g02gc or g02gd. The predicted variable, and its standard error can then be obtained from:
where
is a vector of offsets and , if the variance of future observations is not taken into account, and otherwise. Here indicates the diagonal elements of matrix .
If required, the variance for the th future observation, , can be calculated as:
where is a weight, is the scale (or dispersion) parameter, and is the variance function. Both the scale parameter and the variance function depend on the distribution used for the , with:
Poisson | , |
binomial | , |
Normal | |
gamma |
In the cases of a Normal and gamma error structure, the scale parameter (), is supplied by you. This value is usually obtained from the method used to fit the prediction model. In many cases, for a Normal error structure, , i.e., the estimated variance.
References
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall
Error Indicators and Warnings
Note: g02gp may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDX) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
- On entry, , , or .
- On entry, and , or or and , , , or .
- On entry, or .
- On entry, or .
- On entry, and or .
- On entry, .
- On entry, .
- On entry, .
- On entry, .
- On entry, and for at least one .
- On entry, , and for at least one .
- On entry, , or and .
- On entry, and .
- On entry, supplied covariance matrix has at least one diagonal element .
- On exit, at least one predicted value could not be calculated as required. sepred is set to for affected predicted values.
Accuracy
Not applicable.
Parallelism and Performance
None.
Further Comments
None.
Example
The model
is fitted to a training dataset with five observations. The resulting model is then used to predict the response for two new observations.
Example program (C#): g02gpe.cs