|
NAG[g02cbc] NAG[nag_regress_confid_interval] - Simple linear regression confidence intervals for the regression line and individual points
|
|
Calling Sequence
g02cbc(mean, x, y, clm, clp, yhat, yml, ymu, yl, yu, h, res, rms, 'n'=n, 'wt'=wt, 'fail'=fail)
nag_regress_confid_interval(. . .)
Parameters
|
mean - String;
|
|
|
On entry: indicates whether nag_regress_confid_interval (g02cbc) is to include a constant term in the regression.
|
|
The constant term, , is included.
|
|
Constraint: "Nag_AboutMean" or "Nag_AboutZero". .
|
|
|
x - Vector(1..n, datatype=float[8]);
|
|
|
On entry: observations on the independent variable, .
|
|
Constraint: all the values of must not be identical. .
|
|
|
y - Vector(1..n, datatype=float[8]);
|
|
|
On entry: observations on the dependent variable, .
|
|
|
clm - float;
|
|
|
On entry: the confidence level for the confidence intervals for the mean.
|
|
Constraint: . .
|
|
|
clp - float;
|
|
|
On entry: the confidence level for the prediction intervals.
|
|
Constraint: . .
|
|
|
yhat - Vector(1..n, datatype=float[8]);
|
|
|
On exit: the fitted values, .
|
|
|
yml - Vector(1..n, datatype=float[8]);
|
|
|
On exit: contains the lower limit of the confidence interval for the regression line at .
|
|
|
ymu - Vector(1..n, datatype=float[8]);
|
|
|
On exit: contains the upper limit of the confidence interval for the regression line at .
|
|
|
yl - Vector(1..n, datatype=float[8]);
|
|
|
On exit: contains the lower limit of the confidence interval for the individual y value at .
|
|
|
yu - Vector(1..n, datatype=float[8]);
|
|
|
On exit: contains the upper limit of the confidence interval for the individual y value at .
|
|
|
h - Vector(1..n, datatype=float[8]);
|
|
|
On exit: the leverage of each observation on the regression.
|
|
|
res - Vector(1..n, datatype=float[8]);
|
|
|
On exit: the residuals of the regression.
|
|
|
rms - assignable;
|
|
|
Note: On exit the variable rms will have a value of type float.
|
|
On exit: the residual mean square about the regression.
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the arrays x, y, wt, yhat, yml, ymu, yl, yu, h, res.
|
|
On entry: the number of observations, n.
|
|
if , ;
|
|
if , .
|
|
|
'wt'=wt - Vector(1..n, datatype=float[8]); (optional)
|
|
|
Constraint: , for . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_regress_confid_interval (g02cbc) performs a simple linear regression with or without a constant term. The data is optionally weighted, and confidence intervals are calculated for the predicted and average values of y at a given x.
|
|
Description
|
|
nag_regress_confid_interval (g02cbc) fits a straight line model of the form,
where is the expected value of the variable , to the data points
such that
where the values are independent random errors. The th data point may have an associated weight . The values of and are estimated by minimizing (if the weights option is not selected then ). The fitted values are calculated using
where
and the weighted means and are given by
The residuals of the regression are calculated using
and the residual mean square about the regression , is determined using
where (the number of degrees of freedom) has the following values
|
where
|
|
where .
|
Note: the weights should be scaled to give the required degrees of freedom.
The function calculates predicted estimates for a value of , , is given by
this prediction has a standard error
The confidence interval for this estimation of is given by
where refers to the point of the distribution with degrees of freedom (e.g. when and , ). If the user specifies the probability then the lower limit of this interval is
and the upper limit is
The mean value of at is estimated by the fitted value . This has a standard error of
and a confidence interval is given by
For example, if the user specifies the probability then the lower limit of this interval is
and the upper limit is
The leverage, , is a measure of the influence a value has on the fitted line at that point, . The leverage is given by
so it can be seen that
Similar formulae can be derived for the case when the line goes through the origin, that is .
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument mean had an illegal value.
"NE_INT_ARG_LT"
On entry, n must not be less than 1: if .
"NE_NEG_WEIGHT"
On entry, at least one of the weights is negative.
"NE_REAL_ARG_GE"
On entry, clm must not be greater than or equal to 1.0: .
"NE_REAL_ARG_LE"
On entry, clm must not be less than or equal to 0.0: .
"NE_SW_LOW"
On entry, the sum of elements of wt must be greater than 1.0 if and 2.0 if .
"NE_WT_LOW"
On entry, wt must contain at least 1 positive element if or at least 2 positive elements if .
"NE_X_IDEN"
On entry, all elements of x are equal.
"NW_RMS_EQ_ZERO"
Residual mean sum of squares is zero, i.e., a perfect fit was obtained.
|
|
Accuracy
|
|
The computations are believed to be stable.
|
|
|
Examples
|
|
>
|
mean := "Nag_AboutMean":
n := 9:
clm := 0.95:
clp := 0.95:
x := Vector([1, 2, 4, 2, 2, 3, 7, 4, 2], datatype=float[8]):
y := Vector([4, 4, 5.1, 4, 6, 5.2, 9.1, 2, 4.1], datatype=float[8]):
wt := Vector([1, 2, 1, 1, 1, 1, 1, 1, 1], datatype=float[8]):
yhat := Vector(9, datatype=float[8]):
yml := Vector(9, datatype=float[8]):
ymu := Vector(9, datatype=float[8]):
yl := Vector(9, datatype=float[8]):
yu := Vector(9, datatype=float[8]):
h := Vector(9, datatype=float[8]):
res := Vector(9, datatype=float[8]):
NAG:-g02cbc(mean, x, y, clm, clp, yhat, yml, ymu, yl, yu, h, res, rms, 'n' = n, 'wt' = wt):
|
|
|