Chapter 9 Algorithm to fit a stump


Algorithm type: Metropolis within GIBBS for a hierachical BART models

Reason: We have closed posteriors for most parameters, but not for the tree structure

Data: Target variable y, groups j=1,,J, set of features X

Result: Posterior distributions for all parameters


Initialisation;

Hyper-parameters values for α,β,k1,k2;

Number of groups J;

Number of trees P;

Number of observations N=Jj=1nj;

Number of iterations I;

  • define μμ=0, μ0, τ0, and μ0j,j=1,,J as the initial parameter values

  • for i from 1 to I do:

  • for p from 1 to P do:

  • sample μp from the posterior N(1TΨ1Rp1TΨ11+(k2/P)1,τ1(1TΨ11+(k2/P)1))

  • for j in 1:J do:

    • sample μjp from the posterior MVN(Pμ/k1+ˉRpjnj(nj+P/k1),τ1(nj+P/k1))
  • end

  • set Rijp=Yijpl=1μjl, or, in other words, the residuals for tree p are the vector y minus the sum of the μjp values up to tree p

  • end

  • Define ˆflj as the current overall prediction for observation Rlj, which will be {p = 1}^{P} {lp}$, where l represents the observation index

  • sample τ from the posterior Ga(n+P+12+α,l,j(yljˆflj)22+j,p(μjpμp)22+j,pμ2p2+β)

  • sample k1 from a Uniform(0, 20)

    • calculate p_old as the conditional distribution for the current k1

    • calculate p_new as the conditional distribution for the newly sampled k1

    • sample U from a Unif(0, 1)

    • if (a > u) accept k1_new

  • end