% \VignetteIndexEntry{Regularization and Variable Selection for Parametric Models (3)}
% \VignetteDepends{lqa}

\documentclass[a4paper]{article}

\title{Regularization and Variable Selection for Parametric Models (3)}

\begin{document}

\maketitle


<<echo=FALSE,eval=FALSE>>=
options(width=80)
@

<<eval=FALSE>>=
library(lqa)
@

<<eval=FALSE>>=
library(catdata)
data(heart, package="catdata")

X<-heart[,-1]
y<-heart[,1]
X.std<-scale(X)
p<-ncol(X)
n<-length(y)
family <- binomial()
n.fold<-10


ylab.text<-""
xlab.text<-""
Width = 6 
Height = 6 
oma.vec<-c(1,1,1,3) 
size.axis=1.4 
size.lab=1.4 
size.main=1.4 
size.right=1.2 
size.width=2.0
colour=1
@



LASSO IMPROVED CORRELATION BASED (with $L_1$ term)

Fixed Tuning parameter
<<eval=FALSE>>=
lambda2 <- 0.05

### COEF BUILD-UPS

main.text<-"Lasso Improved Correlation Based"
penalty.family<-licb

Plot.mat<-plot.lqa (y = y, x = X, family=family, penalty.family=penalty.family,
offset.values = c (NA, lambda2),add.MLE = FALSE, ret.true=TRUE,really.plot = FALSE,
show.standardized=TRUE)
@


<<fig=TRUE,eval=FALSE>>=

par(oma=oma.vec,cex.axis=size.axis,cex.lab=size.lab,cex.main=size.main)
matplot(Plot.mat$s1,Plot.mat$beta.mat,type="l",ylab=ylab.text,xlab=xlab.text,
main=main.text,lwd=size.width)
axis(4, at = Plot.mat$beta.mat[1, ], labels = colnames(X), adj = 0, las = 1,
cex.axis=size.right)

@


 CORREALTION BASED


COEF BUILD-UPS
<<eval=FALSE>>=
main.text<-"Correlation Based"
penalty.family<-penalreg

Plot.mat<-plot.lqa (y = y, x = X, family=family, penalty.family=penalty.family,
add.MLE = FALSE, ret.true=TRUE,really.plot = FALSE,show.standardized=TRUE,gamma=0.01)
@


<<fig=TRUE,eval=FALSE>>=

par(oma=oma.vec,cex.axis=size.axis,cex.lab=size.axis,cex.main=size.main)
matplot(Plot.mat$s1,Plot.mat$beta.mat,type="l",ylab=ylab.text,xlab=xlab.text,
main=main.text,lwd=size.width)
axis(4, at = Plot.mat$beta.mat[1, ], labels = colnames(X), adj = 0, las = 1,
cex.axis=size.right)

@

 Forward Boost mit correlation based

<<eval=FALSE>>=
parcorr=10.5
max.steps=20
Path<- ForwardBoost (X.std, y,family = binomial(), penalty = penalreg(parcorr),
intercept =  TRUE,   nu = 1, monotonic = TRUE,control=lqa.control(max.steps=20,
conv.stop = FALSE))
@

<<fig=TRUE,eval=FALSE>>=

par(oma=oma.vec,cex.axis=size.axis,cex.lab=size.axis,cex.main=size.main)
matplot(rowSums(abs(Path$beta.mat[,-1]))/max(rowSums(abs(Path$beta.mat[,-1]))),
Path$beta.mat[,-1]*sqrt(n),type="l",ylab=ylab.text,xlab=xlab.text,main=
  "ForwardBoost",lwd=2.0)
axis(4, at = Path$beta.mat[max.steps, -1]*sqrt(n), labels = colnames(X),
adj = 0, las = 1,cex.axis=size.right)
@



\end{document}