| reparamSigDevn.asrtests {asremlPlus} | R Documentation |
Reparamterizes each random (deviations) term involving
devn.fac to a fixed term and ensures that the same term, with
trend.num replacing devn.fac, is included if any
other term with trend.num is included in terms.
Description
This function reparamterizes each random (deviations) term involving
devn.fac to a fixed term and ensures that the same term with
trend.num replacing devn.fac is included if any
other term with trend.num is included in terms. It also
ansures that any term with spl{trend.num} replacing
devn.fac in a term being reparameterized is removed from the model.
Usage
## S3 method for class 'asrtests'
reparamSigDevn(asrtests.obj,terms = NULL,
trend.num = NULL, devn.fac = NULL,
allow.unconverged = TRUE, allow.fixedcorrelation = TRUE,
checkboundaryonly = FALSE,
denDF = "numeric", IClikelihood = "none",
trace = FALSE, update = TRUE,
set.terms = NULL, ignore.suffices = TRUE,
bounds = "P", initial.values = NA,...)
Arguments
asrtests.obj |
an |
terms |
A character string vector giving the random terms that are to be reparameterized. |
trend.num |
A character string giving the name of the numeric covariate that
corresponds to |
devn.fac |
A character string giving the name of the factor that corresponds to
|
allow.unconverged |
A |
allow.fixedcorrelation |
A |
checkboundaryonly |
If |
denDF |
Specifies the method to use in computing approximate denominator
degrees of freedom when |
IClikelihood |
A |
trace |
If TRUE then partial iteration details are displayed when ASReml-R functions are invoked; if FALSE then no output is displayed. |
update |
If |
set.terms |
A character vector specifying the terms that are to have bounds and/or initial values set prior to fitting. |
ignore.suffices |
A logical vector specifying whether the suffices of the
|
bounds |
A |
initial.values |
A character vector specifying the initial values for
the terms specified in |
... |
further arguments passed to |
Value
An asrtests.object containing the components (i) asreml.obj,
(ii) wald.tab, and (iii) test.summary.
Author(s)
Chris Brien
References
Kenward, M. G., & Roger, J. H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 53, 983-997.
See Also
as.asrtests, changeTerms.asrtests,
testranfix.asrtests, testresidual.asrtests,
newfit.asreml, chooseModel.asrtests
Examples
## Not run:
data(WaterRunoff.dat)
asreml.options(keep.order = TRUE) #required for asreml-R4 only
current.asr <- asreml(fixed = log.Turbidity ~ Benches + Sources + Type + Species +
Sources:Type + Sources:Species + Sources:Species:xDay +
Sources:Species:Date,
data = WaterRunoff.dat, keep.order = TRUE)
current.asrt <- as.asrtests(current.asr, NULL, NULL)
#Examine terms that describe just the interactions of Date and the treatment factors
terms.treat <- c("Sources", "Type", "Species", "Sources:Type", "Sources:Species")
date.terms <- sapply(terms.treat,
FUN=function(term){paste("Date:",term,sep="")},
simplify=TRUE)
date.terms <- c("Date", date.terms)
date.terms <- unname(date.terms)
treat.marginality <- matrix(c(1,0,0,0,0,0, 1,1,0,0,0,0, 1,0,1,0,0,0,
1,0,1,1,0,0, 1,1,1,0,1,0, 1,1,1,1,1,1), nrow=6)
rownames(treat.marginality) <- date.terms
colnames(treat.marginality) <- date.terms
choose <- chooseModel(current.asrt, treat.marginality, denDF="algebraic")
current.asrt <- choose$asrtests.obj
current.asr <- current.asrt$asreml.obj
sig.date.terms <- choose$sig.terms
#Remove all Date terms left in the fixed model
terms <- "(Date/(Sources * (Type + Species)))"
current.asrt <- changeTerms(current.asrt, dropFixed = terms)
#if there are significant date terms, reparameterize to xDays + spl(xDays) + Date
if (length(sig.date.terms) != 0)
{ #add lin + spl + devn for each to fixed and random models
trend.date.terms <- sapply(sig.date.terms,
FUN=function(term){sub("Date","xDay",term)},
simplify=TRUE)
trend.date.terms <- paste(trend.date.terms, collapse=" + ")
current.asrt <- changeTerms(current.asrt, addFixed=trend.date.terms)
trend.date.terms <- sapply(sig.date.terms,
FUN=function(term){sub("Date","spl(xDay)",term)},
simplify=TRUE)
trend.date.terms <- c(trend.date.terms, sig.date.terms)
trend.date.terms <- paste(trend.date.terms, collapse=" + ")
current.asrt <- changeTerms(current.asrt, addRandom = trend.date.terms)
current.asrt <- rmboundary(current.asrt)
}
#Now test terms for sig date terms
spl.terms <- sapply(terms.treat,
FUN=function(term){paste("spl(xDay):",term,sep="")},
simplify=TRUE)
spl.terms <- c("spl(xDay)",spl.terms)
lin.terms <- sapply(terms.treat,
FUN=function(term){paste(term,":xDay",sep="")},
simplify=TRUE)
lin.terms <- c("xDay",lin.terms)
systematic.terms <- c(terms.treat, lin.terms, spl.terms, date.terms)
systematic.terms <- unname(systematic.terms)
treat.marginality <- matrix(c(1,0,0,0,0,0, 1,1,0,0,0,0, 1,0,1,0,0,0,
1,0,1,1,0,0, 1,1,1,1,1,0, 1,1,1,1,1,1), nrow=6)
systematic.marginality <- kronecker(matrix(c(1,0,0,0, 1,1,0,0,
1,1,1,0, 1,1,1,1), nrow=4),
treat.marginality)
systematic.marginality <- systematic.marginality[-1, -1]
rownames(systematic.marginality) <- systematic.terms
colnames(systematic.marginality) <- systematic.terms
choose <- chooseModel(current.asrt, systematic.marginality,
denDF="algebraic", pos=TRUE)
current.asrt <- choose$asrtests.obj
#Check if any deviations are significant and, for those that are, go back to
#fixed dates
current.asrt <- reparamSigDevn(current.asrt, choose$sig.terms,
trend.num = "xDay", devn.fac = "Date",
denDF = "algebraic")
## End(Not run)