multivariate-statistics/figures/schemes/orthogonal_projection.tex

42 lines
1.7 KiB
TeX
Raw Permalink Normal View History

2023-11-16 16:47:14 +01:00
% ref. https://tex.stackexchange.com/a/523362/235607
\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\usepackage{tkz-euclide}
\usepackage{mathtools}
\begin{document}
\tdplotsetmaincoords{50}{0}
\begin{tikzpicture}[tdplot_main_coords,bullet/.style={circle,inner
sep=1pt,fill=black,fill opacity=1}]
\begin{scope}[canvas is xy plane at z=0]
\tkzDefPoints{-2/-1/A,3/-1/B,4/2/C}
\tkzDefParallelogram(A,B,C)
\tkzGetPoint{D}
\tkzDrawPolygon[fill=gray!25!white](A,B,C,D)
\end{scope}
% Draw the rectangle triangle scheme
\begin{scope}[canvas is xz plane at y=1]
\draw[thick,fill=white,fill opacity=0.7,nodes={opacity=1}]
(2,0) node[bullet,label=right:{$\bar{\mathbf{Y}}$}] (Y_bar) {}
-- (0,-0.5) node (B) {}
-- (0,3) node[label=above:{$\mathbf{Y}$}] (Y) {} -- cycle;
% Right angle annotation
\tkzPicRightAngle[draw,
angle eccentricity=.5,angle radius=2mm](Y,B,Y_bar)
% epsilon: Y - X \hat{\beta} curly brackets annotations
\draw[decorate,decoration={brace,
amplitude=8pt},xshift=0pt,very thin,gray] (B) -- (Y) node [black,midway,xshift=-1.25em,yshift=0em] {\color{blue}$b$};
% X\hat{\beta} - \hat{Y}
\draw[decorate,decoration={brace,
amplitude=8pt},xshift=0pt,very thin,gray] (Y_bar) -- (B) node [black,midway,xshift=0.5em,yshift=-1em] {\color{blue}$a$};
%
\draw[decorate,decoration={brace,
amplitude=8pt},xshift=0pt,very thin,gray] (Y) -- (Y_bar) node [black,midway,xshift=1em,yshift=1em] {\color{blue}$c$};
\end{scope}
% Coordinate system
\begin{scope}[canvas is xy plane at z=0]
\draw[->] (2,1) -- node [above] {$\mathbf{1}$} ++(-1,0) ;
\draw[->] (2,1) -- ++(-0.45,-1) node [right] {$X_1$};
\end{scope}
\end{tikzpicture}
\end{document}