Commit eadd4706 by Eric Coissac

remove things related to the formal computation of IRls

parent e1365710
#' @author Christelle Gonindard-Melodelima
#' @author Eric Coissac
NULL
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
icor <- function(x, y = NULL) {
if (is.data.frame(y)) {
y <- as.matrix(y)
}
if (is.data.frame(x)) {
x <- as.matrix(x)
}
if (!is.matrix(x) && is.null(y)) {
stop("supply both 'x' and 'y' or a matrix-like 'x'")
}
if (!(is.numeric(x) || is.logical(x))) {
stop("'x' must be numeric")
}
stopifnot(is.atomic(x))
if (!is.null(y)) {
if (!(is.numeric(y) || is.logical(y))) {
stop("'y' must be numeric")
}
stopifnot(is.atomic(y))
}
if (!is.matrix(x)) {
x <- t(t(x))
}
if (is.null(y)) {
y <- x
}
if (!is.matrix(y)) {
y <- t(t(y))
}
xc <- scale(x, scale = FALSE, center = TRUE)
yc <- scale(y, scale = FALSE, center = TRUE)
n <- nrow(x)
cov <- crossprod(xc, yc) / (n - 1)
print(cov)
sdx <- apply(x, MARGIN = 2, sd)
sdy <- apply(y, MARGIN = 2, sd)
rcov <- sqrt(1 / (n - 1)) * (sdx %o% sdy)
print(rcov)
s <- sign(cov)
icov <- (s * cov - rcov) * s
print(icov)
isdx <- sqrt(1 - sqrt(1 / (n - 1))) * sdx
isdy <- sqrt(1 - sqrt(1 / (n - 1))) * sdy
ipearson <- icov / (isdx %o% isdy)
ipearson
}
......@@ -128,17 +128,6 @@ Similarly the informative counter-part of $VarLs(X)$ is defined as $\ivarls(X)=\
\begin{methods}
\section{Methods}
Two methods are proposed to estimate $\overline{\rcovls(X,Y)}$. The first one is formal and applicable only when $p=1$ and $q=1$ the second one is based on a Monte-Carlo evaluation and is applicable for every $p$ and $q$.
\subsection{Formal estimation of $\overline{\rcovls(X,Y)}$}
For two random real vectors of length $n$, $x$ and $y$ the mean of $R(x,y)^2$, $\overline{\r(x,y)^2}=1/(n-1)$. That equality is independent of the distribution of $x$ and $y$. Let $\sigma_x$ and $\sigma_y$ being respectively the standard deviations of $x$ and $y$, we can estimate $\overline{\rcovls(x,y)}$ by Equation~(\ref{eq:RCovLs11}).
\begin{equation}
\overline{\rcovls(x,y)} = \sigma_x \; \sigma_y \sqrt{\frac{1}{n-1}}
\label{eq:RCovLs11}
\end{equation}
\subsection{Monte-Carlo estimation of $\overline{\rcovls(X,Y)}$}
For every values of $p$ and $q$ including $1$, $\overline{\rcovls(X,Y)}$ can be estimated using a serie of $k$ random matrices $RX=\{RX_1,RX_2,...,RX_k\}$ and $RY=\{RY_1,RY_2,...,RY_k\}$ where each $RX_i$ and $RY_i$ have the same structure respectively than $X$ and $Y$ in term of number of columns and of standard deviation of these columns.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment