Description Usage Arguments Value References See Also Examples
Returns parameter estimates for finite mixtures of linear regressions with unspecified error structure. Based on Hunter and Young (2012).
1 2 3 4 5 
lmformula 
Formula for a linear model, in the same format used by

bw 
Initial bandwidth value. If NULL, this will be chosen automatically by the algorithm. 
constbw 
Logical: If TRUE, the bandwidth is held constant throughout the algorithm; if FALSE, it adapts at each iteration according to the rules given in Hunter and Young (2012). 
bwmult 
Whenever it is updated automatically,
the bandwidth is equal to 
z.hat 
Initial nxm matrix of posterior probabilities. If NULL, this
is initialized randomly. As long as a parametric estimation method like least
squares is used to estimate 
symm 
Logical: If TRUE, the error density is assumed symmetric about zero. If FALSE, it is not. WARNING: If FALSE, the intercept parameter is not uniquely identifiable if it is included in the linear model. 
betamethod 
Method of calculating beta coefficients in the Mstep. Current possible values are "LS" for leastsquares; "L1" for least absolute deviation; "NP" for fully nonparametric; and "transition" for a transition from least squares to fully nonparametric. If something other than these four possibilities is used, then "NP" is assumed. For details of these methods, see Hunter and Young (2012). 
m 
Number of components in the mixture. 
epsilon 
Convergence is declared if the largest change in any lambda or
beta coordinate is smaller than 
maxit 
The maximum number of iterations; if convergence is never declared
based on comparison with 
verbose 
Logical: If TRUE, then various updates are printed during each iteration of the algorithm. 
... 
Additional parameters passed to the

regmixEM
returns a list of class npEM
with items:
x 
The set of predictors (which includes a column of 1's if 
y 
The response values. 
lambda 
The mixing proportions for every iteration in the form of a matrix with m columns and (#iterations) rows 
beta 
The final regression coefficients. 
posterior 
An nxm matrix of posterior probabilities for observations. 
np.stdev 
Nonparametric estimate of the standard deviation, as given in Hunter and Young (2012) 
bandwidth 
Final value of the bandwidth 
density.x 
Points at which the error density is estimated 
density.y 
Values of the error density at the points 
symmetric 
Logical: Was the error density assumed symmetric? 
loglik 
A quantity similar to a loglikelihood, computed just like a standard loglikelihood would be, conditional on the component density functions being equal to the final density estimates. 
ft 
A character vector giving the name of the function. 
Hunter, D. R. and Young, D. S. (2012) Semiparametric Mixtures of Regressions, Journal of Nonparametric Statistics 24(1): 1938.
Scott, D. W. (1992) Multivariate Density Estimation, John Wiley & Sons Inc., New York.
Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis, Chapman & Hall, London.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  data(tonedata)
## By default, the bandwidth will adapt and the error density is assumed symmetric
set.seed(100)
a=spregmix(tuned~stretchratio, bw=.2, data=tonedata, verb=TRUE)
## Look at the sp mixreg solution:
plot(tonedata)
abline(a=a$beta[1,1],b=a$beta[2,1], col=2)
abline(a=a$beta[1,2],b=a$beta[2,2], col=3)
## Look at the nonparametric KDbased estimate of the error density,
## constrained to be zerosymmetric:
plot(xx<a$density.x, yy<a$density.y, type="l")
## Compare to a normal density with mean 0 and NPestimated stdev:
z < seq(min(xx), max(xx), len=200)
lines(z, dnorm(z, sd=sqrt((a$np.stdev)^2+a$bandwidth^2)), col=2, lty=2)
# Add bandwidth^2 to variance estimate to get estimated var of KDE
## Now add the sp mixreg estimate without assuming symmetric errors:
b=spregmix(tuned~stretchratio, bw=.2, , symm=FALSE, data=tonedata, verb=TRUE)
lines(b$density.x, b$density.y, col=3)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.