bart.likelihood#

Module: bart.likelihood#

We want to evaluate

$$ int_{mathbb{R}} rac{1}{(2pisigma^2)^{n/2}} rac{1}{sqrt{2 pi sigma^2_{mu}}} expleft(- rac{1}{2sigma^2} sum_{i=1}^n (R_i-mu)^2 - rac{1}{2 sigma^2_{mu}}(mu-mu_0)^2 ight) ; dmu $$

Clearly depends on \(R\) only through \(ar{R}\) and \(\|R-ar{R}\|^2_2\) $$ = rac{exp left(- rac{1}{2sigma^2} |R-ar{R}|^2_2 ight)}{(2pisigma^2)^{n/2}} int_{mathbb{R}}

rac{1}{sqrt{2 pi sigma^2_{mu}}} expleft(- rac{n}{2sigma^2} (ar{R}-mu)^2 - rac{1}{2 sigma^2_{mu}}(mu-mu_0)^2 ight) ; dmu $$

Expanding: $$ = rac{expleft(- rac{1}{2sigma^2} |R-ar{R}|^2_2- rac{n}{2sigma^2}ar{R}^2- rac{mu_0^2}{2sigma^2_{mu}} ight)}{(2pisigma^2)^{n/2}sqrt{2 pi sigma^2_{mu}}} int_{mathbb{R}} expleft(-left( rac{n}{2sigma^2} + rac{1}{2 sigma^2_{mu}} ight)mu^2 + mu left( rac{ar{R} cdot n}{sigma^2} + rac{mu_0}{sigma^2_{mu}} ight) ight) ; dmu $$

Setting $$ ar{sigma}^{2} = left( rac{n}{2 sigma^2} + rac{1}{2 sigma^2_{mu}} ight)^{-1} $$ this is $$ = rac{expleft(- rac{1}{2sigma^2} |R|^2_2- rac{mu_0^2}{2sigma^2_{mu}} ight)}{(2pisigma^2)^{n/2}sqrt{2 pi sigma^2_{mu}}} cdot sqrt{2 pi ar{sigma}^2} int_{mathbb{R}} rac{1}{sqrt{2piar{sigma}^2}} expleft(- rac{1}{2 ar{sigma}^2} mu^2 + mu left( rac{ar{R} cdot n}{sigma^2} + rac{mu_0}{sigma^2_{mu}} ight) ight) ; dmu $$

Finally, this is $$ = rac{expleft(- rac{1}{2sigma^2} |R|^2_2- rac{mu_0^2}{2sigma^2_{mu}} ight)}{(2pisigma^2)^{n/2}sqrt{2 pi sigma^2_{mu}}} cdot sqrt{2 pi ar{sigma}^2} expleft( rac{ar{sigma}^2}{2} left( rac{ar{R} cdot n}{sigma^2} + rac{mu_0}{sigma^2_{mu}} ight)^2 ight) $$

Or, setting $$ ar{mu} = rac{ rac{ar{R} cdot n}{sigma^2} +

rac{mu_0}{sigma^2_{mu}}}{ rac{n}{sigma^2} +

rac{1}{sigma^2_{mu}}} $$ this is $$ = rac{expleft(- rac{1}{2sigma^2} |R|^2_2 - rac{mu_0^2}{2sigma^2_{mu}} ight)}{(2pisigma^2)^{n/2}sqrt{2 pi sigma^2_{mu}}} cdot sqrt{2 pi ar{sigma}^2} expleft( rac{1}{2ar{sigma}^2} ar{mu}^2 ight) $$

Functions#

ISLP.bart.likelihood.incremental_loglikelihood(response, idx_L, idx_R, sigmasq, mu_prior_mean, mu_prior_var)#
ISLP.bart.likelihood.marginal_loglikelihood(response, sigmasq, mu_prior_mean, mu_prior_var, incremental=False, response_moments=None)#