Need expert statistical support?

More Info

Module

asreml.plotting

plotting routines

Members

function

residual_plot

#
def residual_plot( data=None, residuals=None, fitted=None, group_by=None, plots: Union[str, list[str], NoneType] = None, title: Optional[str] = None, subtitles: bool = False, file_name: Optional[str] = None, plot_lowess: bool = True, ci_alpha: float = 0.95, confidence_interval: str = 'simultaneous', palette: Union[str, list[str], NoneType] = None, title_size: float = 0.75, template: str = 'plotly_white'):

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_palette for 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'.
function

colour_palette

#
def colour_palette(name: Union[str, list[str], NoneType] = 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
function

variogram

#
def variogram( data=None, x=None, y=None, z=None, composite: bool = True, metric: str = 'euclidean', angle: Union[list[float], float, NoneType] = 0.0, angle_tolerance: float = 180, n_lags: int = 20, max_distance: float = 0.5, lag: float = nan, lag_tolerance=0.5, grid: bool = True, graph: bool = True, title: Optional[str] = None, template: str = 'plotly_white', title_size: float = 1, plot_lowess: bool = True, palette: Union[str, list[str], NoneType] = None, colour_scale: str = 'plasma', file_name: Optional[str] = None):

Calculate variogram of three series (x,y,z) and return it as a pandas dataframe.

The data frame includes the following columns:

NPoints: The number of pairs in the lag. Vari: The variogram estimate. For a grid variogram only: DistX: The original x coordinates. DistY: The original y coordinates. otherwise: Distance: The average distance for pairs in the lag bin. Direction: direction in degrees.

Arguments:
  • composite: form a composite variogram (True or False); default = True a non-composite variogram separates the differences into left and right differences.
  • metric: the metric to use to calculate lag lengths (euclidean or manhattan); default euclidean.
  • max_distance: the maximum lag to calculate (given as a proportion of the range); default 0.5.
  • n_lags: number of steps in the lag bins between 0 and max_distance*range; default 20.
  • angle: list of angles in degrees to use as the centre of bins; default [0] i.e. combine all angles.
  • angle_tolerance the tolerance in degrees around the centre of the angle bin; default 180.
  • lag: number giving the step between lags. If this is provided, max_distance is ignored and max_distance will be taken as n_lags*lag.
  • lag_tolerance: the tolerance from the lag at the centre of the bin, used when allocating points to bins; default 0.5
  • grid: produce a variogram on the grid coordinates (True or False); default True. The points must lie on a rectangular grid if this is True.
  • graph: plot the variogram (True or False).
  • title: a string giving the overall title to the plot. The default is
  • an automatic title 'Variogram for vs '.
  • title_size: relative size of the titles; default 1.
  • 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'. The default is 'plotly_white'.
  • palette: The name of a colour palette used to plot the directions in. The available options are 'Alphabet','Dark','Light','Pastel','Safe' and 'Vivid'. The default is 'Vivid'.
  • colour_scale: The name of a plotly colour scale used to plot the variogram surface with. The default is 'plasma'.
  • plot_lowess: indicating whether to include a lowess smoothing curve on the trends in variances for each angle (True or False).

Want to sharpen your statistics skills?

Browse Courses