Module
asreml.plotting.residual_plot
residual plots
Members
Produce up to four residual plots in a combined graph
Produce up to four residual plots with the plotly package. All arguments apart from data are optional.
The histogram should look like a Normal distribution, and the Normal and half-Normal plots should be approximately straight lines. There should be approximately constant variance around the zero reference line in the 'fitted','absolute_fitted' and 'index' plots with no substantial trends shown by the lowess curves. Outliers will show in the Normal plots as points at the end of the range that lie a long way off the line.
Arguments:
- data: a pandas data frame containing the residuals and fitted values. If none is provided, then two arrays can be provided in the optional arguments residuals and fitted.
- residuals: If data is provided then this is name of the column which contains the residuals. If this is not provided, then the first column starting with 'res' in data will be used. If data is None, this can be an array containing the residuals.
- fitted: If data is provided then this is then name of the column which contains the fitted values. If this is not provided, then the first column starting with 'fit' in data will be used. If data is None, this can be an array containing the fitted values.
- group_by: If data is provided then this is name of the column which contains groups to colour the points by. If data is None, this can be an array containing the groups. The option palette controls the colours used to plot the groups.
- plots: A list of strings giving up to 4 plots to be produced. These can be: histogram: a histogram of the residuals; fitted: a plot of the residuals vs the fitted values; absolute_fitted: a plot of the absolute residuals vs the fitted values; normal: a plot of the residuals vs their expected values from a normal distribution; half_normal: a plot of the absolute values of the residuals vs their expected values from a normal distribution; index: a plot of the residuals vs their order in the data. At most 4 of the above plots can be selected. Providing more plots will produce a warning with extra plots being dropped.
- title: a string giving the overall title to the plot. No title is supplied when omitted.
- subtitles: whether to display titles above individual subplots.
- file_name: file name to output the plot to, if None, then it is sent to the screen
- plot_lowess: Indicates whether to include a lowess smoothing curve on the trends in residuals for the 'fitted', 'absolute_fitted' or 'index' plots.
- confidence_interval: Type of confidence interval to plot around the points ("simultaneous", "point_wise" or None) For a simultaneous confidence interval, all points from a Normal distribution will lie inside the region (100 * ci_alpha)% of the time. For a point-wise confidence interval, any individual point from a Normal distribution will lie inside the region (100 * ci_alpha)% of the time. Note for a simultaneous confidence interval, their may be no upper limit on for the maximum residual or lower limit on the minimum residual.
- ci_alpha: controls the probability (0-1) used for the confidence region displayed around the points in the normal plot. The type of confidence interval can be controlled with the confidence_interval option.
- palette: The name of a colour palette used when plotting.
See
asreml.plotting.colour_palettefor list of valid values. Alternatively a list of RGB strings or named colours can be supplied to define a custom palette. The first supplied value is for the histogram bars or if there is no groups, the plotted points, otherwise the i'th group is coloured using the i'th colour. - title_size: Relative size of the titles.
- template: the name of a plotly template to use for the style of the graphs. The templates available are 'ggplot2', 'seaborn', 'simple_white', 'plotly', 'plotly_white', 'plotly_dark', 'presentation', 'xgridoff', 'ygridoff', 'gridon' and 'none'.
return a list of colours to use for the data in a plot
Arguments:
- name: name of the colour palette to use, if set to None, then the 'Safe' palette is used. Valid values: Light, Safe, Pastel, Vivid, Alphabet, Dark