R/evaluate.e.ofv.fim.R
evaluate.e.ofv.fim.Rd
Compute the expectation of the FIM and OFV(FIM) given the model, parameters, distributions of parameter uncertainty, design and methods defined in the
PopED database. Some of the arguments coming from the PopED database can be overwritten;
by default these arguments are NULL
in the
function, if they are supplied then they are used instead of the arguments from the PopED database.
evaluate.e.ofv.fim( poped.db, fim.calc.type = NULL, bpop = poped.db$parameters$bpop, d = poped.db$parameters$d, covd = poped.db$parameters$covd, docc = poped.db$parameters$docc, sigma = poped.db$parameters$sigma, model_switch = NULL, ni = NULL, xt = NULL, x = NULL, a = NULL, groupsize = poped.db$design$groupsize, deriv.type = NULL, bLHS = poped.db$settings$bLHS, ofv_calc_type = poped.db$settings$ofv_calc_type, ED_samp_size = poped.db$settings$ED_samp_size, use_laplace = poped.db$settings$iEDCalculationType, laplace.fim = FALSE, ... )
poped.db  A PopED database. 

fim.calc.type  The method used for calculating the FIM. Potential values:

bpop  Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
Can also just supply the parameter values as a vector 
d  Matrix defining the diagonals of the IIV (same logic as for the fixed effects
matrix bpop to define uncertainty). One can also just supply the parameter values as a 
covd  Column major vector defining the covariances of the IIV variances.
That is, from your full IIV matrix 
docc  Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop. 
sigma  Matrix defining the variances can covariances of the residual variability terms of the model.
can also just supply the diagonal parameter values (variances) as a 
model_switch  A matrix that is the same size as xt, specifying which model each sample belongs to. 
ni  A vector of the number of samples in each group. 
xt  A matrix of sample times. Each row is a vector of sample times for a group. 
x  A matrix for the discrete design variables. Each row is a group. 
a  A matrix of covariates. Each row is a group. 
groupsize  A vector of the number of individuals in each group. 
deriv.type  A number indicating the type of derivative to use:

bLHS  How to sample from distributions in Efamily calculations. 0=Random Sampling, 1=LatinHyperCube  
ofv_calc_type  OFV calculation type for FIM

ED_samp_size  Sample size for Efamily sampling 
use_laplace  Should the Laplace method be used in calculating the expectation of the OFV? 
laplace.fim  Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically the FIM does not need to be computed and, if desired, this calculation is done using the standard MC integration technique, so can be slow. 
...  Other arguments passed to the function. 
A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db updated according to the function arguments.
Other FIM:
LinMatrixH()
,
LinMatrixLH()
,
LinMatrixL_occ()
,
calc_ofv_and_fim()
,
ed_laplace_ofv()
,
ed_mftot()
,
efficiency()
,
evaluate.fim()
,
gradf_eps()
,
mf3()
,
mf7()
,
mftot()
,
ofv_criterion()
,
ofv_fim()
Other Efamily:
calc_ofv_and_fim()
,
ed_laplace_ofv()
,
ed_mftot()
Other evaluate_FIM:
calc_ofv_and_fim()
,
evaluate.fim()
,
ofv_fim()
library(PopED) ############# START ################# ## Create PopED database ## (warfarin model for optimization ## with parameter uncertainty) ##################################### ## Warfarin example from software comparison in: ## Nyberg et al., "Methods and software tools for design evaluation ## for population pharmacokineticspharmacodynamics studies", ## Br. J. Clin. Pharm., 2014. ## Optimization using an additive + proportional reidual error ## to avoid sample times at very low concentrations (time 0 or very late samoples). ## find the parameters that are needed to define from the structural model ff.PK.1.comp.oral.sd.CL#> function (model_switch, xt, parameters, poped.db) #> { #> with(as.list(parameters), { #> y = xt #> y = (DOSE * Favail * KA/(V * (KA  CL/V))) * (exp(CL/V * #> xt)  exp(KA * xt)) #> return(list(y = y, poped.db = poped.db)) #> }) #> } #> <bytecode: 0x7fe20a979808> #> <environment: namespace:PopED>##  parameter definition function ##  names match parameters in function ff sfg < function(x,a,bpop,b,bocc){ parameters=c(CL=bpop[1]*exp(b[1]), V=bpop[2]*exp(b[2]), KA=bpop[3]*exp(b[3]), Favail=bpop[4], DOSE=a[1]) return(parameters) } # Adding 10% lognormal Uncertainty to fixed effects (not Favail) bpop_vals < c(CL=0.15, V=8, KA=1.0, Favail=1) bpop_vals_ed_ln < cbind(ones(length(bpop_vals),1)*4, # lognormal distribution bpop_vals, ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value bpop_vals_ed_ln["Favail",] < c(0,1,0) bpop_vals_ed_ln#> bpop_vals #> CL 4 0.15 0.000225 #> V 4 8.00 0.640000 #> KA 4 1.00 0.010000 #> Favail 0 1.00 0.000000##  Define initial design and design space poped.db < create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, fg_fun=sfg, fError_fun=feps.add.prop, bpop=bpop_vals_ed_ln, notfixed_bpop=c(1,1,1,0), d=c(CL=0.07, V=0.02, KA=0.6), sigma=c(0.01,0.25), groupsize=32, xt=c( 0.5,1,2,6,24,36,72,120), minxt=0, maxxt=120, a=70, mina=0, maxa=100) ############# END ################### ## Create PopED database ## (warfarin model for optimization ## with parameter uncertainty) ##################################### ## ED evaluate (with very few samples) output < evaluate.e.ofv.fim(poped.db,ED_samp_size=10) output$E_ofv#> [1] 55.45214## API evaluate (with very few samples) output < evaluate.e.ofv.fim(poped.db,ED_samp_size=10,ofv_calc_type=4) output$E_ofv#> [1] 55.46088## ED evaluate using Laplace approximation tic() output < evaluate.e.ofv.fim(poped.db,use_laplace=TRUE) toc()#> Elapsed time: 1.3 seconds.output$E_ofv#> [1] 1.302806e+24if (FALSE) { ## ED expected value with more precision. ## Compare time and value to Laplace approximation. ## Run a couple of times to see stochasticity of calculation. tic() e_ofv_mc < evaluate.e.ofv.fim(poped.db,ED_samp_size=500) toc() e_ofv_mc$E_ofv # If you want to get an E(FIM) from the laplace approximation you have to ask for it # and it will take more time. output < evaluate.e.ofv.fim(poped.db,use_laplace=TRUE,laplace.fim=TRUE) output$E_fim }