The specified terms are simply added or dropped, without testing, from either the fixed or random model and/or the residual (rcov) model replaced. Also, the bounds and/or initial values of some terms can be changed. No hypothesis testing is performed, but a check is made for boundary or singular terms.
A row is added to the test.summary
data.frame
of the
asrtests.object
using the supplied label
and stating
which models have been changed. Information criteria can be included in the
row of the test.summary
. Convergence in fitting the model is checked
and a note included in the action if there was not. All components of
the asrtests.object
are updated.
To only change the terms based on a comparison of information
criteria use changeModelOnIC.asrtests
.
# S3 method for asrtests
changeTerms(asrtests.obj,
dropFixed = NULL, addFixed = NULL,
dropRandom = NULL, addRandom = NULL,
newResidual = NULL, label = "Changed terms",
allow.unconverged = TRUE, allow.fixedcorrelation = TRUE,
checkboundaryonly = FALSE,
trace = FALSE, update = TRUE, denDF = "numeric",
set.terms = NULL, ignore.suffices = TRUE,
bounds = "P", initial.values = NA,
IClikelihood = "none", bound.exclusions = c("F","B","S","C"),
...)
An asrtests.object
containing the components (i) asreml.obj
,
(ii) wald.tab
, and (iii) test.summary
.
An asrtests.object
containing the components (i) asreml.obj
,
(ii) wald.tab
, and (iii) test.summary
.
A single character
string in the form of a formula which,
after addition of ". ~ . -"
and after expansion, specifies the sum
of a set of terms to be dropped from the fixed formula.
The names must match those in the wald.tab
component of the
asrtests.obj
. The fixed terms will be reordered so that
single-variable terms come first, followed by two-variable terms and
so on. Note that
multiple terms specified using a single asreml::at
function
can only be dropped as a whole. If the term was specified using
an asreml::at
function with a single level, then it can be
removed and either the level itself or its numeric
position in the levels returned by the levels
function
can be specified.
A single character
string in the form of a formula which,
after addition of ". ~ . +"
and expansion, specifies the sum
of a set of terms to be added to the fixed formula.
The fixed terms will be reordered so that single-variable terms come
first, followed by two-variable terms and so on.
A single character
string in the form of a formula which,
after addition of " ~ . -"
and expansion, specifies the sum
of a set of terms to be dropped from the random formula.
The terms must match those in the vparameters
component of the
asreml.obj
component in the asrtests.obj
. Note that
multiple terms specified using a single asreml::at
function
can only be dropped as a whole. If the term was specified using
an asreml::at
function with a single level, then it can be
removed and either the level itself or its numeric
position in the levels returned by the levels
function
can be specified.
A single character
string in the form of a formula which,
after addition of " ~ . +"
and expansion, specifies the sum
of a set of terms to be added to the random formula.
A single character
string in the form of a formula which,
after addition of " ~ "
, specifies the residual
(or rcov
) model. To remove the model, enter "-(.)"
.
A character
to use as an entry in the terms
column in
test.summary
to indicate as far as is possible the terms that are
being manipulated.
A logical
indicating whether to accept a new model
even when it does not converge. If FALSE
and the fit does not
converge, the supplied asrtests.obj
is returned.
A logical
indicating whether to accept a new model
even when it contains correlations in the model whose values have been
designated as fixed, bound or singular. If FALSE
and the new model
contains correlations whose values have not been able to be estimated,
the supplied asrtests.obj
is returned. The fit in the
asreml.obj
component of the supplied asrtests.obj
will
also be tested and a warning issued if both fixed correlations are found
in it and allow.fixedcorrelation
is FALSE
.
If TRUE
then boundary and singular terms are not removed by
rmboundary.asrtests
; a warning is issued instead.
If TRUE then partial iteration details are displayed when ASReml-R functions are invoked; if FALSE then no output is displayed.
If TRUE
, and set.terms
is NULL
, then
newfit.asreml
is called to fit the model to be tested,
using the values of the variance parameters stored in
the asreml.object
, that is stored in asrtests.obj
, as starting values.
If FALSE
or set.terms
is not NULL
, then
newfit.asreml
will not use the stored variance parameter
values as starting values when fitting the new model, the only
modifications being (i) those specified by this function's arguments and
(ii) those specified via ...
.
Specifies the method to use in computing approximate denominator
degrees of freedom when wald.asreml
is called. Can be none
to suppress the computations, numeric
for numerical methods,
algebraic
for algebraic methods or default
, the default,
to automatically choose numeric or algebraic computations depending
on problem size. The denominator degrees of freedom are calculated
according to Kenward and Roger (1997) for fixed terms in the dense
part of the model.
A character
vector specifying the terms that are to have
bounds and/or initial values set prior to fitting the new model.
The names must match those in the vparameters
component of the
asreml.obj
component in the new asrtests.object
.
The terms in the model do not need to change from those in the
model in the supplied asrtests.obj
.
A logical vector specifying whether the suffices of the
asreml
-assigned names of the variance terms (i.e. the
information to the right of an "!", other than "R!") is to
be ignored in matching elements of terms
.
If TRUE
for an element of terms
, the suffices
are stripped from the asreml
-assigned names.
If FALSE
for an element of terms
, the element
must exactly match an asreml
-assigned name for a
variance term. This vector must be of length one or the
same length as terms
. If it is of length one then
the same action is applied to the asreml
-assigned
suffices for all the terms in terms
.
A character
vector specifying the bounds to be applied
to the terms specified in set.terms
. This vector
must be of length one or the same length as set.terms
.
If it is of length one then the same constraint is
applied to all the terms in set.terms
.
If any of the bounds are equal to NA then they are
left unchanged for those terms.
A character vector specifying the initial values for
the terms specified in terms
. This vector
must be of length one or the same length as terms
.
If it is of length one then the same initial value is
applied to all the terms in terms
.
If any of the initial.values are equal to NA then they are
left unchanged for those terms.
A character
that controls both the occurrence and the type
of likelihood for information criterion in the test.summary
of the new asrtests.object
. If none
, none are
included. Otherwise, if REML
and family
is set to
asr_guassian
(the default), then the AIC and BIC based
on the Restricted Maximum Likelihood are included; if full
and family
is set to asr_guassian
,
then the AIC and BIC based on the full likelihood, evaluated using
REML estimates, are included.
if family
is asr_binomial
or asr_poisson
,
with dispersion
set to 1, the deviance
is extracted
from object
and used to calculate the AIC and BIC.
(See also infoCriteria.asreml
.)
A character
specifying the bound (constraint) codes that
will result in a variance parameter being excluded from the count of
estimated variance parameters in calculating the information criteria.
If set to NULL
then none will be excluded.
Further arguments passed to asreml
, wald.asreml
and
as.asrtests
.
Chris Brien
Kenward, M. G., & Roger, J. H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 53, 983-997.
as.asrtests
, rmboundary.asrtests
,
testranfix.asrtests
, testresidual.asrtests
,
newfit.asreml
, reparamSigDevn.asrtests
,
chooseModel.asrtests
,
changeModelOnIC.asrtests
, infoCriteria.asreml
if (FALSE) {
terms <- "(Date/(Sources * (Type + Species)))"
current.asrt <- changeTerms(current.asrt, addFixed = terms)
current.asrt <- changeTerms(current.asrt, dropFixed = "A + B", denDF = "algebraic")
data(Wheat.dat)
current.asr <- asreml(yield ~ Rep + WithinColPairs + Variety,
random = ~ Row + Column + units,
residual = ~ ar1(Row):ar1(Column),
data=Wheat.dat)
current.asrt <- as.asrtests(current.asr, NULL, NULL)
current.asrt <- rmboundary(current.asrt)
# Add and drop both fixed and random terms
current.asrt <- changeTerms(current.asrt,
addFixed = "vRow", dropFixed = "WithinColPairs",
addRandom = "spl(vRow)", dropRandom = "units",
checkboundaryonly = TRUE)
# Replace residual with model without Row autocorrelation
current.asrt <- changeTerms(current.asrt,
newResidual = "Row:ar1(Column)",
label="Row autocorrelation")
}
Run the code above in your browser using DataLab