g02de adds a new independent variable to a general linear regression model.
Syntax
C# |
---|
public static void g02de( string weight, int n, int ip, double[,] q, double[] p, double[] wt, double[] x, out double rss, double tol, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g02de ( _ weight As String, _ n As Integer, _ ip As Integer, _ q As Double(,), _ p As Double(), _ wt As Double(), _ x As Double(), _ <OutAttribute> ByRef rss As Double, _ tol As Double, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g02de( String^ weight, int n, int ip, array<double,2>^ q, array<double>^ p, array<double>^ wt, array<double>^ x, [OutAttribute] double% rss, double tol, [OutAttribute] int% ifail ) |
F# |
---|
static member g02de : weight : string * n : int * ip : int * q : float[,] * p : float[] * wt : float[] * x : float[] * rss : float byref * tol : float * ifail : int byref -> unit |
Parameters
- 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: .
- ip
- Type: System..::..Int32On entry: , the number of independent variables already in the model.Constraint: and .
- q
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, ]Note: dim1 must satisfy the constraint:On entry: if , q must contain the results of the decomposition for the model with parameters as returned by g02da or a previous call to g02de.If , the first column of q should contain the values of the dependent variable, .On exit: the results of the decomposition for the model with parameters:
- the first column of q contains the updated value of ;
- the columns to are unchanged;
- the first elements of column contain the new column of , while the remaining elements contain details of the matrix .
- p
- Type: array<System..::..Double>[]()[][]An array of size []
- 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.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.If , wt is not referenced and the effective number of observations is .Constraint: if , , for .
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: , the new independent variable.
- rss
- Type: System..::..Double%On exit: the residual sum of squares for the new fitted model.Note: this will only be valid if the model is of full rank, see [Further Comments].
- tol
- Type: System..::..DoubleOn entry: the value of tol is used to decide if the new independent variable is linearly related to independent variables already included in the model. If the new variable is linearly related then is not updated. The smaller the value of tol the stricter the criterion for deciding if there is a linear relationship.Suggested value: .Constraint: .
- 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 linear regression model may be built up by adding new independent variables to an existing model. g02de updates the decomposition used in the computation of the linear regression model. The decomposition may come from g02da or a previous call to g02de. 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 .
The parameter estimates may be found by computing a decomposition of (or in the 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 .
To add a new independent variable, , and have to be updated. The matrix is found such that (or ) is upper triangular. The vector is then updated by multiplying by .
The new independent variable is tested to see if it is linearly related to the existing independent variables by checking that at least one of the values , for , is nonzero.
The new parameter estimates, , can then be obtained by a call to g02dd.
The method can be used with , in which case and are initialized.
References
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
Note: g02de 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
(LDQ) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , or , or , or , or or .
- The new independent variable is a linear combination of existing variables. The th column of q will therefore be null.
Accuracy
The accuracy is closely related to the accuracy of f08ag which should be consulted for further details.
Parallelism and Performance
None.