public class ANCOVA extends Object implements Serializable, Cloneable
ANCOVA
performs analysis for models that combine the
features of a oneway analysis of variance model with that of a multiple
linear regression model. The basic one-way analysis of covariance model is
$$y_{ij}=\beta_{0i}+\beta_{1}x_{ij1}+\beta_{2}x_{ij2}
+\ldots+\beta_mx_{ijm}+\varepsilon_{ij}$$
$$i=1,2,\ldots,ngroup$$
$$j=1,2,\ldots,n_i$$
where, ngroup is the number of treatment groups, the observed value of
\(y_{ij}\) constitutes the j-th response in the i
-th group, \(\beta_{0i}\) denotes the y intercept for
the regression function for the i-th group, \(\beta_{1}
\), \(\beta_{2}\), ..., \(\beta_{m}
\) are the regression coefficients for the covariates, and the
\(\varepsilon_{ij}\)'s are independently distributed normal
errors with mean zero and variance \(\sigma^2\). This model
allows the regression function for each group to have different intercepts.
However, the remaining m regression coefficients are the same for each
group, i.e., the regression functions are parallel.
In practice, sometimes the regression functions are not parallel. In
addition to estimates for the model assuming parallelism (parallel regression
planes), ANCOVA
computes estimates and summary statistics for
the separate regressions of each group. These estimates can be examined using
the methods getCoefficientTables
and
getANOVATables
.
Estimates for the \(\beta_{0i}\)'s and \(
\beta_{1}\), \(\beta_{2}\), ..., \(
\beta_{m}\) in the model assuming parallelism are returned using the
method getModelCoefficients
. Summary statistics are
also computed for this model and returned by the compute
method.
The adjusted group means, stored in the last column of xymean, are computed using the formula:
$$\hat{\beta}_{0i}+\hat{\beta}_{1}\overline{x}_{1}+ \hat{\beta}_{2}\overline{x}_{2}+\ldots+\hat{\beta}_{ncov}\overline{x}_{ncov} $$where xymean is the matrix returned by getMeans
and
ncov is the number of covariates.
The estimated covariance between the \(i_{1}\)-th and \(i_{2}\)-th adjusted group mean is given by
$$\nu_{i_{1}i_{2}}+\sum_{r=1}^{m}\sum_{s=1}^{m} \overline{x}_{r}\nu_{k+r, k+s}\overline{x}_{s}+\sum_{r=1}^{m}\overline{x}_{r} \nu_{i_{1}, k+r}+\sum_{r=1}^{m}\overline{x}_{r}\nu_{i_{2}, k+r}$$where \(\nu_{pq}\) is the entry in
covb[p-1][q-1]
, where covb
is returned by
getVarCovCoefficients
and is the estimated covariance between
the p-th and q-th estimated coefficients in the regression
function.
Constructor and Description |
---|
ANCOVA(double[][] responses,
double[][][] covariates)
Constructs a one-way classification model with covariates.
|
Modifier and Type | Method and Description |
---|---|
double[] |
compute()
Performs one-way analysis of covariance assuming parallelism and returns
an array containing the parallelism tests for the one-way analysis of
covariance.
|
double[] |
getAdjustedANOVA()
Returns the partial sum of squares for the one-way analysis of
covariance.
|
double[] |
getANCOVA()
Returns an array containing the one-way analysis of covariance assuming
parallelism.
|
double[][] |
getANOVATables()
Returns a matrix of size ngroup by 15 containing the analysis of
variance tables for each linear regression model fitted separately to
each treatment group.
|
double[][] |
getCoefficientTable(int group)
Returns a matrix of size ncov + 1 by 4 containing statistics for a
linear regression model fitted separately for each of the ngroup
treatment groups.
|
double[][][] |
getCoefficientTables()
Returns an array containing statistics for a linear regression model
fitted separately for all ngroup treatments.
|
double[][] |
getMeans()
Returns a matrix containing the unadjusted means for the covariates and
the response variate and the means for the response variate adjusted for
the covariates.
|
double[][] |
getModelCoefficients()
Returns a matrix containing statistics for the regression coefficients
for the model assuming parallelism.
|
int |
getNumberOfMissing()
Returns the number of cases with missing values in
covariates
or responses . |
double[][] |
getR()
Returns the R matrix from the QR decomposition.
|
double[][] |
getVarCovAdjustedMeans()
Returns a matrix containing the estimated variances and covariances for
the adjusted means assuming parallelism.
|
double[][] |
getVarCovCoefficients()
Returns a matrix containing the estimated variances and covariances for
the coefficients returned using
getModelCoefficients . |
public ANCOVA(double[][] responses, double[][][] covariates)
responses
- a double
matrix containing the responses.
Each row in responses
corresponds to a
treatment group. Each row of responses
can
contain a different number of observations. There must
be at least two groups (\(responses.length > 1
\)).covariates
- is a three-dimensional double
array
containing the covariates. The first dimension
corresponds to the number of covariates (consider each
element an individual covariate matrix or
covariates.length
= number of covariates). Each
row in covariates[i]
corresponds to a
treatment group. There must be the same number of
rows, for each covariate, as there are in the
responses matrix (covariates[i].length =
responses.length
). There must be at least one
covariate (\(covariate.length > 1\)).
Each row of covariates[i]
must contain the
same number of elements as the corresponding row in
responses
covariates[i][j].length = responses[j].length
).public double[] getANCOVA()
double
array of length 15 containing the
following values:
index | ANCOVA Table Value |
0 | Degrees of freedom for model |
1 | Degrees of freedom for error |
2 | Total degrees of freedom |
3 | Sum of squares for model |
4 | Sum of squares for error |
5 | Total sum of squares |
6 | Model mean square |
7 | Error mean square |
8 | F statistic |
9 | p-value |
10 | R-squared (in percent) |
11 | Adjusted R-squared (in percent) |
12 | Estimated standard deviation of the model error |
13 | Mean of the response (dependent variable) |
14 | Coefficient of variation (in percent) |
public int getNumberOfMissing()
covariates
or responses
. Cases with any missing values are not
used in the analysis.int
scalar value indicating the number of cases
with missing values in covariates
or
responses
.public double[] getAdjustedANOVA()
double
array containing the partial sum of squares
for the one-way analysis of covariance organized as follows:
index | Description |
0 | Degrees of freedom for groups after covariates. |
1 | Degrees of freedom for covariates after groups. |
2 | Sum of squares for groups after covariates. |
3 | Sum of squares for model (groups and covariates combined). |
4 | F-statistic for groups. |
5 | F-statistic for covariates. |
6 | p-value for groups. |
7 | p-value for covariates. |
public double[][] getMeans()
double
matrix of size ngroup + 1 by ncov
+ 3 containing the unadjusted means for the covariates and
the response variate and the means for the response variate
adjusted for the covariates. Each row for i = 0, 1, ...,
ngroup - 1 corresponds to a group. Row ngroup contains
overall statistics. The means are organized in columns as
follows:
Column | Description |
0 | Number of non-missing cases |
1 thru ncov | Covariate means. |
ncov + 1 | Response mean. |
ncov + 2 | Response mean adjusted assuming parallelism. |
public double[][] getModelCoefficients()
double
matrix of size ngroup + ncov
by 4 containing statistics for the regression coefficients for
the model assuming parallelism. Each row corresponds to a
coefficient in the model. For i = 0, 1, ..., ngroup
- 1, row i
is for the y intercept for the i
-th group. The remaining ncov rows are for the
covariate coefficients. The statistics in the columns are
organized as follows:
Column | Description |
0 | Coefficient estimate. |
1 | Estimated standard error of the estimate. |
2 | t-statistic. |
3 | p-value. |
public double[][] getCoefficientTable(int group)
group
- an int
specifying the group that regression
statistics will be retreived for.double
matrix containing statistics for a
group
. Each row corresponds to the model coefficients. For
row = 0, the statistics relate to the intercept in the regression
model. For row = 1, 2, ..., ncov, the statistics relate to
the slopes for the covariates. The column dimension corresponds
to the row described for getModelCoefficients
as
follows:
Column | Description |
0 | Coefficient estimate. |
1 | Estimated standard error of the estimate. |
2 | t-statistic. |
3 | p-value. |
public double[][][] getCoefficientTables()
double[][][]
array containing statistics for a
linear regression model fitted separately for each of the
ngroup treatment groups. The 3 dimensional array organized
with ngroup rows, ncov + 1 columns, and depth of 4.
Each row corresponds to one of the ngroup treatment
groups. Each column corresponds to the model coefficients. For
column = 0, the statistics relate to the intercept in the
regression model. For column = 1, 2, ..., ncov, the
statistics relate to the slopes for the covariates. The depth
dimension corresponds to the columns described for
getModelCoefficients
as follows:
Column | Description |
0 | Coefficient estimate. |
1 | Estimated standard error of the estimate. |
2 | t-statistic. |
3 | p-value. |
public double[][] getANOVATables()
double
matrix containing the analysis of variance
tables for each linear regression model fitted separately to each
treatment group. The 15 values in the i-th row are for
treatment group i organized as follows:
index | Description |
0 | Degrees of freedom for model |
1 | Degrees of freedom for error |
2 | Total degrees of freedom |
3 | Sum of squares for model |
4 | Sum of squares for error |
5 | Total sum of squares |
6 | Model mean square |
7 | Error mean square |
8 | F statistic |
9 | p-value |
10 | R-squared (in percent) |
11 | Adjusted R-squared (in percent) |
12 | Estimated standard deviation of the model error |
13 | Mean of the response (dependent variable) |
14 | Coefficient of variation (in percent) |
public double[][] getR()
double
matrix of size ngroup + ncov
by ngroup + ncov which contains the R from the QR
decomposition. The R matrix is from the regression assuming
parallelism.public double[][] getVarCovAdjustedMeans()
double
matrix of size ngroup by ngroup
containing the estimated variances and covariances for the
adjusted means assuming parallelism.public double[][] getVarCovCoefficients()
getModelCoefficients
.matrix
of size ngroup + ncov by
ngroup + ncov containing the estimated variances and
covariances for the coefficients returned using
getModelCoefficients
.public double[] compute()
double
array containing the parallelism tests for
the one-way analysis of covariance organized as follows:
index |
Description |
0 | Extra degrees of freedom for model not assuming parallelism. |
1 | Degrees of freedom for error for model not assuming parallelism. |
2 | Degrees of freedom for error for model assuming parallelism. |
3 | Extra sum of squares for model not assuming parallelism. |
4 | Sum of squares for error for model not assuming parallelism. |
5 | Sum of squares for error for model assuming parallelism. |
6 | Mean square for index = 0. |
7 | Mean square for index = 1. |
8 | F statistic |
9 | p-value |
Copyright © 2020 Rogue Wave Software. All rights reserved.