RE: Simulate with ETAs from .phi and residual variability

From: Andreas Lindauer Date: October 09, 2023 technical Source: mail-archive.com
Dear Philp, You may also want to have a look at the open-source R package campsis ( https://calvagone.github.io/). Below is some R-code that illustrates how you can easily simulate individual profiles taking the ETAs from a NONMEM output table. Best regards, Andreas. --------------------------------------------------------------------------------------------------------------------------- library(tidyverse) library(campsis) # Load a standard model from the library # you can also set-up a custom model using the free online simulator e-campsis.com) model <- model_library$advan2_trans2 # set the parameter values model <- model %>% replace(Theta("V", value=20)) model <- model %>% replace(Theta("CL", value=5)) model <- model %>% replace(Omega("V", value=0.1,type = 'var')) model <- model %>% replace(Omega("CL", value=0.1,type = 'var')) model <- model %>% replace(Sigma("PROP", value=0.02,type = 'var')) # Have a look at the model model # load NONMEM output table containing the ETAS (and covariates if you have) ETA.tab <- read_table("patab001",skip = 1) %>% group_by(ID) %>% slice(1) %>% # take only the first record of each subject rename(ETA_CL=ETA1,ETA_V=ETA2) # you may need to rename variables to match with the model code # set-up the simulation schedule; the number of subject must equal that of ETA.tab dataset <- Dataset(subjects = n_distinct(ETA.tab$ID)) %>% add(Bolus(time=0, amount=1000, ii=12, addl=2)) %>% add(Observations(times=seq(0, 36, by=0.5))) # add the ETAs by using the bootstrap functionality dataset <- dataset %>% add(Bootstrap(data= ETA.tab, id="ID", replacement=FALSE, random=FALSE, export_id=TRUE)) # we need to discard the random IIV as the ETAs are taken from the dataset model@parameters@list <- model@parameters@list %>% purrr::discard(.p=~is(.x, "omega")) # run the simulation results <- model %>% simulate(dataset=dataset,outvars = c('BS_ID')) # BS_ID is the original ID in the ETA.tab # plot the results spaghettiPlot(results,'OBS_CP')
Quoted reply history
-----Original Message----- From: [email protected] <[email protected]> On Behalf Of Philip Harder Delff Sent: Sunday, October 8, 2023 9:30 PM To: [email protected] Subject: [NMusers] Simulate with ETAs from .phi and residual variability Dear all, I want to simulate subjects with ETAs estimated. I use the .phi file using a $ETAS statement like: $ETAS FILE=file.phi FORMAT=s1pE15.8 TBLN=1 As far as I understand that has to be accompanied by a $ESTIMATION step that specifies FNLETA=2 like this: $ESTIMATION MAXEVAL=0 NOABORT METHOD=1 INTERACTION FNLETA=2 $SIM ONLYSIM does not work with $ESTIMATION so instead I just do: $SIMULATION (220412) This however means that in the following from $ERROR we don't get the ERR(1) and ERR(2) simulated and so Y=IPRED. Y=F+F*ERR(1)+ERR(2) I need to be able to edit the phi file to only simulate a subset of the patients so I can't use msf based solutions. Can I somehow use $ETAS without $ESTIMATION? Or how else can I get it to simulate the residual variability? Thank you, Philip
Oct 08, 2023 Philip Harder Delff Simulate with ETAs from .phi and residual variability
Oct 09, 2023 Leonid Gibiansky Re: Simulate with ETAs from .phi and residual variability
Oct 09, 2023 Andreas Lindauer RE: Simulate with ETAs from .phi and residual variability
Oct 09, 2023 Philip Harder Delff Re: Simulate with ETAs from .phi and residual variability