diff --git a/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.pdf b/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.pdf new file mode 100644 index 0000000..b1f3990 --- /dev/null +++ b/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c0331b5bad971a88e49f51d3dee60321fdb17245b2912e49716e275d6eb79cb +size 93685 diff --git a/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.tex b/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.tex new file mode 100644 index 0000000..98b2b24 --- /dev/null +++ b/AOS-accepted/plots/sim-tsir-reg-vs-gmlm.tex @@ -0,0 +1,98 @@ +\documentclass[border=0cm]{standalone} + +\usepackage{tikz} +\usepackage{pgfplots} +\usepackage{bm} + +\definecolor{gmlm}{RGB}{0,0,0} +\definecolor{tsir}{RGB}{255,50,50} + +\pgfplotsset{ + compat=newest, + every axis/.style={ + grid=both, + grid style={gray, dotted}, + label style={font=\tiny}, + tick label style={font=\tiny} + }, + % every axis plot/.append style={ + % mark = *, + % mark size = 1pt, + % line width=0.8pt + % } +} +\tikzset{ + legend entry/.style={ + mark = *, + mark size = 1pt, + mark indices = {2}, + line width=0.8pt + } +} + +\begin{document} +\begin{tikzpicture}[>=latex] + + \begin{axis}[ + name=p1, % ymin = -60, ymax = 60 + width=7.5cm, height=5cm, + xticklabel=\empty + ] + \addplot[color = tsir] table[x = time, y = tsir.reg.beta] {tsir-vs-gmlm-1.csv}; + \addplot[color = gmlm] table[x = time, y = gmlm.beta] {tsir-vs-gmlm-1.csv}; + \end{axis} + \node[anchor = base west, yshift = 0.3em] at (p1.north west) { + Time + }; + \node[anchor = south, xshift = -1.5em, rotate = 90] at (p1.west) { + $\widehat{\beta}_1$ + }; + + \begin{axis}[ + name=p2, + width=7.5cm, height=5cm, + anchor=north west, at={(p1.below south west)}, yshift=0.4em + ] + \addplot[color = tsir] table[x = time, y = tsir.reg.Gamma] {tsir-vs-gmlm-1.csv}; + \addplot[color = gmlm] table[x = time, y = gmlm.Gamma] {tsir-vs-gmlm-1.csv}; + \end{axis} + \node[anchor = south, xshift = -1.5em, rotate = 90] at (p2.west) { + $\widehat{\Gamma}_1$ + }; + \node[anchor = north, yshift = -1em] at (p2.south) { + Time [s] + }; + + \begin{axis}[ + name=p3, + width=7.5cm, height=5cm, + anchor=north west, at={(p1.right of north east)}, xshift=1cm, + xticklabel=\empty + ] + \addplot[color = gmlm, dotted, mark = *, mark size = 1pt] table[x = sensor, y = gmlm.beta] {tsir-vs-gmlm-2.csv}; + \addplot[color = tsir, dotted, mark = *, mark size = 1pt] table[x = sensor, y = tsir.reg.beta] {tsir-vs-gmlm-2.csv}; + \end{axis} + \node[anchor = base west, yshift = 0.3em] at (p3.north west) { + Sensors + }; + \node[anchor = south, xshift = -1em, rotate = 90] at (p3.west) { + $\widehat{\beta}_2$ + }; + + \begin{axis}[ + name=p4, + width=7.5cm, height=5cm, + anchor=north west, at={(p3.below south west)}, yshift=0.4em + ] + \addplot[color = gmlm, dotted, mark = *, mark size = 1pt] table[x = sensor, y = gmlm.Gamma] {tsir-vs-gmlm-2.csv}; + \addplot[color = tsir, dotted, mark = *, mark size = 1pt] table[x = sensor, y = tsir.reg.Gamma] {tsir-vs-gmlm-2.csv}; + \end{axis} + \node[anchor = south, xshift = -1em, rotate = 90] at (p4.west) { + $\widehat{\Gamma}_2$ + }; + \node[anchor = north, yshift = -1em] at (p4.south) { + Sensor Index + }; + +\end{tikzpicture} +\end{document} diff --git a/AOS-accepted/plots/sim-tsir-vs-gmlm.pdf b/AOS-accepted/plots/sim-tsir-vs-gmlm.pdf new file mode 100644 index 0000000..874439b --- /dev/null +++ b/AOS-accepted/plots/sim-tsir-vs-gmlm.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0c28bfb2a6313c62da9fa7df1fe22f5db903a5bb2501a283f1ff7fa93316c8a +size 94050 diff --git a/AOS-accepted/plots/sim-tsir-vs-gmlm.tex b/AOS-accepted/plots/sim-tsir-vs-gmlm.tex new file mode 100644 index 0000000..d6ce392 --- /dev/null +++ b/AOS-accepted/plots/sim-tsir-vs-gmlm.tex @@ -0,0 +1,98 @@ +\documentclass[border=0cm]{standalone} + +\usepackage{tikz} +\usepackage{pgfplots} +\usepackage{bm} + +\definecolor{gmlm}{RGB}{0,0,0} +\definecolor{tsir}{RGB}{255,50,50} + +\pgfplotsset{ + compat=newest, + every axis/.style={ + grid=both, + grid style={gray, dotted}, + label style={font=\tiny}, + tick label style={font=\tiny} + }, + % every axis plot/.append style={ + % mark = *, + % mark size = 1pt, + % line width=0.8pt + % } +} +\tikzset{ + legend entry/.style={ + mark = *, + mark size = 1pt, + mark indices = {2}, + line width=0.8pt + } +} + +\begin{document} +\begin{tikzpicture}[>=latex] + + \begin{axis}[ + name=p1, % ymin = -60, ymax = 60 + width=7.5cm, height=5cm, + xticklabel=\empty + ] + \addplot[color = tsir] table[x = time, y = tsir.beta] {tsir-vs-gmlm-1.csv}; + \addplot[color = gmlm] table[x = time, y = gmlm.beta] {tsir-vs-gmlm-1.csv}; + \end{axis} + \node[anchor = base west, yshift = 0.3em] at (p1.north west) { + Time + }; + \node[anchor = south, xshift = -1.5em, rotate = 90] at (p1.west) { + $\widehat{\beta}_1$ + }; + + \begin{axis}[ + name=p2, + width=7.5cm, height=5cm, + anchor=north west, at={(p1.below south west)}, yshift=0.4em + ] + \addplot[color = tsir] table[x = time, y = tsir.Gamma] {tsir-vs-gmlm-1.csv}; + \addplot[color = gmlm] table[x = time, y = gmlm.Gamma] {tsir-vs-gmlm-1.csv}; + \end{axis} + \node[anchor = south, xshift = -1.5em, rotate = 90] at (p2.west) { + $\widehat{\Gamma}_1$ + }; + \node[anchor = north, yshift = -1em] at (p2.south) { + Time [s] + }; + + \begin{axis}[ + name=p3, + width=7.5cm, height=5cm, + anchor=north west, at={(p1.right of north east)}, xshift=1cm, + xticklabel=\empty + ] + \addplot[color = gmlm, dotted, mark = *, mark size = 1pt] table[x = sensor, y = gmlm.beta] {tsir-vs-gmlm-2.csv}; + \addplot[color = tsir, dotted, mark = *, mark size = 1pt] table[x = sensor, y = tsir.beta] {tsir-vs-gmlm-2.csv}; + \end{axis} + \node[anchor = base west, yshift = 0.3em] at (p3.north west) { + Sensors + }; + \node[anchor = south, xshift = -1em, rotate = 90] at (p3.west) { + $\widehat{\beta}_2$ + }; + + \begin{axis}[ + name=p4, + width=7.5cm, height=5cm, + anchor=north west, at={(p3.below south west)}, yshift=0.4em + ] + \addplot[color = gmlm, dotted, mark = *, mark size = 1pt] table[x = sensor, y = gmlm.Gamma] {tsir-vs-gmlm-2.csv}; + \addplot[color = tsir, dotted, mark = *, mark size = 1pt] table[x = sensor, y = tsir.Gamma] {tsir-vs-gmlm-2.csv}; + \end{axis} + \node[anchor = south, xshift = -1em, rotate = 90] at (p4.west) { + $\widehat{\Gamma}_2$ + }; + \node[anchor = north, yshift = -1em] at (p4.south) { + Sensor Index + }; + +\end{tikzpicture} +\end{document} diff --git a/AOS-accepted/supplement.tex b/AOS-accepted/supplement.tex index 480cdac..a177a36 100644 --- a/AOS-accepted/supplement.tex +++ b/AOS-accepted/supplement.tex @@ -849,7 +849,7 @@ TSIR suffers substantial loss in predictive accuracy in the full 2D EEG data (se \begin{figure} \centering \caption{\label{fig:TSIRvsGMLM}TSIR in red vs. GMLM in black} - \includegraphics[width = \textwidth]{plots/tsir_eeg_2d_bad_perf.pdf} + \includegraphics{plots/sim-tsir-vs-gmlm.pdf} \end{figure} To observe this in practice, we took the full 2D EEG data (only the S1 stimulus) and computed $\widehat{\mat{\Gamma}}^{\mathrm{TSIR}}_1, \widehat{\mat{\Gamma}}^{\mathrm{TSIR}}_2$, $\widehat{\mat{\Sigma}}^{\mathrm{TSIR}}_1, \widehat{\mat{\Sigma}}^{\mathrm{TSIR}}_2$ from which we computed the reductions $\widehat{\mat{\beta}}^{\mathrm{TSIR}}_1$ and $\widehat{\mat{\beta}}^{\mathrm{TSIR}}_2$. For comparison, we used GMLM to estimate the reduction matrices $\widehat{\mat{\beta}}^{\mathrm{GMLM}}_1$, $\widehat{\mat{\beta}}^{\mathrm{GMLM}}_2$ and the scatter matrices $\widehat{\mat{\Omega}}^{\mathrm{GMLM}}_1$, $\widehat{\mat{\Omega}}^{\mathrm{GMLM}}_2$. We also computed the GMLM analog of the standardized reductions $\widehat{\mat{\Gamma}}^{\mathrm{GMLM}}_1 = (\widehat{\mat{\Omega}}^{\mathrm{GMLM}}_1)^{-1}\widehat{\mat{\beta}}_1^{\mathrm{GMLM}}$ and $\widehat{\mat{\Gamma}}^{\mathrm{GMLM}}_2 = (\widehat{\mat{\Omega}}^{\mathrm{GMLM}}_2)^{-1}\widehat{\mat{\beta}}_2^{\mathrm{GMLM}}$. We next plotted in \cref{fig:TSIRvsGMLM} the estimated reductions $\widehat{\mat{\beta}}^{\mathrm{GMLM}}_1$, $\widehat{\mat{\beta}}^{\mathrm{GMLM}}_2$, $\widehat{\mat{\Gamma}}^{\mathrm{GMLM}}_1$, $\widehat{\mat{\Gamma}}^{\mathrm{GMLM}}_2$ in black and $\widehat{\mat{\beta}}^{\mathrm{TSIR}}_1$, $\widehat{\mat{\beta}}^{\mathrm{TSIR}}_2$, $\widehat{\mat{\Gamma}}^{\mathrm{TSIR}}_1$, $\widehat{\mat{\Gamma}}^{\mathrm{TSIR}}_2$ in red (with appropriate scaling). Since the estimates of the reductions $\widehat{\mat{\beta}}_j$'s are completely different between GMLM and TSIR but the estimates of the standardized reductions $\mat{\Gamma}_j$'s agree to a high degree, we conclude that the loss of estimation accuracy happens in the final calculations that %That is in computing the estimates of the reductions $\mat{\beta}_j = \mat{\Sigma}_j^{-1}\mat{\Gamma}$, which @@ -858,9 +858,9 @@ involve the inversion of the severely ill-conditioned mode-wise estimated covari To check whether our conjecture holds, we introduced a regularization term similar to the regularization employed in GMLM to the mode-wise sample covariances $\mat{\Sigma}_j$ in TSIR. As can be seen in \cref{fig:TSIRregvsGMLM}, this produced roughly the same reductions $\widehat{\mat{\beta}}_j$ as well as the $\widehat{\mat{\Gamma}}_j$. \begin{figure} -\caption{TSIR (reg) in red vs. GMLM in black} -\label{fig:TSIRregvsGMLM} - \includegraphics[width = \textwidth]{plots/tsir_regularized.pdf} + \centering + \caption{\label{fig:TSIRregvsGMLM}TSIR (reg) in red vs. GMLM in black} + \includegraphics{plots/sim-tsir-reg-vs-gmlm.pdf} \end{figure} To further study the relationship between GMLM and TSIR, we first consider a setting in which GMLM and TSIR are theoretically equivalent. We assume that $Y$ is categorical, $\ten{X}\mid Y = y$ is multi-linear normal and the reduction $\ten{R}(\ten{X})$ is one-dimensional. Additionally, $\mat{\Omega}_j$ is assumed to be positive definite but \emph{not} further constrained. Under these assumptions, GMLM and TSIR are equivalent since %Even though GMLM minimizes the log-likelihood and TSIR minimizes a squared error loss, @@ -1043,40 +1043,6 @@ The results of our analysis above agree with the configuration of the chess boar \end{appendix} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Support information, if any, %% -%% should be provided in the %% -%% Acknowledgements section. %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%\begin{acks}[Acknowledgments] -%The authors would like to thank the anonymous referees, an Associate Editor and the Editor for their constructive comments that improved the quality of this paper. -%\end{acks} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Funding information, if any, %% -%% should be provided in the %% -%% funding section. %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \begin{funding} -% Both authors were partially supported by the Vienna Science and Technology Fund (WWTF) [10.47379/ICT19018] and the Austrian Science Fund (FWF) research -% project P 30690-N35. -% \end{funding} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Supplementary Material, including data %% -%% sets and code, should be provided in %% -%% {supplement} environment with title %% -%% and short description. It cannot be %% -%% available exclusively as external link. %% -%% All Supplementary Material must be %% -%% available to the reader on Project %% -%% Euclid with the published article. %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \begin{supplement} -% \stitle{???} -% \sdescription{???.} -% \end{supplement} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% The Bibliography %% %% %% diff --git a/sim/sim_efficiency.R b/sim/sim_efficiency.R index d8107f5..3648de9 100644 --- a/sim/sim_efficiency.R +++ b/sim/sim_efficiency.R @@ -101,11 +101,11 @@ with(merge( suffixes = c("", ".sd"), all = FALSE ), { - plot(range(pj), 0:1, type = "n", - main = "Simulation -- Efficiency Gain", - xlab = expression(tilde(p)), - ylab = expression(d(B, hat(B))) - ) + par(mar = c(4.1, 4.1, 0.1, 0.1)) + plot(range(pj), 0:1, type = "n", main = "", xlab = "", ylab = "", xaxt = "n", bty = "n") + axis(1, at = sort(unique(pj))) + title(ylab = expression(d(B, hat(B))), line = 2.5) + title(xlab = expression(tilde(p)), line = 2.5) for (sz in sort(unique(sample.size))) { i <- order(pj)[(sample.size == sz)[order(pj)]] i <- i[!(is.na(lm[i]) | is.na(lm.sd[i]))] @@ -132,4 +132,17 @@ with(merge( lines(pj[i], mani[i], type = "b", pch = 16, col = "#006e18", lty = lty.idx, lwd = 2) lty.idx <- lty.idx + 1L } + legend(23, 0.8, + legend = c( + "Linear Model of Y | vec(X)", + "GMLM of vec(X) | Y", + "GMLM of X | Y", + "GMLM of X | Y + constraint" + ), + col = c("#cf7d03", "#b30303", "#002d8d", "#006e18"), + fill = paste0(c("#cf7d03", "#b30303", "#002d8d", "#006e18"), "50"), + lwd = 2, lty = 1, bty = "n" + ) }) + +dev.copy2pdf(file = "sim_efficiency.pdf", width = 12, height = 6) diff --git a/tensorPredictors/R/gmlm_tensor_normal.R b/tensorPredictors/R/gmlm_tensor_normal.R index a567389..747f81f 100644 --- a/tensorPredictors/R/gmlm_tensor_normal.R +++ b/tensorPredictors/R/gmlm_tensor_normal.R @@ -112,7 +112,6 @@ gmlm_tensor_normal <- function(X, F, sample.axis = length(dim(X)), min_max <- range(eigen(Sigmas[[j]], TRUE, TRUE)$values) # The condition is approximately `kappa(Sigmas[[j]]) > reg.threshold` if (min_max[2] > reg.threshold * min_max[1]) { - cat(sprintf("\033[2mReg (%d): cond(Sigma_%d) = %f\033[0m\n", iter, j, min_max[2] / min_max[1])) diag(Sigmas[[j]]) <- diag(Sigmas[[j]]) + reg.factor * min_max[2] } }