\name{Sigma_Estimation}
\alias{Sigma_Estimation}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Estimation of the correlation matrix
}
\description{
This function estimates the correlation matrix of the rows of a design matrix in linear models
in the case where the correlation matrix has a block-wise structure.
}
\usage{
Sigma_Estimation(X)
}
\arguments{
  \item{X}{
Design matrix of the linear model considered.
}
}

\value{
\item{mat }{Estimation of the correlation matrix of the rows of X}
\item{alpha }{Estimation of the coefficients of the blocks of the correlation matrix}
\item{group_act }{Indices of the active or non active variables}
%% ...
}

\author{
Wencan Zhu, Celine Levy-Leduc, Nils Ternes
}

\references{
W. Zhu, C. Levy-Leduc, N. Ternes. "A variable selection approach for highly correlated predictors in 
high-dimensional genomic data". arXiv:2007.10768.
}

\examples{
data(X)
Sigma_Estimation(X)

## The function is currently defined as
function (X) 
{
    matrix_cor = cor(X)
    dist_cor <- dist(matrix_cor)
    p <- ncol(matrix_cor)
    fit_clust <- hclust(dist_cor)
    groups <- cutree(fit_clust, k = 2)
    group1 <- which(groups == 1)
    group2 <- which(groups == 2)
    M1 <- matrix_cor[group1, group1]
    M2 <- matrix_cor[group2, group2]
    M3 <- matrix_cor[-group1, -group2]
    est_alpha1 <- mean(M1 - diag(diag(M1)))
    est_alpha3 <- mean(M2 - diag(diag(M2)))
    est_alpha2 <- mean(M3)
    New_cor <- matrix(0, nrow = p, ncol = p)
    New_cor[group1, group1] <- est_alpha1
    New_cor[group2, group2] <- est_alpha3
    New_cor[-group1, -group2] = New_cor[-group2, -group1] = est_alpha2
    diag(New_cor) <- rep(1, p)
    return(list(mat = New_cor, alpha = c(est_alpha3, est_alpha2, 
        est_alpha1), group_act = group2))
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~estimation of the correlation matrix }% use one of  RShowDoc("KEYWORDS")



