TABLE OF CONTENTS


CMetropolisHastings/MH_ParamHazard [ Functions ]

NAME

    MH_ParamHazard --- MH for hazard parametric component parameters

FUNCTION

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

SYNOPSIS

2237 void MH_ParamHazard(curveP hazard, curveP frailty, regressionP regression)

INPUTS

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

SOURCE

2241 {
2242     if(!hazard->hasPar) return;
2243     double baselik, candlik;
2244     // base likelihoood
2245     baselik = LikelihoodParamHazard(hazard,frailty,regression);
2246     // storage for old settings
2247     double * cand = (double *) calloc( hazard->np, sizeof(double));
2248     double * oldPar = (double *) malloc( hazard->np * sizeof(double));
2249     dcopyWrapper(hazard->np, hazard->ParamPar, oldPar);
2250     mvrnorm(hazard->np, cand, hazard->ParamPar, hazard->ParamCholCov, hazard->ParamTun[0]);
2251     // update curve at candidate
2252     UpdateParamPar(hazard,cand);
2253     // candidate likelihodo
2254     candlik = LikelihoodParamHazard(hazard,frailty,regression);
2255     int acc = AcceptReject(baselik, candlik, 1);
2256     if(!acc) // rejected, undo damage
2257         UpdateParamPar(hazard,oldPar);
2258     hazard->ParamAccept[0] = (double) acc;
2259     free(cand);
2260     free(oldPar);
2261 }