g02dg calculates the estimates of the parameters of a general linear regression model for a new dependent variable after a call to g02da.

Syntax

C#
public static void g02dg(
	string weight,
	int n,
	double[] wt,
	ref double rss,
	int ip,
	int irank,
	double[] cov,
	double[,] q,
	bool svd,
	double[] p,
	double[] y,
	double[] b,
	double[] se,
	double[] res,
	double[] wk,
	out int ifail
)
Visual Basic
Public Shared Sub g02dg ( _
	weight As String, _
	n As Integer, _
	wt As Double(), _
	ByRef rss As Double, _
	ip As Integer, _
	irank As Integer, _
	cov As Double(), _
	q As Double(,), _
	svd As Boolean, _
	p As Double(), _
	y As Double(), _
	b As Double(), _
	se As Double(), _
	res As Double(), _
	wk As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g02dg(
	String^ weight, 
	int n, 
	array<double>^ wt, 
	double% rss, 
	int ip, 
	int irank, 
	array<double>^ cov, 
	array<double,2>^ q, 
	bool svd, 
	array<double>^ p, 
	array<double>^ y, 
	array<double>^ b, 
	array<double>^ se, 
	array<double>^ res, 
	array<double>^ wk, 
	[OutAttribute] int% ifail
)
F#
static member g02dg : 
        weight : string * 
        n : int * 
        wt : float[] * 
        rss : float byref * 
        ip : int * 
        irank : int * 
        cov : float[] * 
        q : float[,] * 
        svd : bool * 
        p : float[] * 
        y : float[] * 
        b : float[] * 
        se : float[] * 
        res : float[] * 
        wk : float[] * 
        ifail : int byref -> unit 

Parameters

weight
Type: System..::..String
On entry: indicates if weights are to be used.
weight="U"
Least squares estimation is used.
weight="W"
Weighted least squares is used and weights must be supplied in array wt.
Constraint: weight="U" or "W".
n
Type: System..::..Int32
On entry: n, the number of observations.
Constraint: nip.
wt
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: the dimension of the array wt must be at least n if weight="W", and at least 1 otherwise.
On entry: if weight="W" >, wt must contain the weights to be used in the weighted regression.
If wt[i-1]=0.0, the ith observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights.
If weight="U", wt is not referenced and the effective number of observations is n.
Constraint: if weight="W", wt[i]0.0, for i=0,1,,n-1.
rss
Type: System..::..Double%
On entry: the residual sum of squares for the original dependent variable.
On exit: the residual sum of squares for the new dependent variable.
Constraint: rss>0.0.
ip
Type: System..::..Int32
On entry: p, the number of independent variables (including the mean if fitted).
Constraint: 1ipn.
irank
Type: System..::..Int32
On entry: the rank of the independent variables, as given by g02da.
Constraint: irank>0, and if svd=false, then irank=ip, else irankip.
cov
Type: array<System..::..Double>[]()[][]
An array of size [ip×ip+1/2]
On entry: the covariance matrix of the parameter estimates as given by g02da.
On exit: the upper triangular part of the variance-covariance matrix of the ip parameter estimates given in b. They are stored packed by column, i.e., the covariance between the parameter estimate given in b[i-1] and the parameter estimate given in b[j-1], ji, is stored in cov[j×j-1/2+i-1].
q
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, ip+1]
Note: dim1 must satisfy the constraint: dim1n
On entry: the results of the QR decomposition as returned by g02da.
On exit: the first column of q contains the new values of c, the remainder of q will be unchanged.
svd
Type: System..::..Boolean
On entry: indicates if a singular value decomposition was used by g02da.
svd=true
A singular value decomposition was used by g02da.
svd=false
A singular value decomposition was not used by g02da.
p
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: the dimension of the array p must be at least ip if svd=false, and at least ip×ip+2×ip otherwise.
On entry: details of the QR decomposition and SVD, if used, as returned in array p by g02da.
If svd=false, only the first ip elements of p are used; these contain the zeta values for the QR decomposition (see (F08AEF not in this release) for details).
If svd=true, the first ip elements of p contain the zeta values for the QR decomposition (see (F08AEF not in this release) for details) and the next ip×ip+ip elements of p contain details of the singular value decomposition.
y
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the new dependent variable, ynew.
b
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On exit: the least squares estimates of the parameters of the regression model, β^.
se
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On exit: the standard error of the estimates of the parameters.
res
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: the residuals for the new regression model.
wk
Type: array<System..::..Double>[]()[][]
An array of size [5×ip-1+ip×ip]
On entry: if svd=true, wk must be unaltered from the previous call to g02da or g02dg.
If svd=false, wk is used as workspace.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

g02dg uses the results given by g02da to fit the same set of independent variables to a new dependent variable.
g02da computes a QR decomposition of the matrix of p independent variables and also, if the model is not of full rank, a singular value decomposition (SVD). These results can be used to compute estimates of the parameters for a general linear model with a new dependent variable. The QR decomposition leads to the formation of an upper triangular p by p matrix R and an n by n orthogonal matrix Q. In addition the vector c=QTy (or QTW1/2y) is computed. For a new dependent variable, ynew, g02dg computes a new value of c=QTynew or QTW1/2ynew.
If R is of full rank, then the least squares parameter estimates, β^, are the solution to
Rβ^=c1,
where c1 is the first p elements of c.
If R is not of full rank, then g02da will have computed an SVD of R,
R=Q*D000PT,
where D is a k by k diagonal matrix with nonzero diagonal elements, k being the rank of R, and Q* and P are p by p orthogonal matrices. This gives the solution
β^=P1D-1Q*1Tc1,
P1 being the first k columns of P, i.e., P=P1P0, and Q*1 being the first k columns of Q*. Details of the SVD are made available by g02da in the form of the matrix P*:
P*=D-1P1TP0T.
The matrix Q* is made available through the workspace of g02da.
In addition to parameter estimates, the new residuals are computed and the variance-covariance matrix of the parameter estimates are found by scaling the variance-covariance matrix for the original regression.

References

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
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 (LDQ) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,ip<1,
orn<ip,
orirank0,
orsvd=false and irankip,
orsvd=true and irank>ip,
orrss0.0,
orweight"U" or "W".
ifail=2
On entry,weight="W" and a value of wt<0.0.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The same accuracy as g02da is obtained.

Parallelism and Performance

None.

Further Comments

The values of the leverages, hi, are unaltered by a change in the dependent variable so a call to g02fa can be made using the value of h from g02da.

Example

See Also