3737# ' @param object A posologyr list, created by the \code{\link{posologyr}}
3838# ' function.
3939# ' @param n_simul An integer, the number of simulations to be run. For `n_simul
40- # ' = 0`, all ETAs are set to 0.
40+ # ' = 0`, all ETAs are set to 0.
4141# ' @param return_model A boolean. Returns a RxODE model using the simulated
4242# ' ETAs if set to `TRUE`.
4343# '
44- # ' @return If `return_model` is set to `FALSE`, a dataframe of the
45- # ' individual values of ETA.
44+ # ' @return If `return_model` is set to `FALSE`, a list of one element: a
45+ # ' dataframe `$eta` of the individual values of ETA.
4646# ' If `return_model` is set to `TRUE`, a list of the dataframe of the
4747# ' individual values of ETA, and a RxODE model using the simulated ETAs.
4848# '
6464# '
6565# ' @export
6666poso_simu_pop <- function (object = NULL ,n_simul = 1000 ,
67- return_model = TRUE ){
67+ return_model = TRUE ){
6868
6969 omega <- object $ omega
7070 eta_mat <- matrix (0 ,nrow = 1 ,ncol = ncol(omega ))
@@ -89,7 +89,7 @@ poso_simu_pop <- function(object=NULL,n_simul=1000,
8989 theta <- rbind(object $ theta )
9090 covar <- object $ tdm_data [1 ,object $ covariates ]
9191 names(covar ) <- object $ covariates
92- model_pop $ params <- cbind(theta ,eta_df ,covar ,row.names = NULL )
92+ model_pop $ params <- cbind(theta ,eta_df ,covar ,row.names = NULL )
9393 eta_pop $ model <- model_pop
9494 }
9595
@@ -111,10 +111,10 @@ poso_simu_pop <- function(object=NULL,n_simul=1000,
111111# ' (RSE) of the MAP estimates of ETA if set to `TRUE`.
112112# '
113113# ' @return A named list consisting of one or more of the following elements
114- # ' depending on the input parameters of the function: a named vector of the
115- # ' MAP estimates of the individual values of ETA, an RxODE model using the
116- # ' estimated ETAs, the Fisher information matrix, a named vector of RSEs
117- # ' of the MAP estimates of ETAs.
114+ # ' depending on the input parameters of the function: `$eta` a named vector
115+ # ' of the MAP estimates of the individual values of ETA, `$ model` an RxODE
116+ # ' model using the estimated ETAs, `$fim` the Fisher information matrix,
117+ # ' `$rse` a named vector of RSEs of the MAP estimates of ETAs.
118118# '
119119# ' @examples
120120# ' # df_patient01: event table for Patient01, following a 30 minutes intravenous
@@ -133,8 +133,8 @@ poso_simu_pop <- function(object=NULL,n_simul=1000,
133133# ' poso_estim_map(patient01_tobra)
134134# '
135135# ' @export
136- poso_estim_map <- function (object = NULL ,return_model = TRUE ,
137- return_fim = FALSE ,return_rse = FALSE )
136+ poso_estim_map <- function (object = NULL ,return_model = TRUE ,
137+ return_fim = FALSE ,return_rse = FALSE )
138138{
139139
140140 # Update model predictions with a new set of parameters, for all obs-----
@@ -196,7 +196,7 @@ poso_estim_map <- function(object=NULL,return_model = TRUE,
196196 if (return_rse ){
197197 map_se <- sqrt(diag(solve(r $ hessian ))) # the inverse of the fim is the
198198 # variance-covariance matrix
199- map_rse <- map_se / abs(eta_map )
199+ map_rse <- map_se / abs(eta_map [ ind_eta ] )
200200 estim_map $ rse <- map_rse
201201 }
202202
@@ -231,8 +231,9 @@ poso_estim_map <- function(object=NULL,return_model = TRUE,
231231# ' @param control A list of parameters controlling the Metropolis-Hastings
232232# ' algorithm.
233233# '
234- # ' @return If `return_model` is set to `FALSE`, a dataframe of ETAs from
235- # ' the posterior distribution, estimated by Markov Chain Monte Carlo.
234+ # ' @return If `return_model` is set to `FALSE`, , a list of one element: a
235+ # ' dataframe `$eta` of ETAs from the posterior distribution, estimated by
236+ # ' Markov Chain Monte Carlo.
236237# ' If `return_model` is set to `TRUE`, a list of the dataframe of the posterior
237238# ' distribution of ETA, and a RxODE model using the estimated distributions of ETAs.
238239# '
@@ -259,7 +260,7 @@ poso_estim_map <- function(object=NULL,return_model = TRUE,
259260# ' poso_estim_mcmc(patient01_tobra,n_iter=100)
260261# '
261262# ' @export
262- poso_estim_mcmc <- function (object = NULL ,return_model = TRUE ,burn_in = 50 ,
263+ poso_estim_mcmc <- function (object = NULL ,return_model = TRUE ,burn_in = 50 ,
263264 n_iter = 1000 ,control = list (n_kernel = c(2 ,2 ,2 ),
264265 stepsize_rw = 0.4 ,proba_mcmc = 0.3 ,nb_max = 3 )){
265266 # Update model predictions with a new set of parameters, for all obs-----
@@ -391,7 +392,7 @@ poso_estim_mcmc <- function(object=NULL,return_model = TRUE,burn_in=50,
391392 theta_return <- rbind(theta )
392393 covar <- dat [1 ,object $ covariates ]
393394 names(covar ) <- object $ covariates
394- model_mcmc $ params <- cbind(theta_return ,eta_df_mcmc ,covar ,row.names = NULL )
395+ model_mcmc $ params <- cbind(theta_return ,eta_df_mcmc ,covar ,row.names = NULL )
395396 estim_mcmc $ model <- model_mcmc
396397 }
397398
0 commit comments