Learn R Programming

L2E (version 2.0)

l2e_regression_convex_MM: L2E convex regression - MM

Description

l2e_regression_convex_MM performs L2E convex regression via block coordinate descent with MM for updating beta and modified Newton for updating tau.

Usage

l2e_regression_convex_MM(
  y,
  beta,
  tau,
  max_iter = 100,
  tol = 1e-04,
  Show.Time = TRUE
)

Value

Returns a list object containing the estimates for beta (vector) and tau (scalar), the number of outer block descent iterations until convergence (scalar), and the number of inner iterations per outer iteration for updating beta and eta (vectors)

Arguments

y

response

beta

initial vector of regression coefficients

tau

initial precision estimate

max_iter

maximum number of iterations

tol

relative tolerance

Show.Time

Report the computing time

Examples

Run this code
set.seed(12345)
n <- 200
tau <- 1
x <- seq(-2, 2, length.out=n)
f <- x^4 + x
y <- f + (1/tau)*rnorm(n)

## Clean
plot(x, y, pch=16, cex.lab=1.5, cex.axis=1.5, cex.sub=1.5, col='gray')
lines(x, f, lwd=3)

tau <- 1
b <- y
sol <- l2e_regression_convex_MM(y, b, tau)

plot(x, y, pch=16, cex.lab=1.5, cex.axis=1.5, cex.sub=1.5, col='gray')
lines(x, f, lwd=3)
cvx <- fitted(cobs::conreg(y, convex=TRUE))
lines(x, cvx, col='blue', lwd=3)
lines(x, sol$beta, col='red', lwd=3)

## Contaminated
ix <- 0:9
y[45 + ix] <- 14 + rnorm(10)

plot(x, y, pch=16, cex.lab=1.5, cex.axis=1.5, cex.sub=1.5, col='gray')
lines(x, f, lwd=3)

tau <- 1
b <- y
sol <- l2e_regression_convex_MM(y, b, tau)

plot(x, y, pch=16, cex.lab=1.5, cex.axis=1.5, cex.sub=1.5, col='gray')
lines(x, f, lwd=3)
cvx <- fitted(cobs::conreg(y, convex=TRUE))
lines(x, cvx, col='blue', lwd=3)
lines(x, sol$beta, col='red', lwd=3)

Run the code above in your browser using DataLab