plot.mixresid: Plot residuals for a fitted mixture of linear regressions.

Description Usage Arguments Details Value Side Effects ACKNOWLEDGEMENT Author(s) References See Also Examples

View source: R/plot.mixresid.R

Description

Plots the residuals against predictors or fitted values using symbols whose size is proportional to the probability that the associated observation was generated by the associated component of the model.

Usage

1
2
3
4
5
## S3 method for class 'mixresid'
plot(x, vsFit=FALSE, whichx=1,digits=2,
                        shape=c("disc","lozenge","square","none"),
                        ngon=20, size=1, gexp=1, polycol=NULL,
                        xlab=NULL, ...)

Arguments

x

An object of class "mixresid", which consists of a list with entries providing the residuals, the relevant probabilities, the predictors, and the observations, as returned by residuals.mixreg(). When plotting against fitted values, it is probably better to used the standardized residuals, i.e. residuals.mixreg() should be called with std=TRUE.

vsFit

Logical scalar; should the residuals be plotted against the fitted values?

whichx

Integer scalar that indicates which predictor to plot against if there is more than one predictor. I.e. whichx indicates which column of the x matrix to use. If vsFit is TRUE, then whichx is ignored.

digits

Integer scalar giving the number of digits to which the fitted values should be rounded when these values are used as axis labels. Such use occurs only when there are no predictors in the model (i.e. when the formula is of the form y ~ 1 — so that there is a single fitted value for each component) and when vsFit is TRUE. In all other circumstances digits is ignored.

shape

Character string indicating the shape of the plotting symbol; may be abbreviated, e.g. to "d", "l", "s" or "n". If shape is "none" then “ordinary” plotting is done, using the usual plotting symbols etc. This can be much faster, but somewhat defeats the purpose of this plotting function in that the resulting plots can be misleading. Using shape="n" allows the user to compare the misleading result with plots in which “improbable” residuals are downweighted.

ngon

The "disc" shape is actually a regular polygon; ngon specifies how many sides it should have; ignored if shape is not equal to "disc".

size

Positive numeric scalar. A scale factor to change the absolute sizes of the plotting symbols; values larger than 1 make the symbols larger; values less than 1 make them smaller.

gexp

Non-negative numeric scalar (“gamma exponent”). The power to which the conditional “component probabilities” gamma[i,j] should be raised. The default value 1 causes the area of the plotting symbol to be proportional to the probability. Setting gexp=0.5 effectively causes the diameter of the plotting symbol to be proportional to the probability. Setting gexp=3 causes the area of the plotting symbol to be proportional to the square of the probability. Increasing gexp decreases the visual impact of plotted points with low probability, and vice versa. Setting gexp=0 has effectively the same impact as setting shape="none".

polycol

Character string specifying the colour in which polygons are plotted. This encompasses both the colour of the border of the polygon (specified as border argument in polygon()) and and the “fill” colour (specified as col argument in polygon()). Note that the border colour and fill colour are hard-wired to be the same in this function — there is no option to make them different. The “exception” to this rule results from using the default value of polycol, i.e. NULL. This causes the border colour to be par("fg") (usually black) and the polygons not to be filled (so that the fill colour is “transparent”, i.e. in effect (usually) white.

xlab

The x label for the plot; defaults to "x" unless vsFit is TRUE, in which case it defaults to "fitted values".

...

Additional arguments (e.g. pch, col, cex, ...) to be passed to the points() function which actually plots the points when shape="none".

Details

This function is a "method" for plot. The plot produced is visually assessed by ignoring or discounting small symbols.

The label for the x-axis (“xlab”) is by default taken from the vnms component of the object being plotted. If you find this label to be unsatisfactory, supply the argument xlab.

Value

None. This function is called for its side effect of drawing a residual plot.

Side Effects

A residual plot is produced in whatever device is currently open.

ACKNOWLEDGEMENT

The idea of creating residual plots for regression mixtures by making the symbol size proportional to the associated probability is due to Prof. Adrian Baddeley who was, at the time, at the University of Western Australia. He is now (2021) at Curtin University.

Author(s)

Rolf Turner r.turner@auckland.ac.nz

References

T. Rolf Turner (2000). Estimating the rate of spread of a viral infection of potato plants via mixtures of regressions. Applied Statistics 49 Part 3, pp. 371 – 384.

See Also

mixreg(), residuals.mixreg() cband(), plot.cband(), qqMix()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    thStrt <- list(list(beta=c(3.0,0.1),sigsq=16,lambda=0.5),
                   list(beta=c(0.0,0.0),sigsq=16,lambda=0.5))
    fit    <- mixreg(aphRel,plntsInf,ncomp=2,thetaStart=thStrt,data=aphids)
    rrr    <- residuals(fit)
    plot(rrr)
    plot(rrr,shape="n")
# The plot with shape="n" gives an impression that variability
# increases with aphRel; the plot with default shape ("disc")
# does not give that impression
    rrs    <- residuals(fit,std=TRUE)
    plot(rrs,vsFit=TRUE)
    plot(rrs,vsFit=TRUE,shape="n")
    fit <- mixreg(plntsInf ~ 1,data=aphids,ncomp=2)
    rrr <- residuals(fit,std=TRUE)
    plot(rrr,vsFit=TRUE,digits=4,polycol="blue")

mixreg documentation built on Oct. 14, 2021, 9:12 a.m.