Learn R Programming

asremlPlus (version 2.0-2)

predictionplot.asreml: This function plots the predictions for a term, possibly with error bars.

Description

This function plots the predictions y that are based on classify stored in the data.frame data. The package ggplot2 is used to produce the plots. Line plots are produced when variables involving x.num or x.fac are involved in classify for the predictions; otherwise, bar charts are produced. Further, for line charts, the argument panels determines whether a single plot or multiple plots in a single window are produced; for bar charts, the argument panels is ignored.

Usage

predictionplot.asreml(classify, y, data, 
                      x.num = NULL, x.fac = NULL, nonx.fac.order = NULL,  
                      colour.scheme = "colour", panels = "multiple", 
                      graphics.device = "NULL",
                      error.intervals = "Confidence",  titles = NULL, 
                      y.title = NULL, filestem = NULL, ...)

Arguments

classify
a character string giving the combinations of the independent variables on which the predictions are based. It is an interaction type term formed from the independent variables, that is, separating
y
a character string giving the name of the variable that is to be plotted on the Y axis.
data
a data.frame containing the values of the variables to be plotted. It should be consistent with an object of class asremlPredict such as is stored in the pvals component of the <
x.num
A character string giving the name of the numeric covariate that corresponds to x.fac, is potentially included in terms in the fitted model and which corresponds to the x-axis variable. It should
x.fac
A character string giving the name of the factor that corresponds to x.num, is potentially included in terms in the fitted model and which corresponds to the x-axis variable. It should have the same
nonx.fac.order
A character vector giving the order in which factors other than x.fac are to be plotted in facetted plots (i.e. where the number of non x factors is greater than 1). The first factor in the vector
colour.scheme
A character string specifying the colour scheme for the plots. The default is "colour" which produces coloured lines and bars, a grey background and white gridlines. A value of "black"
panels
Possible values are "single" and "multiple". When line plots are to be produced, because variables involving x.num or x.fac are involved in classify for
graphics.device
A character specifying a graphics device for plotting. The default is graphics.device = NULL, which will result in plots being produced on the current graphics device. Setting it to
error.intervals
A character string indicating the type of error interval, if any, to calculate and plot in order to indicate uncertainty in the results. Possible values are "none", "StandardError", "Confidence
titles
A list, each component of which is named for an object name and contains a character string giving a title to use in output (e.g. tables and graphs) for the object. Here they will be used for
filestem
A character sting giving the beginning of the name of the file in which to save the plot. If filestem = NULL, the plot is not saved. The remainder of the file name will be generated automatically and consists o
y.title
The title to be displayed on the y axis of any plot.
...
further arguments passed to ggplot.

Value

  • no values are returned.

See Also

predictiondiffs.asreml, pred.present.asreml, ggplot, Devices

Examples

Run this code
current.asr <- asreml(fixed = log.Turbidity ~ Benches + Sources + Type + Species +
                       Sources:Type + Sources:Species + 
                       Sources:xDay + Species:xDay + Species:Date,
                       data = Runoff.longi.dat, keep.order = TRUE)
predictions <- predict(current.asr, class="Species:Date:xDay", 
                       present=c("Type","Species","Sources"),
                       levels=list(xDay=unique(Runoff.longi.dat$xDay)))$predictions$pvals
predictions <- predictions[predictions$est.status == "Estimable",]
predictionplot.asreml(classify="Species:Date:xDay", diffs$predictions, current.asrt$wald.tab, 
                      x.num = "xDay", x.fac = "Date", 
                      x.title = "Days since first observation",
                      y.title = "Predicted log(Turbidity)",
                      present = c("Type","Species","Sources"))


diffs <- predictparallel.asreml(classify="Species:Date:xDay", 
                                present=c("Type","Species","Sources"), 
                                asreml.obj = current.asr, 
                                x.num = "xDay", x.fac = "Date", 
                                x.pred.values=sort(unique(Runoff.longi.dat$xDay)),
                                x.plot.values=c(0,28,56,84))
predictionplot.asreml(diffs$predictions, current.asrt$wald.tab, 
                                x.num = "xDay", x.fac = "Date", 
                                x.title = "Days since first observation",
                                y.title = "Predicted log(Turbidity)"))

Run the code above in your browser using DataLab