g_wlsq(G;S;Y;W;XX)
Returns a model corresponding to the weighted multiple least squares regression of one or more independent variables against a given dependent variable.
Function type
Vector only
Syntax
g_wlsq(G;S;Y;W;XX)
Input
Argument | Type | Description |
---|---|---|
G |
any | A space- or comma-separated list of column names Rows are in the same group
if their values for all of the columns listed in If If any of the columns listed in |
S |
integer | The name of a column in which every row evaluates to a 1 or 0, which determines
whether or not that row is selected to be included in the calculation If
If any of the values in
|
Y |
integer or decimal | A column name denoting the dependent variable |
W |
integer or decimal | A column name denoting the weights of the dependent variable |
XX |
integer or decimal | A space- or comma-separated list of column names denoting
the independent variable(s)
|
Return Value
For every row in each group defined by G
(and for those rows where
S
=1, if specified), g_wlsq
computes a weighted multiple least squares regression for the independent variable(s)
XX
against the dependent variable Y
and returns a
special type representing a model for each group in the data. The values in
Y
are weighted by the values in the column listed in
W
.
W
may also be the constant value 1, in which
case the result of g_wlsq()
is identical to that of
g_lsq()
. g_wlsq
returns can be used as an argument to:param(M;P;I)
to extract the regression model parameters, orscore(XX;M;Z)
to score data points according to the regression model
g_wlsq
may be much slower if there is significant multicollinearity
in the data (i.e., if two or more of the independent variables XX
are
nearly perfectly correlated with each other).M
is the column containing the result of g_wlsq
,
use the following function calls to obtain the desired information:param(M;'b';N)
N
th coefficient of the model (corresponding to theN
th data column inXX
)param(M;'p';N)
- p-value associated with the
N
th coefficient of the model param(M;'g';N)
N
th diagonal value of (X
T
X
)-1
, whereX
is the matrix of input valuesparam(M;'valcnt';)
- Count of valid observations (those where
XX
andY
are all non-N/A) in the data param(M;'ybar';)
- Mean of the valid dependent variable observations
Y
in the data param(M;'chi2';)
- Residual sum of squares
param(M;'df';)
- Degrees of freedom of the model
param(M;'r2';)
- Coefficient of determination (R2) for the model
param(M;'adjr2';)
- Adjusted R2 for the model
score(XX;M;)
- Predicted
Y
for data pointsXX
according to the model