$\newcommand{\vbeta}{\boldsymbol{\beta}}$

## Overview

The L2E package implements the computational framework in “A User-Friendly Computational Framework for Robust Structured Regression with the L$$_2$$ Criterion” by Jocelyn T. Chi and Eric C. Chi. This vignette provides code to replicate some examples illustrating the framework in that paper.

## Examples

### Multivariate Regression

The first example provides code to perform multivariate L$$_{2}$$E regression with the Italian bank data from the paper. We begin by loading the bank data from the L2E package.

library(L2E)
y <- bank$y X <- as.matrix(bank[,1:13]) X0 <- as.matrix(cbind(rep(1,length(y)), X)) tau_initial <- 1/mad(y) beta_initial <- matrix(0, 14, 1) The l2e_regression function performs multivariate regression via the L$$_{2}$$ criterion, also called LTE multivariate regression, as described in the paper. It simultaneously obtains an estimate for the coefficient vector $$\vbeta$$ and the precision $$\tau$$. sol <- l2e_regression(y, X0, tau_initial, beta_initial) We can use the estimates for $$\vbeta$$ and $$\tau$$ in sol$beta and sol$tau to identify outlying observations, depicted in blue in the figure below. betaEstimate <- sol$beta
tauEstimate <- sol\$tau

r <- y - X0 %*% betaEstimate
outliers <- which(abs(r) > 3/tauEstimate)
l2e_fit <- X0 %*% betaEstimate
plot(y, l2e_fit, ylab='Predicted values', pch=16, cex=0.8)
points(y[outliers], l2e_fit[outliers], pch=16, col='blue', cex=0.8)