Learn R Programming

asremlPlus (version 4.3-19)

LSD.frame: Description of an LSD frame

Description

A data.frame that stores Least Significant differences (LSDs) for predictions for a fitted model.

Arguments

Value

A data.frame that can be a component of an alldiffs.object and that contains LSD values and statistics to be used in determining the significance of the pairwise diffrences. In particular, they are used in calculating halfLeastSignificant limits to be included in a predictions.frame.

Exactly what an LSD.frame contains is determined by the following arguments to functions that return an alldiffs.object: LSDtype, LSDby, LSDstatistic, LSDaccuracy and LSDsupplied. The rownames of the LSD.frame indicate, for each of its rows, for what group of predictions the entries in the row were calculated, this being controlled by the LSDtype and LSDby arguments. The values for all of the LSD arguments are stored as attributes to the alldiffs.object and the predictions and, if present backtransforms, components of the alldiffs.object.

An LSD.frame always has the eight columns c, minimumLSD, meanLSD, maximumLSD, assignedLSD, accuracyLSD, false.pos and false.neg.

  1. c: This gives the number of pairwise coomparison of predictions for the combinations of the factor levels given by the row name. If the row name is overall then it is for all predictions.

  2. minimumLSD, meanLSD, maximumLSD: These are computed for either overall, for factor.combinations, per.prediction or supplied, as specified by the LSDtype argument. For overall, the mean, minimum and maximum of the LSDs for all pairwise comparisons are computed. The mean LSD is calculated using the square root of the mean of the variances of all pairwise differences. If factor.combinations was specified for LSDtype when the LSDs were being calculated, then the LSD.frame contains a row for each each levels combination of the factors specified by LSDby. The values in a row are calculated from the variances for all pairwise differences for each factor combination, unless there is only one prediction for a factor.combination, when notional LSDs are calculated that are based on the standard error of the prediction multiplied by the square root of two. A mean LSD is calculated as desribed for overall, except that only the pairwise differences for each levels combination are used. For per.prediction, the minimum, mean and maximum, based, for each prediction, on all pairwise differences involving that prediction are computed; the mean value is based on the square root of the mean of the variances for the pairwise differences. For supplied, the LSD.frame is set up based on the setting of LSDby: a single row with name overall if LSDby is NULL or, if LSDby is a list of factor names, rows for each observed levels combination of the listed factors. The LSDsupplied argument is used to provide the values to be stored in the column assignedLSD.

  3. assignedLSD: The assignedLSD column contains the values that are assigned for use in calculating halfLeastSignificant error.intervals. Its contents are determined by LSDstatistic and LSDsupplied arguments. The LSDsupplied argument allows the direct specification of values to be placed in the assignedLSD column of the LSD.frame.

  4. LSDaccuracy: The LSDaccuracy gives an indication of the proportion that the correct LSD for a single predicted.value might deviate from its assignedLSD value. The contents of the accuracyLSD column is controlled by the LSDaccuracy argument.

  5. false.pos and false.neg: These columns contain the number of false positives and negatives if the assignedLSD value(s) is(are) used to determine the significance of the pairwise predictions differences. Each LSD value in the assignedLSD column is used to determine the significance of pairwise differences that involve predictions for the combination of levels given by the row name for the LSD value.

See recalcLSD.alldiffs for more information.

See Also

recalcLSD.alldiffs, redoErrorIntervals.alldiffs, predictPresent.asreml, predictPlus.asreml

Examples

Run this code
# NOT RUN {
  data(Oats.dat)
  
  ## Use asreml to get predictions and associated statistics

  
# }
# NOT RUN {
  m1.asr <- asreml(Yield ~ Nitrogen*Variety, 
                   random=~Blocks/Wplots,
                   data=Oats.dat)
  current.asrt <- as.asrtests(m1.asr)
  Var.diffs <- predictPlus(m1.asr, classify="Nitrogen:Variety", 
                          wald.tab = current.asrt$wald.tab, 
                          tables = "none")
  
# }
# NOT RUN {
  
  ## Use lmerTest 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("Nitrogen:Variety", rownames(wald.tab)), "denDF"]
    testthat::expect_equal(den.df, 45)
    
    #Set up an alldiffs object, which includes overall LSDs
    Var.diffs <- allDifferences(predictions = Var.preds, classify = "Variety:Nitrogen", 
                                     sed = Var.sed, vcov = Var.vcov, tdf = den.df,
                                     sortFactor = "Variety", decreasing = TRUE)
  }

  if (exists("Var.diffs"))
  {
    ## Use recalcLSD to get LSDs for within Vaietry differences
    Var.LSD.diffs <- recalcLSD(Var.diffs, LSDtype = "factor.combinations", LSDby = "Variety")
  }
# }

Run the code above in your browser using DataLab