Skip to content

Commit cba9b6e

Browse files
RJ-2024-010 fix equation overflow
1 parent bae9be1 commit cba9b6e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

_articles/RJ-2024-010/RJ-2024-010.Rmd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,14 @@ $\boldsymbol{\theta}^{\star}_b$ and $\boldsymbol{\theta}^{\star}$, we
514514
first transform $\gamma_1=\log\left(\frac{1}{\sigma^2_1}\right)$ and
515515
$\gamma_2=\log\left(\frac{1}{\sigma^2_2}\right)$ to stabilize the
516516
optimization. We optimize
517-
$\log P(\boldsymbol{Y}|g,\sigma^2_1,\sigma^2_2)^b\pi(\sigma^2_1,\sigma^2_2,g)=\frac{n_1b}{2}\log \gamma_1+\frac{n_2b}{2}\gamma_2-\frac{P}{2}\log g+\frac{1}{2}|X^T\tilde{\Sigma}X|-\frac{1}{2}\log|\frac{bg+1}{bg}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X|-\frac{b}{2}\boldsymbol{Y}^T \left(\tilde{\Sigma}-Z_{\tilde{\Sigma}}-(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X\left(\frac{bg+1}{bg}X^T\tilde{\Sigma}X-X^T Z_{\tilde{\Sigma}}X\right)^{-1}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}}) \right) \boldsymbol{Y}-\frac{3}{2}\log(g)-\frac{N}{2g}+\log(J)$
517+
518+
$$\begin{split}
519+
\log &P(\boldsymbol{Y}|g,\sigma^2_1,\sigma^2_2)^b\pi(\sigma^2_1,\sigma^2_2,g)=\frac{n_1b}{2}\log \gamma_1+\frac{n_2b}{2}\gamma_2-\frac{P}{2}\log g+\frac{1}{2}|X^T\tilde{\Sigma}X|-\\
520+
& \frac{1}{2}\log|\frac{bg+1}{bg}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X|- \\
521+
& \frac{b}{2}\boldsymbol{Y}^T \left(\tilde{\Sigma}-Z_{\tilde{\Sigma}}-(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X\left(\frac{bg+1}{bg}X^T\tilde{\Sigma}X-X^T Z_{\tilde{\Sigma}}X\right)^{-1}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}}) \right) \boldsymbol{Y}-\\
522+
& \frac{3}{2}\log(g)-\frac{N}{2g}+\log(J)
523+
\end{split}$$
524+
518525
using the Nelder-Mead method from **optim** where
519526
$Z_{\tilde{\Sigma}}=\tilde{\Sigma}Z(Z^T \tilde{\Sigma} Z)^{-1}Z^T \tilde{\Sigma}$,
520527
$Z=\boldsymbol{1}^T$, and $\log(J)=-(\gamma_1+\gamma_2)$ represents the

_articles/RJ-2024-010/RJ-2024-010.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
<!--radix_placeholder_rmarkdown_metadata-->
228228

