Chapter 9 Algorithm to fit HBART (stump)


Algorithm type: Metropolis within GIBBS for a hierachical BART model

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

Data: Target variable y, groups j=1,,J

Result: Posterior distributions for all parameters


Initialisation;

Hyper-parameters values for α,β,k2;

Number of groups J;

Number of trees P;

Total number of nodes Np

Number of observations N=Jj=1nj;

Number of iterations I;

  • define μμ=0, μ0, τ0, and μ0j,j=1,,J, k01, 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=Yijpt=1μjt, 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 ˆfij as the current overall prediction for observation Rij, which will be Ppppμjp, where pp represents the current tree index.

  • sample τ from the posterior Ga(N+JNp+Np2+α,Ni=1(yiˆfi)22+Pj,l,p(μj,l,pμl,p)22k1+Pl,pμ2l,p2k2+β)

  • sample k1 from a Uniform(0, u)

    • 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 the new k1; else keep the current k1

  • end