TABLE OF CONTENTS


CMetropolisHastings/MH_ParamFrailty [ Functions ]

NAME

    MH_ParamFrailty --- MH for frailty parametric component parameters

FUNCTION

Update the parameters indexing the parametric component by Metropolis-Hastings, see also mh.frailty.param

SYNOPSIS

2276 void MH_ParamFrailty(curveP hazard, curveP frailty, regressionP regression)

INPUTS

    hazard        CCurve for the hazard
    frailty       CCurve for the frailty
    regression    CRegression structure

SOURCE

2280 { 
2281     if(!frailty->hasPar) return;
2282     double baselik, candlik;
2283     // base likelihood
2284     baselik = LikelihoodParamFrailty(hazard,frailty,regression);
2285     double * cand = (double *) calloc( frailty->np, sizeof(double));
2286     double * oldPar = (double *) malloc( frailty->np * sizeof(double));
2287     dcopyWrapper(frailty->np, frailty->ParamPar, oldPar);
2288     // generate candidate
2289     mvrnorm(frailty->np, cand, frailty->ParamPar, frailty->ParamCholCov, frailty->ParamTun[0]);
2290     // update curve with candidate parameter
2291     UpdateParamPar(frailty,cand);
2292     // candidate likelihood
2293     candlik = LikelihoodParamFrailty(hazard,frailty,regression);
2294     int acc = AcceptReject(baselik, candlik, 1);
2295     if(!acc) // rejected, undo damage
2296         UpdateParamPar(frailty,oldPar);
2297     frailty->ParamAccept[0] = (double) acc;
2298     free(cand);
2299     free(oldPar);
2300 }