229229
<script type="text/json" id="radix-rmarkdown-metadata">
230-
{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["title","description","author","date","date_received","journal","volume","issue","slug","citation_url","packages","preview","bibliography","CTV","legacy_pdf","legacy_converted","output","draft","pdf_url","doi","creative_commons","csl"]}},"value":[{"type":"character","attributes":{},"value":["Bayesian Model Selection with Latent Group-Based Effects and Variances with the R Package slgf"]},{"type":"character","attributes":{},"value":["Linear modeling is ubiquitous, but performance can suffer when the\nmodel is misspecified. We have recently demonstrated that latent\ngroupings in the levels of categorical predictors can complicate\ninference in a variety of fields including bioinformatics,\nagriculture, industry, engineering, and medicine. Here we present the\nR package slgf which enables the user to easily implement our\nrecently-developed approach to detect group-based regression effects,\nlatent interactions, and/or heteroscedastic error variance through\nBayesian model selection. We focus on the scenario in which the levels\nof a categorical predictor exhibit two latent groups. We treat the\ndetection of this grouping structure as an unsupervised learning\nproblem by searching the space of possible groupings of factor levels.\nFirst we review the suspected latent grouping factor (SLGF) method.\nNext, using both observational and experimental data, we illustrate\nthe usage of slgf in the context of several common linear model\nlayouts: one-way analysis of variance (ANOVA), analysis of covariance\n(ANCOVA), a two-way replicated layout, and a two-way unreplicated\nlayout. We have selected data that reveal the shortcomings of\nclassical analyses to emphasize the advantage our method can provide\nwhen a latent grouping structure is present.\n"]},{"type":"list","attributes":{},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","affiliation","orcid_id","address"]}},"value":[{"type":"character","attributes":{},"value":["Thomas A. Metzger"]},{"type":"character","attributes":{},"value":["Department of Statistics, The Ohio State University"]},{"type":"character","attributes":{},"value":["0000-0003-3620-1405"]},{"type":"character","attributes":{},"value":["1958 Neil Avenue, Columbus, Ohio 43210","United States of America","[metzger.181@osu.edu](metzger.181@osu.edu){.uri}\n"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","affiliation","address"]}},"value":[{"type":"character","attributes":{},"value":["Christopher T. Franck"]},{"type":"character","attributes":{},"value":["Department of Statistics, Virginia Tech"]},{"type":"character","attributes":{},"value":["403E Hutcheson Hall, Blacksburg, VA 24060","United States","(ORCiD: 0000-0003-1251-4378)","[chfranck@vt.edu](chfranck@vt.edu){.uri}\n"]}]}]},{"type":"character","attributes":{},"value":["2025-01-11"]},{"type":"character","attributes":{},"value":["2022-12-31"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["title","issn","firstpage","lastpage"]}},"value":[{"type":"character","attributes":{},"value":["The R Journal"]},{"type":"character","attributes":{},"value":["2073-4859"]},{"type":"integer","attributes":{},"value":[175]},{"type":"integer","attributes":{},"value":[191]}]},{"type":"integer","attributes":{},"value":[16]},{"type":"integer","attributes":{},"value":[1]},{"type":"character","attributes":{},"value":["RJ-2024-010"]},{"type":"character","attributes":{},"value":["https://doi.org/10.32614/RJ-2024-010"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["cran","bioc"]}},"value":[{"type":"character","attributes":{},"value":["slgf","numDeriv","mixtools","flexmix","MultiLCIRT"]},{"type":"list","attributes":{},"value":[]}]},{"type":"character","attributes":{},"value":["preview.png"]},{"type":"character","attributes":{},"value":["slgf.bib"]},{"type":"character","attributes":{},"value":["Cluster","Distributions","Environmetrics","NumericalMathematics","Psychometrics"]},{"type":"logical","attributes":{},"value":[true]},{"type":"logical","attributes":{},"value":[true]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["distill::distill_article"]}},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["self_contained","toc","mathjax","md_extension"]}},"value":[{"type":"logical","attributes":{},"value":[true]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"]},{"type":"character","attributes":{},"value":["-tex_math_single_backslash"]}]}]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["RJ-2024-010.pdf"]},{"type":"character","attributes":{},"value":["10.32614/RJ-2024-010"]},{"type":"character","attributes":{},"value":["CC BY"]},{"type":"character","attributes":{},"value":["/home/mitchell/R/x86_64-pc-linux-gnu-library/4.4/rjtools/rjournal.csl"]}]}
230+
{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["title","description","author","date","date_received","journal","volume","issue","slug","citation_url","packages","preview","bibliography","CTV","legacy_pdf","legacy_converted","output","draft","pdf_url","doi","creative_commons","csl"]}},"value":[{"type":"character","attributes":{},"value":["Bayesian Model Selection with Latent Group-Based Effects and Variances with the R Package slgf"]},{"type":"character","attributes":{},"value":["Linear modeling is ubiquitous, but performance can suffer when the\nmodel is misspecified. We have recently demonstrated that latent\ngroupings in the levels of categorical predictors can complicate\ninference in a variety of fields including bioinformatics,\nagriculture, industry, engineering, and medicine. Here we present the\nR package slgf which enables the user to easily implement our\nrecently-developed approach to detect group-based regression effects,\nlatent interactions, and/or heteroscedastic error variance through\nBayesian model selection. We focus on the scenario in which the levels\nof a categorical predictor exhibit two latent groups. We treat the\ndetection of this grouping structure as an unsupervised learning\nproblem by searching the space of possible groupings of factor levels.\nFirst we review the suspected latent grouping factor (SLGF) method.\nNext, using both observational and experimental data, we illustrate\nthe usage of slgf in the context of several common linear model\nlayouts: one-way analysis of variance (ANOVA), analysis of covariance\n(ANCOVA), a two-way replicated layout, and a two-way unreplicated\nlayout. We have selected data that reveal the shortcomings of\nclassical analyses to emphasize the advantage our method can provide\nwhen a latent grouping structure is present.\n"]},{"type":"list","attributes":{},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","affiliation","orcid_id","address"]}},"value":[{"type":"character","attributes":{},"value":["Thomas A. Metzger"]},{"type":"character","attributes":{},"value":["Department of Statistics, The Ohio State University"]},{"type":"character","attributes":{},"value":["0000-0003-3620-1405"]},{"type":"character","attributes":{},"value":["1958 Neil Avenue, Columbus, Ohio 43210","United States of America","[metzger.181@osu.edu](metzger.181@osu.edu){.uri}\n"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","affiliation","address"]}},"value":[{"type":"character","attributes":{},"value":["Christopher T. Franck"]},{"type":"character","attributes":{},"value":["Department of Statistics, Virginia Tech"]},{"type":"character","attributes":{},"value":["403E Hutcheson Hall, Blacksburg, VA 24060","United States","(ORCiD: 0000-0003-1251-4378)","[chfranck@vt.edu](chfranck@vt.edu){.uri}\n"]}]}]},{"type":"character","attributes":{},"value":["2025-01-11"]},{"type":"character","attributes":{},"value":["2022-12-31"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["title","issn","firstpage","lastpage"]}},"value":[{"type":"character","attributes":{},"value":["The R Journal"]},{"type":"character","attributes":{},"value":["2073-4859"]},{"type":"integer","attributes":{},"value":[175]},{"type":"integer","attributes":{},"value":[191]}]},{"type":"integer","attributes":{},"value":[16]},{"type":"integer","attributes":{},"value":[1]},{"type":"character","attributes":{},"value":["RJ-2024-010"]},{"type":"character","attributes":{},"value":["https://doi.org/10.32614/RJ-2024-010"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["cran","bioc"]}},"value":[{"type":"character","attributes":{},"value":["slgf","numDeriv","mixtools","flexmix","MultiLCIRT"]},{"type":"list","attributes":{},"value":[]}]},{"type":"character","attributes":{},"value":["preview.png"]},{"type":"character","attributes":{},"value":["slgf.bib"]},{"type":"character","attributes":{},"value":["Cluster","Distributions","Environmetrics","NumericalMathematics","Psychometrics"]},{"type":"logical","attributes":{},"value":[true]},{"type":"logical","attributes":{},"value":[true]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["distill::distill_article"]}},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["self_contained","toc","mathjax","md_extension"]}},"value":[{"type":"logical","attributes":{},"value":[true]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"]},{"type":"character","attributes":{},"value":["-tex_math_single_backslash"]}]}]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["RJ-2024-010.pdf"]},{"type":"character","attributes":{},"value":["10.32614/RJ-2024-010"]},{"type":"character","attributes":{},"value":["CC BY"]},{"type":"character","attributes":{},"value":["/home/mitchell/R/x86_64-pc-linux-gnu-library/4.4/rjtools/rjournal.csl"]}]}
231231
</script>
232232
<!--/radix_placeholder_rmarkdown_metadata-->
233233

@@ -3065,9 +3065,14 @@ <h4 class="unnumbered" data-number="2.4" id="fractional-bayes-factors-and-poster
30653065
<span class="math inline">\(\boldsymbol{\theta}^{\star}_b\)</span> and <span class="math inline">\(\boldsymbol{\theta}^{\star}\)</span>, we
30663066
first transform <span class="math inline">\(\gamma_1=\log\left(\frac{1}{\sigma^2_1}\right)\)</span> and
30673067
<span class="math inline">\(\gamma_2=\log\left(\frac{1}{\sigma^2_2}\right)\)</span> to stabilize the
3068-
optimization. We optimize
3069-
<span class="math inline">\(\log P(\boldsymbol{Y}|g,\sigma^2_1,\sigma^2_2)^b\pi(\sigma^2_1,\sigma^2_2,g)=\frac{n_1b}{2}\log \gamma_1+\frac{n_2b}{2}\gamma_2-\frac{P}{2}\log g+\frac{1}{2}|X^T\tilde{\Sigma}X|-\frac{1}{2}\log|\frac{bg+1}{bg}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X|-\frac{b}{2}\boldsymbol{Y}^T \left(\tilde{\Sigma}-Z_{\tilde{\Sigma}}-(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X\left(\frac{bg+1}{bg}X^T\tilde{\Sigma}X-X^T Z_{\tilde{\Sigma}}X\right)^{-1}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}}) \right) \boldsymbol{Y}-\frac{3}{2}\log(g)-\frac{N}{2g}+\log(J)\)</span>
3070-
using the Nelder-Mead method from <strong>optim</strong> where
3068+
optimization. We optimize</p>
3069+
<p><span class="math display">\[\begin{split}
3070+
\log &amp;P(\boldsymbol{Y}|g,\sigma^2_1,\sigma^2_2)^b\pi(\sigma^2_1,\sigma^2_2,g)=\frac{n_1b}{2}\log \gamma_1+\frac{n_2b}{2}\gamma_2-\frac{P}{2}\log g+\frac{1}{2}|X^T\tilde{\Sigma}X|-\\
3071+
&amp; \frac{1}{2}\log|\frac{bg+1}{bg}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X|- \\
3072+
&amp; \frac{b}{2}\boldsymbol{Y}^T \left(\tilde{\Sigma}-Z_{\tilde{\Sigma}}-(\tilde{\Sigma}-Z_{\tilde{\Sigma}})X\left(\frac{bg+1}{bg}X^T\tilde{\Sigma}X-X^T Z_{\tilde{\Sigma}}X\right)^{-1}X^T(\tilde{\Sigma}-Z_{\tilde{\Sigma}}) \right) \boldsymbol{Y}-\\
3073+
&amp; \frac{3}{2}\log(g)-\frac{N}{2g}+\log(J)
3074+
\end{split}\]</span></p>
3075+
<p>using the Nelder-Mead method from <strong>optim</strong> where
30713076
<span class="math inline">\(Z_{\tilde{\Sigma}}=\tilde{\Sigma}Z(Z^T \tilde{\Sigma} Z)^{-1}Z^T \tilde{\Sigma}\)</span>,
30723077
<span class="math inline">\(Z=\boldsymbol{1}^T\)</span>, and <span class="math inline">\(\log(J)=-(\gamma_1+\gamma_2)\)</span> represents the
30733078
determinant of the log-precision transformation. For <span class="math inline">\(b=1\)</span> these
@@ -3777,7 +3782,7 @@ <h3 class="appendix" data-number="8" id="note"><span class="header-section-numbe
37773782
(function () {
37783783
var script = document.createElement("script");
37793784
script.type = "text/javascript";
3780-
script.src = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js";
3785+
script.src = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js";
37813786
document.getElementsByTagName("head")[0].appendChild(script);
37823787
})();
37833788
</script>

0 commit comments

Comments
 (0)