|
NAG[g02dec] NAG[nag_regsn_mult_linear_add_var] - Add a new independent variable to a general linear regression model
|
|
Calling Sequence
g02dec(q, p, x, rss, 'n'=n, 'ip'=ip, 'tdq'=tdq, 'wt'=wt, 'tol'=tol, 'fail'=fail)
nag_regsn_mult_linear_add_var(. . .)
Parameters
|
q - Matrix(1..n, 1..tdq, datatype=float[8], order=C_order);
|
|
|
|
p - Vector(1.., datatype=float[8]);
|
|
|
On entry: p contains further details of the decomposition used. The first ip elements of p must contain the zeta values for the decomposition (see f01qcc (nag_real_qr) for details). The first ip elements of array p are provided by g02dac (nag_regsn_mult_linear) or by previous calls to nag_regsn_mult_linear_add_var (g02dec).
|
|
On exit: the first ip elements of p are unchanged and the (ip+1)th element contains the zeta value for .
|
|
|
x - Vector(1..n, datatype=float[8]);
|
|
|
On entry: the new independent variable, .
|
|
|
rss - assignable;
|
|
|
Note: On exit the variable rss will have a value of type float.
|
|
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 Section [Further Comments].
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the arrays q, wt, x.
|
|
On entry: the number of observations, .
|
|
Constraint: . .
|
|
|
'ip'=ip - integer; (optional)
|
|
|
Default value: the second dimension of the array q.
|
|
On entry: the number of independent variables already in the model, .
|
|
Constraint: and . .
|
|
|
'tdq'=tdq - integer; (optional)
|
|
|
On entry: the second dimension of the array q as declared in the function from which nag_regsn_mult_linear_add_var (g02dec) is called.
|
|
Constraint: . .
|
|
|
'wt'=wt - Vector(1..n, datatype=float[8]); (optional)
|
|
|
On entry: if weighted estimates are required, then wt must contain the weights to be used in the weighted regression. Otherwise wt need not be defined and may be set to the null pointer NULL, i.e., (double *)0.
|
|
|
'tol'=tol - float; (optional)
|
|
|
On 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: (default: ) .
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_regsn_mult_linear_add_var (g02dec) adds a new independent variable to a general linear regression model.
|
|
Description
|
|
A linear regression model may be built up by adding new independent variables to an existing model. nag_regsn_mult_linear_add_var (g02dec) updates the decomposition used in the computation of the linear regression model. The decomposition may come from g02dac (nag_regsn_mult_linear) or a previous call to nag_regsn_mult_linear_add_var (g02dec). 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 arguments, and is a vector of length of unknown random errors such that var , 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 arguments minimize while the weighted least-squares estimates minimize .
The argument 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 non-zero.
The new argument estimates, , can then be obtained by a call to g02ddc (nag_regsn_mult_linear_upd_model).
The function can be used with , in which case and are initialized.
|
|
Error Indicators and Warnings
|
|
"NE_2_INT_ARG_GE"
On entry, while . These arguments must satisfy .
"NE_INT_ARG_LT"
On entry, n must not be less than 1: .
"NE_NVAR_NOT_IND"
The new independent variable is a linear combination of existing variables. The th column of q is, therefore, null.
"NE_REAL_ARG_LE"
On entry, tol must not be less than or equal to 0.0: .
"NE_REAL_ARG_LT"
On entry, must not be less than 0.0: .
|
|
Accuracy
|
|
The accuracy is closely related to the accuracy of f01qdc (nag_real_apply_q) which should be consulted for further details.
|
|
Further Comments
|
|
It should be noted that the residual sum of squares produced by nag_regsn_mult_linear_add_var (g02dec) may not be correct if the model to which the new independent variable is added is not of full rank. In such a case g02ddc (nag_regsn_mult_linear_upd_model) should be used to calculate the residual sum of squares.
|
|
|
Examples
|
|
>
|
n := 12:
ip := 0:
tdq := 6:
tol := 1e-06:
q := Matrix([[4.32, 0, 0, 0, 0, 0], [5.21, 0, 0, 0, 0, 0], [6.49, 0, 0, 0, 0, 0], [7.1, 0, 0, 0, 0, 0], [7.94, 0, 0, 0, 0, 0], [8.529999999999999, 0, 0, 0, 0, 0], [8.84, 0, 0, 0, 0, 0], [9.02, 0, 0, 0, 0, 0], [9.27, 0, 0, 0, 0, 0], [9.43, 0, 0, 0, 0, 0], [9.68, 0, 0, 0, 0, 0], [9.83, 0, 0, 0, 0, 0]], datatype=float[8], order='C_order'):
p := Vector([0], datatype=float[8]):
wt := Vector([], datatype=float[8]):
x := Vector([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], datatype=float[8]):
NAG:-g02dec(q, p, x, rss, 'n' = n, 'ip' = ip, 'tdq' = tdq, 'wt' = wt, 'tol' = tol):
|
|
|
See Also
|
|
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
g02 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|