lixoftConnectors tar gz code example

Example 1: lixoftConnectors tar gz

# load and initialize the API
library(lixoftConnectors)
initializeLixoftConnectors(software="monolix")

# create a new project by setting a data set and a structural model
# replace <userFolder> by the path to your home directory
demoPath = 'C:/Users/username/lixoft/monolix/monolix2019R1/demos/1.creating_and_using_models/1.1.libraries_of_models/'
librariesPath = 'C:/ProgramData/Lixoft/MonolixSuite2019R1/factory/library/pk'
newProject(data = list(dataFile = paste0(demoPath,'data/warfarin_data.txt'),
                       headerTypes =c("id", "time", "amount", "observation", "obsid", "contcov", "catcov", "ignore"),
                       observationTypes = list(y1 = "continuous", y2 = "continuous" ),
                       mapping = list("1" = "y1")),
           modelFile = paste0(librariesPath,'/oral1_1cpt_TlagkaVCl.txt'))

# set tasks in scenario
scenario <- getScenario()
scenario$tasks = c(populationParameterEstimation = T, 
                   conditionalModeEstimation = T, 
                   conditionalDistributionSampling = T, 
                   standardErrorEstimation=T, 
                   logLikelihoodEstimation=T)
scenario$linearization = TRUE
setScenario(scenario)

# ----------------------------------------------------------------------------
# convergence assessment: run 5 estimations with different initial estimates,
# store the results in tabestimates
# ----------------------------------------------------------------------------
popparams <- getPopulationParameterInformation()
tabestimates <- NULL; tabse <- NULL
for(i in 1:5){
   # sample new initial estimates
   popini <- sapply(1:nrow(popparams), function(j){runif(n=1, min=popparams$initialValue[j]/2, max=popparams$initialValue[j]*2)})

   # set sampled values as new initial estimates
   newpopparams <- popparams
   newpopparams$initialValue <- popini
   setPopulationParameterInformation(newpopparams)

   # run the estimation
   runScenario()

   # store the estimates and s.e. in table
   tabestimates <- cbind(tabestimates, getEstimatedPopulationParameters())
   tabse <- cbind(tabse, getEstimatedStandardErrors()$stochasticApproximation)
}

Example 2: lixoftConnectors tar gz

# load and initialize the API
library(lixoftConnectors) 
initializeLixoftConnectors(software="monolix")

demoPath = 'C:/Users/username/lixoft/monolix/monolix2019R1/demos/1.creating_and_using_models/1.1.libraries_of_models/'
project <- paste0(demoPath, "theophylline_project.mlxtran"
loadProject(projectFile = project)

runPopulationParameterEstimation()
iter <- getSAEMiterations()
print(paste0("Iterations in exploratory phase: ",iter$iterationNumbers[1]))
print(paste0("Iterations in smoothing phase: ",iter$iterationNumbers[2]))

Example 3: lixoftconnectors

install.packages(packagePath, repos = NULL, type="source", INSTALL_opts ="--no-multiarch")