R/fitTK.R

Defines functions fitTK.stanTKdataVAR fitTK.stanTKdataCST fitTK

Documented in fitTK fitTK.stanTKdataCST fitTK.stanTKdataVAR

#' Posterior predictive check
#'
#' @param stanTKdata List of Data require for computing
#' @param \dots Arguments passed to `rstan::sampling` (e.g. iter, chains).
#' 
#' @return An object of class `fitTK` containing two object: \code{stanTKdata}
#' the data set used for inference and \code{stanfit}  returned by `rstan::sampling`
#' 
#' @rdname fitTK
#' 
#' @export
#' 
fitTK <- function(stanTKdata, ...){
   UseMethod("fitTK")
}


#' Bayesian inference of TK model with Stan
#' 
#' @rdname fitTK
#'
#' @export
#' 
fitTK.stanTKdataCST <- function(stanTKdata, ...) {
   # remove additional variables
   dataFit <- stanTKdata
   dataFit$origin_data <- NULL
   stanfit <- rstan::sampling(stanmodels$TK, data = dataFit, ...)
   out <- list(stanTKdata = stanTKdata, stanfit = stanfit)
   class(out) <- append("fitTK", class(out))
   return(out)
}


#' Bayesian inference of TK model with variable exposure profile (BETA version)
#'
#' @rdname fitTK
#' 
#' @export
#'
 fitTK.stanTKdataVAR <- function(stanTKdata, ...) {
   stanfit <- rstan::sampling(stanmodels$odeTK, data = stanTKdata, ...)
   out <- list(stanTKdata = stanTKdata, stanfit = stanfit)
   class(out) <- append("fitTK", class(out))
   return(out)
 }

Try the rbioacc package in your browser

Any scripts or data that you put into this service are public.

rbioacc documentation built on Sept. 21, 2023, 5:06 p.m.