TABLE OF CONTENTS


S3Methods/post.fvar [ Functions ]

NAME

    post.fvar --- compute posterior frailty variance

FUNCTION

Compute the posterior mean frailty variance and its quantiles by weighing posterior spline and parametric component frailty variances together. The former is computed at each iteration as the variance of the density defined by the current set of knots and parameters for the frailty spline.

SYNOPSIS

3639 post.fvar <- function(x, quantiles = c(.025, .975))

INPUTS

    x      an object of class splinesurv
    quantiles  a list of quantiles at which to compute

OUTPUTS

    means  a vector containing the overall frailty variance, the variance of the spline
           component, and the variance of the parametric component
    quantiles  a matrix containing the same for each given quantile

SOURCE

3642 {
3643     goodind <- (x$control$burnin + 1):(x$control$iter)
3644     # spline component
3645     if(hasspline(x$frailty)) spline.fvars <- x$history$frailty.spline.fvar[goodind] else 
3646         spline.fvars <- NULL
3647     # parametric component
3648     if(haspar(x$frailty)) 
3649         param.fvars <- exp(x$history$frailty.param.par[goodind, ,drop = FALSE]) else 
3650             param.fvars <- NULL
3651     # weigh the two components
3652     if(haspar(x$frailty) & hasspline(x$frailty)){
3653         weights <- x$history$frailty.weight[goodind, ,drop = F]
3654         fvars <- weights * spline.fvars + (1 - weights) * param.fvars
3655     }else{
3656         if(haspar(x$frailty)) fvars <- param.fvars else fvars <- spline.fvars
3657     }
3658     # compute means
3659     fvar.means <- suppressWarnings(rbind(mean(fvars), mean(spline.fvars), mean(param.fvars)))
3660     # compute quantiles
3661     fvar.quantiles <- suppressWarnings(rbind(quantile(fvars, quantiles),
3662         quantile(spline.fvars, quantiles), quantile(param.fvars, quantiles)))
3663     rownames(fvar.means) <- rownames(fvar.quantiles) <- c("fvar", "spline.fvar", "param.fvar")
3664     return(list(mean = fvar.means, quantiles = fvar.quantiles))
3665 }