Learn R Programming

mixreg (version 2.0-10)

stepPlot: Plot the steps of the fit of a mixture of regressions model.

Description

Fit a mixture of regressions model, one EM step at a time, plotting the result after each step.

Usage

stepPlot(fmla, ncomp = NULL, eqVar = FALSE, thetaStart = NULL,
         nsteps = 100, eps = 1e-06, digits = 7, maxTry = 5,
         seed = NULL, data)

Arguments

fmla

The formula specifying the regression in the mixture model that is to be fitted.

ncomp

Integer scalar; the number of components in the model. Defaults to 2.

eqVar

See mixreg().

thetaStart

See mixreg().

nsteps

Integer scalar; the maximum number of EM steps to be undertaken.

eps

See mixreg().

digits

The number of digits to which the details about the EM steps are printed out.

maxTry

See mixreg().

seed

See mixreg().

data

A data frame containing the variables to which the model is to be fitted.

Value

An object of class "mixreg". See mixreg(). The model being fitted may not have converged.

Details

Can only be used in an interactive session. May give some insight into convergence problems or into the reasons for unexpected results in the fit.

References

See mixreg().

See Also

mixreg().

Examples

Run this code
# NOT RUN {
 # Interactive session is required.
    vfit <- visualFit(y~x,data=kilnAfull,ncomp=3)
    stepPlot(y ~ x,ncomp=3,data=kilnAfull,thetaStart=vfit$theta)
# }
# NOT RUN {
# The result is clearly slightly wrong in respect of the second ("middle")
# component, which has a slope that is too low.  The outlier in
# kilnAfull may be "pulling up" the left hand end of the fitted line.
# }

Run the code above in your browser using DataLab