plot.mixreg: Plot a fitted mixture of regressions.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/plot.mixreg.R

Description

Plots the fitted regression lines for a mixture of regression models as fitted by mixreg() (or possibly visualFit()).

Usage

1
2
3
   ## S3 method for class 'mixreg'
plot(x, y, cMeth=c("none","distance","prob"),
           legPos = "topleft", ...)

Arguments

x

An object of class "mixreg" as returned by mixreg() or possibly by visualFit().

y

Not used.

cMeth

Text string specifying the “classification method”. If cMeth is "none" no classification is done. If cMeth is "distance" then points are classified as “belonging” to a component of the mixture according to which of the regression lines they are nearest to, in terms of Euclidean distance. If cMeth is "prob" then points are classified as “belonging” to a component of the mixture according to which of the probabilities gamma[i,j] of their being associated with that component is largest. If the points are classified then they are plotted in colours corresponding to that classification.

legPos

A list with entries x and y, or a text string, specifying the placement of the legend. See legend() for details. The plotting of a legend may be suppressed by setting legPos=NULL.

...

Optional extra arguments for plot(), points() and lines(). These may include xlim, ylim, xlab, ylab, lty, col, pch, and main. If col is supplied, then when cMeth is "none" its first entry determines the colour in which the points are plotted and the remaining entries of col determine the colours in which the fitted lines (corresponding to the different components) are plotted. If the points actually get classified then the entries of col determine the colours for both points and lines. Note that lty is replicated to have length K where K is the number of components in the model. If cMeth is "none" then col is replicated to have length K+1, otherwise it is replicated to have length K.

Value

If cMeth is "none" then no value is returned. Otherwise the value is the data component of the x argument of this function, augmented by an extra column groups. This column is a factor that specifies the component to which each point has been assigned. This data frame also has an attribute "cMeth", the value of the cMeth argument.

Author(s)

Rolf Turner r.turner@auckland.ac.nz

See Also

plot.cband(), plot.mixresid(), qqMix(),

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
   thStrt <- list(
                   list(beta=c(26.07,48808),sigsq=1.1573,lambda=0.33333333),
                   list(beta=c(23.48,32387),sigsq=1.8730,lambda=0.33333333),
                   list(beta=c(-0.0597,20760),sigsq=0.2478,lambda=0.33333333)
                 )
   kfit  <- mixreg(y ~ x,ncomp=3,data=kilnAoneOut,thetaStart=thStrt)
   plot(kfit,pch=8,col=c("red","green","blue","black"))
   plot(kfit,pch=8,col=c("green","blue","black"),cMeth="d")
   plot(kfit,pch=8,col=c("green","blue","black"),cMeth="p")
   afit <- mixreg(plntsInf ~ aphRel,data=aphids,ncomp=2)
   plot(afit,cMeth="p",col=c("blue","red"),pch=20)
   # Separates the points into two groups incredibly clearly!
   npfit <- mixreg(plntsInf ~ 1, data=aphids,ncomp=2)
   plot(npfit,cMeth="p",col=c("blue","red"),pch=20)

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