paper/paper-msmk/bsw-code.R

genData = function(m, th, genLik){
    # Generate data from Y|\theta
    #
    # @param m: rational subgroups generated at each time t
    # @param th: distribution of the parameter
    #
    # @return updated hyperparameters
    return(genLik(m, th))
}

updatePars = function(hyp, y, upFun){
    # Update parameters for the 
	#
    # @param hyp: hyperparameters of the distribution
    # @param y: observed data from Y|\theta
    # @param upFun: function(y) that updates the parameters
	#
    # @return updated hyperparameters
    hyp = hyp + upFun(y)
    return(hyp)
}

genPred = function(npred, hyp, predDist){
    # Predictive distribution of the data
	#
    # @param npred: number of points to generate
    # @param hyp: hyperparameters of the distribution
	#
    # @return vector of points generated by the predictive distribution

    return(predDist(npred, hyp))
}

selfStart = function(nstart, p0, l, setup){
    genLik = setup$lik
    upFun = setup$upStat
    p = p0
    for(t in 1:nstart){
        y = genData(m, l, genLik)
        p = updatePars(p, y, upFun)
    }
    return(p)
}
DedZago/msMK documentation built on June 14, 2022, 10:29 p.m.