TABLE OF CONTENTS
initRoutine/inithistory [ Functions ]
NAME
inithistory --- initialize the history structure
FUNCTION
The history structure keeps track of the posterior samples from the chain. It contains components for all the parameters that change in the course of the chain. The function updatehistory is called at the end of each iteration to update this structure.
SYNOPSIS
1010 inithistory <- function(hazard, frailty, regression, control)
INPUTS
hazard a hazard RCurve frailty a frailty RCurve regression a RRegression structure control an RControl structure
OUTPUTS
an RHistory structure
SOURCE
1013 { 1014 history <- NULL 1015 maxiter <- control$maxiter 1016 history$frailty <- matrix(0, maxiter, length(frailty$x)) 1017 history$coefficients <- matrix(0, maxiter, length(regression$coefficients)) 1018 # ssorate for spline knots and parameters 1019 if(hazard$hasspline) { 1020 history$hazard.spline.par <- matrix(-Inf, maxiter, 1021 hazard$spline.maxoccknots + hazard$spline.ord) 1022 history$hazard.spline.knots <- matrix(-Inf, maxiter, 1023 hazard$spline.maxoccknots + 2 * hazard$spline.ord) 1024 } 1025 if(frailty$hasspline) { 1026 history$frailty.spline.par <- matrix(-Inf, maxiter, 1027 frailty$spline.maxoccknots + frailty$spline.ord) 1028 history$frailty.spline.knots <- matrix(-Inf, maxiter, 1029 frailty$spline.maxoccknots + 2 * frailty$spline.ord) 1030 history$frailty.spline.fvar <- matrix(0, maxiter, 1) 1031 } 1032 # storage for parametric parameters 1033 if(hazard$haspar) history$hazard.param.par <- matrix(0, 1034 maxiter, length(hazard$param.par)) 1035 if(frailty$haspar) history$frailty.param.par <- matrix(0, 1036 maxiter, length(frailty$param.par)) 1037 # storage for weights 1038 if(hazard$hasspline & hazard$haspar) history$hazard.weight <- matrix(0, maxiter, 1) 1039 if(frailty$hasspline & frailty$haspar) history$frailty.weight <- matrix(0, maxiter, 1) 1040 # storage for prior variances 1041 history$priorvar <- matrix(0, maxiter, 7); 1042 colnames(history$priorvar) <- c("coefficients", "hazard.spline", "frailty.spline", 1043 "hazard.param", "frailty.param", "hazard.weight", "frailty.weight") 1044 # storage for acceptance history 1045 history$accept <- matrix(0, maxiter, 8) 1046 colnames(history$accept) <- c(colnames(history$priorvar), "frailty") 1047 # update with first iteration 1048 history <- updatehistory(history, 1, hazard, frailty, regression) 1049 return(history) 1050 }