From dc1009b1e538e67c62cb1b8af5ccc279be89ee0f Mon Sep 17 00:00:00 2001 From: Louis Lacoste Date: Wed, 10 Jun 2026 16:17:38 +0200 Subject: [PATCH] vault backup: 2026-06-10 16:17:38 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Affected files: Thèse/Axes/Phylogénie/SBM avec covariance latente.md --- .../Phylogénie/SBM avec covariance latente.md | 291 ++++++++++-------- 1 file changed, 169 insertions(+), 122 deletions(-) diff --git a/Thèse/Axes/Phylogénie/SBM avec covariance latente.md b/Thèse/Axes/Phylogénie/SBM avec covariance latente.md index 925bb80..792f53b 100644 --- a/Thèse/Axes/Phylogénie/SBM avec covariance latente.md +++ b/Thèse/Axes/Phylogénie/SBM avec covariance latente.md @@ -1,6 +1,4 @@ -# Inclusion dans la thèse -Ce modèle ci est une proposition pour remettre en cause l'hypothèse du LBM d'indépendance des $Z_{i}$ en définissant une structure de dépendance dépendantes de la phylogénie. # Idée du modèle @@ -35,191 +33,238 @@ avec $\Sigma$, la matrice de variance-covariance déterminée en fonction de l'a \usepackage{amsmath,amssymb} -\usetikzlibrary{ +\usetikzlibrary{arrows.meta,positioning,shapes.geometric,calc} -arrows.meta, +\begin{document} +\begin{tikzpicture}[ +font=\sffamily, +>=Latex, +node distance=1.5cm and 2cm, +directed/.style={-{Latex}, line width=0.8pt, draw=gray!75}, +bidirected/.style={-, line width=0.8pt, draw=red!75}, +base/.style={ + draw=gray!70, + line width=0.9pt, + align=center, + inner sep=4pt +}, +prior/.style={base,rectangle,rounded corners=1pt,fill=blue!7}, +latent/.style={base,rectangle,rounded corners=6pt,fill=teal!8}, +known/.style={base,diamond,aspect=1.35,fill=orange!12}, +observed/.style={base,circle,fill=purple!8} +] -positioning, +%-------------------------------------------------- +% Hyperparameters rows +%-------------------------------------------------- +\node[prior] (sigma) {$\sigma^2$}; +\node[known,right=of sigma] (Sigma) {$\Sigma$}; -shapes.geometric, +\node[latent,below=of sigma] (Pi) {$P_i$}; +\node[latent,below=of Sigma] (Pip) {$P_{i'}$}; -calc, +\node[latent,below=of Pi] (Zi) {$Z_i$}; +\node[latent,below=of Pip] (Zip) {$Z_{i'}$}; -fit +%-------------------------------------------------- +% Hyperparameters columns +%-------------------------------------------------- +\node[prior,right=4cm of Sigma] (rho) {$\rho$}; -} +\node[latent,below left=of rho] (Wj) {$W_j$}; +\node[latent,below right=of rho] (Wjp) {$W_{j'}$}; - +%-------------------------------------------------- +% Intercept +%-------------------------------------------------- +\node[prior] (alpha) +at ($(Zi)!0.5!(Wj)+(0,-3)$) +{$\alpha$}; + +%-------------------------------------------------- +% Observations +%-------------------------------------------------- +\node[observed] +at ($(Zi)!0.5!(Wj)+(0,-1.4)$) +(Yij) {$Y_{ij}$}; + +\node[observed] +at ($(Zi)!0.5!(Wjp)+(2.0,-1.4)$) +(Yijp) {$Y_{ij'}$}; + +\node[observed] +at ($(Zip)!0.5!(Wj)+(-2.0,-1.4)$) +(Yipj) {$Y_{i'j}$}; + +\node[observed] +at ($(Zip)!0.5!(Wjp)+(0,-1.4)$) +(Yipjp) {$Y_{i'j'}$}; + +%-------------------------------------------------- +% Row side +%-------------------------------------------------- +\draw[directed] (sigma) -- (Pi); +\draw[directed] (Sigma) -- (Pi); + +\draw[directed] (sigma) -- (Pip); +\draw[directed] (Sigma) -- (Pip); + +\draw[directed] (Pi) -- (Zi); +\draw[directed] (Pip) -- (Zip); + +%-------------------------------------------------- +% Column side +%-------------------------------------------------- +\draw[directed] (rho) -- (Wj); +\draw[directed] (rho) -- (Wjp); + +%-------------------------------------------------- +% Likelihood +%-------------------------------------------------- +\foreach \y in {Yij,Yijp} + \draw[directed] (Zi) -- (\y); + +\foreach \y in {Yipj,Yipjp} + \draw[directed] (Zip) -- (\y); + +\foreach \y in {Yij,Yipj} + \draw[directed] (Wj) -- (\y); + +\foreach \y in {Yijp,Yipjp} + \draw[directed] (Wjp) -- (\y); + +\foreach \y in {Yij,Yijp,Yipj,Yipjp} + \draw[directed] (alpha) -- (\y); + +%-------------------------------------------------- +% Correlation structure +%-------------------------------------------------- +\draw[bidirected] (alpha) -- (Zi); +\draw[bidirected] (alpha) -- (Zip); + +\draw[bidirected] (alpha) -- (Wj); +\draw[bidirected] (alpha) -- (Wjp); + +\end{tikzpicture} +\end{document} +``` + +```tikz +\usepackage{tikz} + +\usepackage{amsmath} + +\usetikzlibrary{positioning,shapes.arrows, arrows.meta,shapes.geometric} \begin{document} -\begin{tikzpicture}[ +\begin{tikzpicture} -font=\sffamily, +\tikzset{ ->=Latex, +every path/.append style = { -node distance=1cm and 0.25cm, +arrows = ->, -directed/.style={-{Latex}, line width=0.8pt, draw=gray!75}, +> = stealth,}, -bidirected/.style={-, line width=0.8pt, draw=red!75}, +every node/.append style = { -base/.style={ +shape = circle, -draw=gray!70, +draw = black, -line width=0.9pt, - -align=center, - -inner sep=4pt +minimum size=3em }, -prior/.style={base,rectangle,rounded corners=1pt,fill=blue!7}, +latent/.style = { -latent/.style={base,rectangle,rounded corners=6pt,fill=teal!8}, +fill = lightgray -known/.style={base,diamond,aspect=1.35,fill=orange!12}, +}, -observed/.style={base,circle,fill=purple!8}, +prior/.style = { -plate/.style={ +fill = red}, -draw=black!60, +moral/.style = { -rounded corners, +dashed, -inner sep=8pt +> = {}, % remove arrow tip -} +arrows = -, % ensure no arrows -] +}} -%-------------------------------------------------- - -% Row clustering - -%-------------------------------------------------- +\node (y) {$Y$}; -\node[prior] (sigma) {$\sigma^2$}; - -\node[known,right=of sigma] (Sigma) {$\Sigma$}; +\node[latent] (z) [above left = of y] {$Z$}; -\node[latent,below=of sigma] (Pi) {$P_i$}; - -\node[latent,below=0.5cm of Pi] (Zi) {$Z_i$}; +\node[latent] (w) [above right = of y] {$W$}; -\draw[directed] (sigma) -- (Pi); - -\draw[directed] (Sigma) -- (Pi); - -\draw[directed] (Pi) -- (Zi); +\node[latent] (P) [above = of z] {$P$}; -%-------------------------------------------------- - -% Column clustering - -%-------------------------------------------------- - -\node[latent,right=2.5cm of Zi] (Wj) {$W_j$}; +\node[prior] (sigma2) [above = of P] {$\sigma^2$}; -\node[prior] (rho) at (Wj |- sigma) {$\rho$}; +\node[prior] (rho) [above = of w] {$\rho_{1:R}$}; -\draw[directed] (rho) -- (Wj); +\node[prior] (alpha) [below = of y] {$\boldsymbol{\alpha}$}; -%-------------------------------------------------- - -% Observation - -%-------------------------------------------------- +\path (z) edge (y); -\node[observed] (Yij) - -at ($(Zi)!0.5!(Wj)+(0,-0.9)$) - -{$Y_{ij}$}; +\path (w) edge (y); -\draw[directed] (Zi) -- (Yij); - -\draw[directed] (Wj) -- (Yij); +\path (rho) edge (w); -\draw[bidirected] (Zi) -- (Wj); +\path (alpha) edge (y); -%-------------------------------------------------- - -% Intercept - -%-------------------------------------------------- +\path (P) edge (z); -\node[prior] (alpha) - -at ($(Yij)+(0,-2.5)$) - -{$\alpha$}; +\path (sigma2) edge (P); -\draw[directed] (alpha) -- (Yij); +% moral -\draw[bidirected] (alpha) -- (Zi); - -\draw[bidirected] (alpha) -- (Wj); +\path[moral] (z) edge (alpha); -%-------------------------------------------------- - -% Plates - -%-------------------------------------------------- +\path[moral] (w) edge (alpha); -\node[plate,fit=(Pi)(Zi),label={[align=center]left:$i=1,\ldots,n_1$}] {}; - - - -\node[plate,fit=(Wj),label={[align=center]right:$j=1,\ldots,n_2$}] {}; - - - -\node[plate, - -fit=(Yij), - -label=below right:{$(i,j)$}] {}; - - +\path[moral] (z) edge (w); \end{tikzpicture} @@ -600,14 +645,14 @@ $$ \end{align*} $$ -En posant $R_{ir}^W=\sum_{j=1}^{n_{2}}W_{jr}Y_{ij}$ et $F_{ir}^W =\sum_{j=1}^{n_{2}}W_{jr}(1-Y_{ij})$ on définit les matrices $\mathbf{R}^W$ et $\mathbf{F}^W$ qui comptent les succès et échecs par ligne $i$ et groupe $r$. +En posant $R_{ir}=\sum_{j=1}^{n_{2}}W_{jr}Y_{ij}$ et $F_{ir}=\sum_{j=1}^{n_{2}}W_{jr}(1-Y_{ij})$ on définit les matrices $\mathbf{R}$ et $\mathbf{F}$ qui comptent les succès et échecs par ligne $i$ et groupe $r$. Ce qui donne pour les $\tilde{\pi}_{i,k}$ de la posterior: $$ \begin{align*} \tilde{\pi}_{i,k} = p(Z_{i} = k\mid Y_{i,\bullet},\alpha,W,P_{i}) & \propto p(Y_{i,\bullet}\mid Z_{i} = k, \alpha, W, P_{i})p(Z_{i}=k\mid P_{i})\\ -& \propto \pi_{i,k} \prod_{r=1}^{R} \alpha_{k,r}^{R^W_{ir}}(1-\alpha_{k,r})^{F^W_{ir}} +& \propto \pi_{i,k} \prod_{r=1}^{R} \alpha_{k,r}^{R_{ir}}(1-\alpha_{k,r})^{F_{ir}} \end{align*} $$ @@ -821,33 +866,35 @@ p(Y_{\bullet,j}\mid W_j=r,\alpha,Z)&= \prod_{i=1}^{n_1} \alpha_{Z_i,r}^{Y_{i,j}} \end{align*} $$ -On peut poser $R_{jq}^{Z} = \sum_{i=1}^{n_{1}}\mathbb{1}_{Z_{i}=q} Y_{i,j}$ et $F_{jq}^{Z} = \sum_{i=1}^{n_{1}}\mathbb{1}_{Z_{i}=q} (1-Y_{i,j})$ et on définit les matrices $\mathbf{R}^Z$ et $\mathbf{F}^{Z}$. +**A MODIFIER** + +On a : $$ - \begin{align*} - p(W_{j}=r\mid Y_{\bullet,j},\alpha, Z, \rho) \propto \rho_{r}\prod_{q=1}^Q\alpha_{q,r}^{R^Z_{jq}}(1-\alpha_{q,r})^{F_{jq}^Z} - \end{align*} + \begin{align*} + p(Z_{i}\mid P_{i}) & = \ilr^{-1}(P_{i}) = (\pi_{i,1},\dots,\pi_{i,k},\dots,\pi_{i,K}) \\ + p(Y_{i,\bullet}\mid Z_{i}, \alpha, W) & = \prod_{j=1}^{n_{2}} \alpha_{Z_{i},W_{j}}^{Y_{ij}}(1- \alpha_{Z_{i},W_{j}})^{1-Y_{ij}} \\ + p(Z_{i} = k \mid P_{i}) & = \pi_{i,k} \\ + p(Y_{i,\bullet}\mid Z_{i} = k, \alpha, W) & = \prod_{j=1}^{n_{2}} \prod_{r=1}^{R}\alpha_{k,r}^{\mathbb{1}_{W_{j} = r} Y_{ij}}(1- \alpha_{k,r})^{\mathbb{1}_{W_{j} = r}(1-Y_{ij})} \\ + & = \prod_{r=1}^{R} \alpha_{k,r}^{\sum_{j=1}^{n_{2}}W_{jr}Y_{ij}} (1-\alpha_{k,r})^{\sum_{j=1}^{n_{2}}W_{jr}(1-Y_{ij})} + \end{align*} $$ -À la fin +En posant $R_{ir}=\sum_{j=1}^{n_{2}}W_{jr}Y_{ij}$ et $F_{ir}=\sum_{j=1}^{n_{2}}W_{jr}(1-Y_{ij})$ on définit les matrices $\mathbf{R}$ et $\mathbf{F}$ qui comptent les succès et échecs par ligne $i$ et groupe $r$. -$$ - W_{j} \sim \Cat_{R}(\tilde{\rho}_{1:R}^j) -$$ - -### Implémentation +Ce qui donne pour les $\tilde{\pi}_{i,k}$ de la posterior: $$ \begin{align*} - \log \tilde{p_{jr}} & = \log \rho_{r} + \sum_{q=1}^{Q} [R_{jq}^{Z} \log\alpha_{q,r} + F_{jq}^W\log{(1-\alpha_{q,r})}] \\ - \tilde{\rho}_{jr} &= \frac{\exp(\log \tilde{p}_{jr} - m_{j})}{\sum_{l=1}^{R}\exp(\log \tilde{p_{jr}}-m_{j})},\quad m_{j} = \max_{l} \log p_{jr} +\tilde{\pi}_{i,k} = p(Z_{i} = k\mid Y_{i,\bullet},\alpha,W,P_{i}) & \propto p(Y_{i,\bullet}\mid Z_{i} = k, \alpha, W, P_{i})p(Z_{i}=k\mid P_{i})\\ +& \propto \pi_{i,k} \prod_{r=1}^{R} \alpha_{k,r}^{R_{ir}}(1-\alpha_{k,r})^{F_{ir}} \end{align*} $$ -Ainsi : +Et ainsi à la fin : $$ -\log \tilde{R} = \log(\rho) + \mathbf{R}^Z\log\alpha^{\top} + \mathbf{F}^Z \log(1-\alpha)^{\top} +Z_{i}\mid P_{i}, Y, W, \alpha \sim \Cat_{K}(\tilde{\pi}_{i,1},\dots, \tilde{\pi}_{i,K}) $$ ## Loi de $\alpha \mid Y,Z,W$