cband: Calculate confidence and prediction bands for mixtures of...

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

View source: R/cband.R

Description

Produces confidence and prediction bands, two-sided or upper or lower, for the lines fitted in a model consisting of a mixture of one-variable regressions.

Usage

1
cband(object, alpha=0.05, MC=FALSE, xlen=100, plot=FALSE,...)

Arguments

object

Object describing the fitted mixture of regressions, as returned by mixreg().

alpha

One minus the confidence level for the confidence and prediction bands; e.g. alpha = 0.05 for 95% confidence.

MC

Logical scalar; should the covariance matrix of the parameter estimates be calculated by a Monte Carlo procedure? If the covariance matrix is extracted from object, the "MC" attribute of this matrix is checked. If argument MC disagrees with this attribute then the covariance matrix is re-calculated using the appropriate procedure.

xlen

The number of points to be plotted in the band envelopes. The x-values of the points will be equispaced from the minimum to the maximum of the predictor variable.

plot

Logical scalar; should a plot of the fitted model and confidence and prediction bands be produced immediately?

...

Extra arguments to be passed to covMixMC() if the covariance matrix needs to be (re-) calculated and MC is TRUE.

Details

The prediction bands are conditional in that the associated probability is conditional upon the associated observation being generated by the relevant component of the mixture.

The covariance matrix need to construct the confidence and prediction bands is extracted from object, given that object has an entry named "covMat" (i.e. if the call to mixreg that produced object was made with covMat=TRUE). If object has no such entry then covMix() is called to produce the covariance matrix. (Such a call may take a bit of time.)

Value

An object of class "cband", consisting of a list with entries:

theta

The parameter list from object (as returned by mixreg).

intercept

The logical value from object indicating whether intercepts were fitted.

x

The predictor for the model (extracted from the data entry of object).

y

The response for the model (extracted from the data entry of object).

xf

The equispaced sequence of values, extending from min(x) to max(x), at which the values of the band envelopes were calculated.

bnds

A list with one entry for each component of the mixture. Each entry is a matrix with 8 columns (lower and upper confidence and prediction bounds for one-sided intervals and lower and upper confidence and prediction bounds for two-sided interval).

alpha

Numeric scalar; the alpha argument.

varnms

Character vector of length two providing the names of the predictor (first entry) and of the response (second entry).

If plot is TRUE the value is returned invisibly.

Side Effects

If plot is TRUE a plot of the fit and the confidence and prediction bands is produced in whatever device is currently open or on screen if no device is open.

Warning

If MC is FALSE then an error may be thrown if the observed Fisher information (the inverse of which is use as the estimated covariance matrix) is singular. Note that if MC is FALSE then any call to covMix() is made with useMC="no".

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

ncMcTest(), covMix(), mixreg(), plot.cband(), residuals.mixreg(), plot.mixresid(), qqMix(),

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Aphids.
    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(plntsInf~aphRel,ncomp=2,thetaStart=thStrt,
                     covMat=TRUE,data=aphids)
    cbds   <- cband(fit,plot=TRUE)
    plot(cbds) # Same plot as was produced by call to cband().
# Kilns.
   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)
                 )
    fit    <- mixreg(y ~ x,ncomp=3,data=kilnAoneOut,thetaStart=thStrt)
    ## Not run:  # Takes too long.
        res    <- residuals(fit,std=TRUE)
        qqMix(res) # No way are these residuals Gaussian!
        cbdsG  <- cband(fit)
        cbdsMC <- cband(fit,MC=TRUE)
        plot(cbdsG)
        plot(cbdsMC)
    # Same-same, despite the lack of Gaussianity!
    
## End(Not run)

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