ratioTransform.alldiffs | R Documentation |
alldiffs.object
.Ratio predictions and error intervals are formed for two levels of a factor,
the ratio.factor
. For each pair of a level of the ratio.factor
in numerator.levels
with a level in denominator.levels
,
the ratio predictions are formed from all combinations of the other factors
as the ratio of the two predictions for each combination, along with confidence
intervals for the ratio predictions computed using the Fieller (1954) method.
The printing of the components produced is controlled by the
tables
argument.
## S3 method for class 'alldiffs'
ratioTransform(alldiffs.obj, ratio.factor,
numerator.levels, denominator.levels,
method = "Fieller", alpha = 0.05,
response = NULL, response.title = NULL,
tables = "predictions", ...)
alldiffs.obj |
An |
ratio.factor |
A |
numerator.levels |
A |
denominator.levels |
A |
method |
A |
alpha |
A |
response |
A |
response.title |
A |
tables |
A |
... |
further arguments passed to |
A list
of predictions.frame
s, each containing the ratio predictions
and their confidence limits for a combination of the numerator.levels
with the
denominator.levels
. It will also contain the values of the variables in the
classify
of alldiffs.obj
that index the ratio predictions, except that
the ratio.factor
is omitted.
If sortFactor
attribute of the alldiffs.object
is set and is not the
ratio.factor
, the predictions and their backtransforms will be sorted using
the sortOrder
attribute of the alldiffs.object
.
Chris Brien
Fieller, E. C. (1954). Some Problems in Interval Estimation. Journal of the Royal Statistical Society.Series B (Methodological), 16, 175-185.
pairdiffsTransform
, linTransform
, predictPlus.asreml
,
as.alldiffs
,
print.alldiffs
, sort.alldiffs
, subset.alldiffs
,
allDifferences.data.frame
,
redoErrorIntervals.alldiffs
,
recalcLSD.alldiffs
, predictPresent.asreml
,
plotPredictions.data.frame
,
as.Date
, predict.asreml
#### Form the ratios and Fieller CIs for RGR Salinity
load(system.file("extdata", "testDiffs.rda", package = "asremlPlus", mustWork = TRUE))
Preds.ratio.RGR <- ratioTransform(diffs.RGR,
ratio.factor = "Salinity",
numerator.levels = "Salt",
denominator.levels = "Control")
#### Form the ratios and Fieller CIs for Nitrogen compared to no Nitrogen
data("Oats.dat")
## Not run:
m1.asr <- asreml(Yield ~ Nitrogen*Variety,
random=~Blocks/Wplots,
data=Oats.dat)
current.asrt <- as.asrtests(m1.asr)
wald.tab <- current.asrt$wald.tab
Var.diffs <- predictPlus(m1.asr, classify="Nitrogen:Variety", pairwise = TRUE,
Vmatrix = TRUE, error.intervals = "halfLeast",
LSDtype = "factor", LSDby = "Variety",
wald.tab = wald.tab)
## End(Not run)
## Use lme4 and emmmeans to get predictions and associated statistics
if (requireNamespace("lmerTest", quietly = TRUE) &
requireNamespace("emmeans", quietly = TRUE))
{
m1.lmer <- lmerTest::lmer(Yield ~ Nitrogen*Variety + (1|Blocks/Wplots),
data=Oats.dat)
## Set up a wald.tab
int <- as.data.frame(rbind(rep(NA,4)))
rownames(int) <- "(Intercept)"
wald.tab <- anova(m1.lmer, ddf = "Kenward", type = 1)[,3:6]
names(wald.tab) <- names(int) <- c("Df", "denDF", "F.inc", "Pr")
wald.tab <- rbind(int, wald.tab)
#Get predictions
Var.emm <- emmeans::emmeans(m1.lmer, specs = ~ Nitrogen:Variety)
Var.preds <- summary(Var.emm)
## Modify Var.preds to be compatible with a predictions.frame
Var.preds <- as.predictions.frame(Var.preds, predictions = "emmean",
se = "SE", interval.type = "CI",
interval.names = c("lower.CL", "upper.CL"))
Var.vcov <- vcov(Var.emm)
Var.sed <- NULL
den.df <- wald.tab[match("Variety", rownames(wald.tab)), "denDF"]
#Create alldiffs object
Var.diffs <- as.alldiffs(predictions = Var.preds,
sed = Var.sed, vcov = Var.vcov,
classify = "Nitrogen:Variety", response = "Yield", tdf = den.df)
}
if (exists("Var.diffs"))
Preds.ratio.OatsN <- ratioTransform(alldiffs.obj = Var.diffs,
ratio.factor = "Nitrogen",
numerator.levels = c("0.2","0.4","0.6"),
denominator.levels = "0.2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.