Learn R Programming

mixtools (version 0.3.0)

regmixEM.chgpt: EM Algorithm for Mixtures of Regressions with a Changepoint

Description

Returns EM algorithm output for a mixture of a regression with a changepoint and a simple linear regression.

Usage

regmixEM.chgpt(y, x, lambda = NULL, gamma = NULL, beta = NULL,
               sigma = NULL, k = 2, T = 3, t = NULL, 
               epsilon = 1e-08, maxit = 10000, verb = FALSE)

Arguments

y
An n-vector of response values.
x
An n-vector of predictor values. A column of ones is automatically appended to x.
lambda
Initial value of mixing proportions. Entries should sum to 1. If NULL, then lambda is random from uniform Dirichlet.
gamma
Initial value of gamma parameters for the changepoint component. Should be a 3-dimenstional vector. If NULL, then gamma has standard normal entries according to a binning method done on the data.
beta
Initial value of beta parameters for the simple linear regression component. Should be a 2-dimenstional vector. If NULL, then beta has standard normal entries according to a binning method done on the data.
sigma
A vector of standard deviations. If NULL, then 1/sigma$^2$ has random standard exponential entries according to a binning method done on the data.
k
Number of components. Currently, this value must be set equal to 2.
T
The number of values to leave off for the range of all possible changepoints to be tested.
t
Initial value of the changepoint to consider.
epsilon
The convergence criterion.
maxit
The maximum number of iterations.
verb
If TRUE, then various updates are printed during each iteration of the algorithm.

Value

  • regmixEM.chgpt returns a list of class mixEM with items:
  • lambdaThe final mixing proportions.
  • gammaThe final regression coefficients for the changepoint component.
  • betaThe final regression coefficients for the simple linear regression component.
  • sigmaThe final standard deviations.
  • cutpointThe estimated value for the changepoint in the changepoint component.
  • loglikThe final log-likelihood.
  • posteriorA nx2 matrix of posterior probabilities for observations.
  • all.loglikA vector of each iteration's log-likelihood.
  • restartsThe number of times the algorithm restarted due to unacceptable choice of initial values.
  • ftA character vector giving the name of the function.

See Also

regmixEM

Examples

Run this code
## EM output for simulated data.
 
w<-rbinom(100, 1, .5)
cpt<-50
x<-sort(runif(100, 0, 10))
x1<-cbind(1, x)
xt<-cbind(x1, (x-x[cpt])*(x>x[cpt]))
beta<-c(5, -1)
gamma<-c(15, -1, 2)
y<-w*rnorm(100, mean = xt%*%gamma, sd = .1) + 
   (1-w)*rnorm(100, mean = x1%*%beta, sd = .1)
out<-regmixEM.chgpt(y = y, x = x, t = cpt, beta = beta, 
                    gamma = gamma, verb = TRUE, epsilon = 1e-03)
out

Run the code above in your browser using DataLab