Learn R Programming

mixreg (version 2.0-10)

covMix: Calculate the covariance matrix of the parameter estimates for a mixture of regressions.

Description

Produces an estimate of the covariance matrix of the parameter estimates for a fitted mixture of linear regressions, by inverting the observed Fisher information matrix.

Usage

covMix(object,useMC=c("ifNec","no"),...)
covMixMC(object,nsim=100,progRep=TRUE,seed=NULL,...)

Arguments

object

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

useMC

Text string specifying whether to call upon a Monte Carlo procedure if there are problems with the “analytic” procedure (i.e. if the calculated observed Fisher information is singular) or to simply give up and throw an error.

nsim

Positive integer scalar specifying how many simulated samples to generate for the purpose of calculating the Monte Carlo estimate of the covariance matrix.

progRep

Logical scalar; should nominal “progress reports” be issued during the simulation?

seed

Integer scalar. The seed for the random number generator used to produce random samples from which to calculate the Monte Carlo based estimate of the covariance matrix. If this argument is not supplied, then it is randomly sampled from 1:1e5.

...

Optional arguments semiPar and conditional to be passed on to rmixreg() by covMixMC().

Value

The estimated covariance matrix. If the Monte Carlo method was applied then this matrix has an attribute "seed". This attribute will be the value of the seed argument if this was supplied, otherwise it is the randomly generated replacement for this argument.

Details

If different variances are allowed amongst the components (i.e. if object$eqVar is FALSE) then the parameters are taken in the order beta.1, sigsq.1, lambda.1, …, beta.K, sigsq.K for a K component model --- lambda.K is redundant and hence omitted. If equal variances are assumed, the parameters are taken in the order beta.1, lambda.1, …, beta.K, sigsq.

In the foregoing beta refers to the linear coefficients, sigsq to the variance or variances, and lambda to the mixing probabilities.

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.

T. A. Louis (1982). Finding the observed information matrix when using the EM algorithm. Journal of the Royal Statistical Society, series B 44 pp. 226 -- 233.

See Also

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

Examples

Run this code
# NOT RUN {
# Aphids.
    fita   <- mixreg(plntsInf~aphRel,ncomp=2,seed=42,data=aphids)
    cMafi  <- covMix(fita)
    
# }
# NOT RUN {
        cMaMC  <- covMixMC(fita)
    
# }
# NOT RUN {
# 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)
                 )
    fitk   <- mixreg(y ~ x,ncomp=3,data=kilnAoneOut,thetaStart=thStrt)
    
# }
# NOT RUN {
        cMkfi  <- covMix(fitk)
        cMkMC  <- covMixMC(fitk)
        cMkMCs <- covMixMC(fitk,semiPar=TRUE)
    
# }

Run the code above in your browser using DataLab