Syntax
C# |
---|
public static void g02da( string mean, string weight, int n, double[,] x, int m, int[] isx, int ip, double[] y, double[] wt, out double rss, out int idf, double[] b, double[] se, double[] cov, double[] res, double[] h, double[,] q, out bool svd, out int irank, double[] p, double tol, double[] wk, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g02da ( _ mean As String, _ weight As String, _ n As Integer, _ x As Double(,), _ m As Integer, _ isx As Integer(), _ ip As Integer, _ y As Double(), _ wt As Double(), _ <OutAttribute> ByRef rss As Double, _ <OutAttribute> ByRef idf As Integer, _ b As Double(), _ se As Double(), _ cov As Double(), _ res As Double(), _ h As Double(), _ q As Double(,), _ <OutAttribute> ByRef svd As Boolean, _ <OutAttribute> ByRef irank As Integer, _ p As Double(), _ tol As Double, _ wk As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g02da( String^ mean, String^ weight, int n, array<double,2>^ x, int m, array<int>^ isx, int ip, array<double>^ y, array<double>^ wt, [OutAttribute] double% rss, [OutAttribute] int% idf, array<double>^ b, array<double>^ se, array<double>^ cov, array<double>^ res, array<double>^ h, array<double,2>^ q, [OutAttribute] bool% svd, [OutAttribute] int% irank, array<double>^ p, double tol, array<double>^ wk, [OutAttribute] int% ifail ) |
F# |
---|
static member g02da : mean : string * weight : string * n : int * x : float[,] * m : int * isx : int[] * ip : int * y : float[] * wt : float[] * rss : float byref * idf : int byref * b : float[] * se : float[] * cov : float[] * res : float[] * h : float[] * q : float[,] * svd : bool byref * irank : int byref * p : float[] * tol : float * wk : float[] * ifail : int byref -> unit |
Parameters
- 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 .
- weight
- Type: System..::..StringOn entry: indicates if weights are to be used.
- Least squares estimation is used.
- Weighted least squares is used and weights must be supplied in array wt.
Constraint: or .
- n
- Type: System..::..Int32On entry: , the number of observations.Constraint: .
- x
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, m]Note: dim1 must satisfy the constraint: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 in the dataset.Constraint: .
- isx
- Type: array<System..::..Int32>[]()[][]An array of size [m]On entry: indicates which independent variables are to be included in the model.
- The variable contained in the th column of x 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.Constraints:
- if , ;
- if , ;
- otherwise .
- y
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: , observations on the dependent variable.
- wt
- Type: array<System..::..Double>[]()[][]An array of size [dim1]Note: the dimension of the array wt must be at least if , and at least otherwise.On entry: if , wt must contain the weights to be used in the weighted regression.If , the th observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights. The values of res and h will be set to zero for observations with zero weights.If , wt is not referenced and the effective number of observations is .Constraint: if , , for .
- rss
- Type: System..::..Double%On exit: the residual sum of squares for the regression.
- idf
- Type: System..::..Int32%On exit: the degrees of freedom associated with the residual sum of squares.
- b
- Type: array<System..::..Double>[]()[][]An array of size [ip]
- se
- Type: array<System..::..Double>[]()[][]An array of size [ip]
- cov
- Type: array<System..::..Double>[]()[][]An array of size []
- res
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the (weighted) residuals, , for .
- h
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the diagonal elements of , , for .
- q
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, ]Note: dim1 must satisfy the constraint:On exit: the results of the decomposition:
- the first column of q contains ;
- the upper triangular part of columns to contain the matrix;
- the strictly lower triangular part of columns to contain details of the matrix.
- svd
- Type: System..::..Boolean%
- irank
- Type: System..::..Int32%
- p
- Type: array<System..::..Double>[]()[][]An array of size []
- tol
- Type: System..::..DoubleOn entry: the value of tol is used to decide if the independent variables are of full rank and if not what is the rank of the independent variables. The smaller the value of tol the stricter the criterion for selecting the singular value decomposition. If , the singular value decomposition will never be used; this may cause run time errors or inaccurate results if the independent variables are not of full rank.Suggested value: .Constraint: .
- wk
- Type: array<System..::..Double>[]()[][]An array of size []
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
The general linear regression model is defined by
where
- is a vector of observations on the dependent variable,
- is an by matrix of the independent variables of column rank ,
- is a vector of length of unknown parameters, and
- is a vector of length of unknown random errors such that , where is a known diagonal matrix.
If , the identity matrix, then least squares estimation is used. If , then for a given weight matrix , weighted least squares estimation is used.
The least squares estimates of the parameters minimize while the weighted least squares estimates minimize .
g02da finds a decomposition of (or in weighted case), i.e.,
where and is a by upper triangular matrix and is an by orthogonal matrix. If is of full rank, then is the solution to
where (or ) and is the first elements of . If is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of ,
where is a by diagonal matrix with nonzero diagonal elements, being the rank of , and and are by orthogonal matrices. This gives the solution
being the first columns of , i.e., , and being the first columns of .
Details of the SVD, are made available, in the form of the matrix :
This will be only one of the possible solutions. Other estimates may be obtained by applying constraints to the parameters. These solutions can be obtained by using g02dk after using g02da. Only certain linear combinations of the parameters will have unique estimates; these are known as estimable functions.
The fit of the model can be examined by considering the residuals, , where are the fitted values. The fitted values can be written as for an by matrix . The th diagonal elements of , , give a measure of the influence of the th values of the independent variables on the fitted regression model. The values are sometimes known as leverages. Both and are provided by g02da.
The output of g02da also includes , the residual sum of squares and associated degrees of freedom, , the standard errors of the parameter estimates and the variance-covariance matrix of the parameter estimates.
In many linear regression models the first term is taken as a mean term or an intercept, i.e., , for . This is provided as an option. Also only some of the possible independent variables are required to be included in a model, a facility to select variables to be included in the model is provided.
References
Cook R D and Weisberg S (1982) Residuals and Influence in Regression Chapman and Hall
Draper N R and Smith H (1985) Applied Regression Analysis (2nd Edition) Wiley
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall
Searle S R (1971) Linear Models Wiley
Error Indicators and Warnings
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDX, LDQ) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , or , or , or , or .
On entry, or , or or .
On entry, and a value of .
On entry, a value of , or the value of ip is incompatible with the values of mean and isx, or ip is greater than the effective number of observations.
- The degrees of freedom for the residuals are zero, i.e., the designated number of parameters is equal to the effective number of observations. In this case the parameter estimates will be returned along with the diagonal elements of , but neither standard errors nor the variance-covariance matrix will be calculated.
- The singular value decomposition has failed to converge, see (F02WUF not in this release). This is an unlikely error.
Accuracy
The accuracy of g02da is closely related to the accuracy of (F08AEF not in this release) (F02WUF not in this release). These method documents should be consulted.
Parallelism and Performance
None.