Package: campsismod 1.4.2

Nicolas Luyckx

campsismod: Generic Implementation of a PK/PD Model

A generic, easy-to-use and expandable implementation of a pharmacokinetic (PK) / pharmacodynamic (PD) model based on the S4 class system. This package allows the user to read and write pharmacometric models from and to files, including a JSON-based interface to import Campsis models defined using a formal JSON schema distributed with the package. Models can be adapted further on the fly in the R environment using an intuitive API to add, modify or delete equations, ordinary differential equations (ODEs), model parameters or compartment properties (such as infusion duration or rate, bioavailability and initial values). The package also provides export facilities for use with the simulation packages 'rxode2' and 'mrgsolve'. The package itself is licensed under the GPL (>= 3); the JSON schema file shipped in inst/extdata is licensed separately under the Creative Commons Attribution 4.0 International (CC BY 4.0). This package is designed and intended to be used with the package 'campsis', a PK/PD simulation platform built on top of 'rxode2' and 'mrgsolve'.

Authors:Nicolas Luyckx [aut, cre], Calvagone [cph]

campsismod_1.4.2.tar.gz
campsismod_1.4.2.zip(r-4.7-any)campsismod_1.4.2.zip(r-4.6-any)campsismod_1.4.2.zip(r-4.5-any)
campsismod_1.4.2.tgz(r-4.6-any)campsismod_1.4.2.tgz(r-4.5-any)
campsismod_1.4.2.tar.gz(r-4.7-any)campsismod_1.4.2.tar.gz(r-4.6-any)
campsismod_1.4.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
campsismod/json (API)

# Install 'campsismod' in R:
install.packages('campsismod', repos = c('https://campsisverse.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/calvagone/campsismod/issues

Datasets:

On CRAN:

Conda:

7.69 score 7 stars 2 packages 66 scripts 721 downloads 143 exports 47 dependencies

Last updated from:9868639344. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK212
source / vignettesOK251
linux-releaseOK240
macos-releaseOK149
macos-oldrelOK151
windows-develOK187
windows-releaseOK184
windows-oldrelOK113
wasm-releaseOK125

Exports::=%>%addadd_rseadd_suffixaddSuffixall_naas.data.frameassert_single_character_stringauto_detect_nonmemAutoReplicationSettingsBioavailabilityCampsisModelCodeRecordsCommentCompartmentCompartmentscontainsdefaultdeletedisableEquationErrorRecordexportexport_to_jsonextract_lhsextract_rhsextract_text_between_bracketsfindfix_omegafixOmegaget_by_indexget_by_nameget_campsismod_optionget_campsismod_optionsget_compartment_indexget_nameget_name_in_modelget_namesget_nonmem_nameget_omega_blockget_omega_indexesget_prefixget_record_delimiterget_record_equation_namesget_record_nameget_uncertaintyget_var_covgetByIndexgetByNamegetCompartmentIndexgetNamegetNameInModelgetNamesgetUncertaintyhas_commenthas_exact_methodhas_off_diagonal_omegasIfStatementindex_ofindexOfInfusionDurationInfusionRateInitialConditionis_commentis_diagis_empty_lineis_equationis_if_statementis_matrix_positive_definiteis_odeis_record_delimiteris_rxodeis_strict_record_delimiterisDiagjson_to_parameterJSONElementjsonToParameterLagTimeLineBreakload_from_jsonloadFromJSONMainRecordManualReplicationSettingsmap_json_properties_to_s4_slotsmap_s4_slots_to_json_propertiesmapJSONPropertiesToS4SlotsmapS4SlotsToJSONPropertiesmax_indexmaxIndexmin_indexminIndexModelStatementsmovemrgsolve_blockmrgsolve_capturemrgsolve_compartmentmrgsolve_mainmrgsolve_matrixmrgsolve_odemrgsolve_parammrgsolve_tableOdeOdeRecordOmegaOmegaBlockOmegaBlocksParametersPatternPositionprocess_extra_argprocessExtraArgreadread.allparametersread.campsisread.modelread.parametersread.pmxmodread.varcovremove_na_columnreplacereplace_allreplaceAllreplicaterxode_coderxode_matrixrxode_paramsrxodeMatrixselectset_min_maxshift_omega_indexesSigmasortstandardiseThetato_stringtoStringtrimUnknownStatementupdate_compartmentsupdateCompartmentsVariablePatternwrite

Dependencies:assertthatbitbit64clicliprcpp11crayoncurldplyrfarvergenericsggplot2gluegtablehmsisobandjsonlitejsonvalidatelabelingLaplacesDemonlifecyclemagrittrMASSpillarpkgconfigprettyunitsprogresspurrrR6RColorBrewerRcppreadrrlangS7scalesstringistringrtibbletidyrtidyselecttzdbutf8V8vctrsviridisLitevroomwithr

Adapt your model
Prerequisite | Define the concentration | Define an error model | Simulate the observed concentration | A couple of useful functions in action

Last update: 2026-09-29
Started: 2021-10-04

Adapt your parameters
Prerequisite | Retrieve your parameters | Access parameter values | Replace parameters | Delete parameters

Last update: 2026-09-29
Started: 2021-10-04

Append a model to another
Prerequisite | Load your base PK model | Load an effect-compartment model | Append PD model to PK model | Simulate our PK/PD model

Last update: 2026-09-29
Started: 2021-10-04

Create a minimalist model
Prerequisite | Create a minimalist model in the Notepad++ editor | Create the same model programmatically

Last update: 2026-09-29
Started: 2021-10-04

Get started with Campsis model
Load example from model library | Write Campsis model | Read Campsis model | Export Campsis model to rxode2 | Export Campsis model to mrgsolve

Last update: 2026-09-29
Started: 2021-10-04

Insight on the structural model
Prerequisite | Equation | Ordinary differential equation (ODE) | Line break | Comment | If-statement | Additional remarks

Last update: 2026-09-29
Started: 2021-10-04

Play with compartment properties
Prerequisite | Create new compartment properties | Simulate our model | A couple of useful functions in action

Last update: 2026-09-29
Started: 2021-10-04

Readme and manuals

Help Manual

Help pageTopics
Add element to list.add add,campsis_model,campsis_model-method add,campsis_model,code_record-method add,campsis_model,compartment_property-method add,campsis_model,list-method add,campsis_model,model_statement-method add,campsis_model,parameter-method add,code_record,code_record-method add,code_record,model_statement-method add,code_records,code_records-method add,code_records,model_statement-method add,compartments,compartments-method add,compartments,compartment_property-method add,omega_block,double_array_parameter-method add,omega_blocks,omega_block-method add,omega_blocks,parameters-method add,parameters,double_array_parameter-method add,parameters,parameters-method add,parameters,single_array_parameter-method add,pmx_list,list-method add,pmx_list,pmx_element-method add,pmx_list,pmx_list-method
Add relative standard error (RSE) to the specified parameter.add_rse add_rse,campsis_model,parameter,numeric-method add_rse,parameters,parameter,numeric-method
Generic function to add a suffix to various objects like parameters, code records, compartment names or a model (all previous objects at the same time). This makes it an extremely powerful function to combine 2 models or more (using function 'add'), that have similar equation, parameter or compartment names.add_suffix add_suffix,campsis_model,character,character-method add_suffix,code_record,character,character-method add_suffix,code_records,character,character-method add_suffix,compartments,character,character-method add_suffix,parameters,character,character-method
As data frame method.as.data.frame as.data.frame,omega,character,logical-method as.data.frame,sigma,character,logical-method as.data.frame,theta,character,logical-method
Assert the given character vector is a single character string.assert_single_character_string
Auto-detect special variables from NONMEM as compartment properties. Bioavailabilities, infusion durations/rates and lag times will be automatically detected.auto_detect_nonmem auto_detect_nonmem,campsis_model-method
Auto replication settings class.auto_replication_settings-class
Create auto replication settings.AutoReplicationSettings
Create a bioavailability for the specified compartment.Bioavailability
Campsis model class.campsis_model-class
Create a new Campsis model.CampsisModel
Code record class. See this code record as an abstract class. 2 implementations are possible: - properties record (lag, duration, rate & bioavailability properties) - statements record (main, ode & error records)code_record-class
Create a list of code records.CodeRecords
Create a new comment.Comment
Comment class. A statement starting with #.comment-class
Create a compartment.Compartment
Compartment bioavailability class.compartment_bioavailability-class
Compartment infusion duration class.compartment_infusion_duration-class
Compartment infusion rate class.compartment_infusion_rate-class
Compartment initial condition class.compartment_initial_condition-class
Compartment lag time class.compartment_lag_time-class
Compartment properties class.compartment_properties-class
Compartment property class.compartment_property-class
Compartment class.compartment-class
Create a list of compartmentsCompartments
Compartments class.compartments-class
Get default element from list.default
Delete an element from this list.delete delete,campsis_model,code_record-method delete,campsis_model,compartment_property-method delete,campsis_model,model_statement-method delete,campsis_model,parameter-method delete,code_records,model_statement-method delete,compartments,compartment_property-method delete,parameters,double_array_parameter-method delete,parameters,single_array_parameter-method delete,pmx_list,integer-method delete,pmx_list,pmx_element-method delete,statements_record,integer-method delete,statements_record,model_statement-method
Disable.disable disable,campsis_model,character-method disable,parameters,character-method
Double-array parameter class. This parameter has 2 indexes. It can thus be used to define correlations between parameters.double_array_parameter-class
(Infusion)-duration record class.duration_record-class
Create a new equation.Equation
Equation class. Any statement in the form A = B.equation-class
Error record class.error_record-class
Create ERROR code record.ErrorRecord
Export function.export export,campsis_model,character-method export,campsis_model,mrgsolve_type-method export,campsis_model,rxode_type-method export,replicated_campsis_model,campsis_model-method
Export the given object to a JSON object, ready to be written to files.export_to_json export_to_json,campsis_model-method export_to_json,omega-method export_to_json,parameters-method export_to_json,sigma-method export_to_json,theta-method
Export type class.export_type-class
Extract left-hand-side expression.extract_lhs
Extract right-hand-side expression.extract_rhs
Extract text between brackets.extract_text_between_brackets
Bioavailability record class.f_record-class
Find an element in list.find find,campsis_model,code_record-method find,campsis_model,compartment-method find,campsis_model,compartment_property-method find,campsis_model,model_statement-method find,campsis_model,parameter-method find,code_records,model_statement-method find,compartments,compartment_property-method find,pmx_list,pmx_element-method find,statements_record,model_statement-method
Fix omega matrix for SAME OMEGA parameters that have NA values due to imperfections in Pharmpy import.fix_omega fix_omega,parameters-method
Get element by index.get_by_index get_by_index,compartment_properties,compartment_property-method get_by_index,parameters,parameter-method get_by_index,pmx_list,integer-method get_by_index,pmx_list,numeric-method
Get an element from a list by name. Never return more than 1 element.get_by_name get_by_name,pmx_list,character-method
Get Campsismod option logic.get_campsismod_option
Get the compartment index for the specified compartment name.get_compartment_index get_compartment_index,campsis_model,character-method get_compartment_index,compartments,character-method
Get element name.get_name get_name,ANY-method get_name,comment-method get_name,compartment-method get_name,compartment_bioavailability-method get_name,compartment_infusion_duration-method get_name,compartment_infusion_rate-method get_name,compartment_initial_condition-method get_name,compartment_lag_time-method get_name,duration_record-method get_name,equation-method get_name,error_record-method get_name,f_record-method get_name,if_statement-method get_name,init_record-method get_name,lag_record-method get_name,line_break-method get_name,main_record-method get_name,ode-method get_name,ode_record-method get_name,omega-method get_name,omega_block-method get_name,rate_record-method get_name,sigma-method get_name,theta-method get_name,unknown_statement-method
Get the name of the given parameter in the Campsis model.get_name_in_model get_name_in_model,omega-method get_name_in_model,sigma-method get_name_in_model,theta-method
Get element names from list.get_names get_names,pmx_list-method
Get NONMEM name.get_nonmem_name get_nonmem_name,omega-method get_nonmem_name,sigma-method get_nonmem_name,theta-method
Get the right block of OMEGA's.get_omega_block get_omega_block,omega_blocks,double_array_parameter-method
Get the indexes of the omegas.get_omega_indexes get_omega_indexes,omega_block-method
Get prefix.get_prefix get_prefix,compartment_bioavailability-method get_prefix,compartment_infusion_duration-method get_prefix,compartment_infusion_rate-method get_prefix,compartment_initial_condition-method get_prefix,compartment_lag_time-method
Get record delimiter.get_record_delimiter
Get record name.get_record_name get_record_name,compartment_bioavailability-method get_record_name,compartment_infusion_duration-method get_record_name,compartment_infusion_rate-method get_record_name,compartment_initial_condition-method get_record_name,compartment_lag_time-method
Get uncertainty on the parameters.get_uncertainty get_uncertainty,campsis_model-method get_uncertainty,parameter-method get_uncertainty,parameters-method
Get variance-covariance matrix.get_var_cov get_var_cov,campsis_model-method get_var_cov,parameters-method
Check if string contains Campsis-style comments.has_comment
Has exact method allows to check the existence of a S4 method in Campsis based on its signature.has_exact_method
Has off-diagonal omegas.has_off_diagonal_omegas has_off_diagonal_omegas,omega_block-method
If-statement class. Any statement in the form if (condition) A = B.if_statement-class
Create a new IF-statement.IfStatement
Get the index of an element in list.index_of index_of,pmx_list,pmx_element-method
Create an infusion duration.InfusionDuration
Create an infusion rate.InfusionRate
Init record class.init_record-class
Create an initial condition.InitialCondition
Check if string is a Campsis comment (i.e. not an equation).is_comment
Is diagonal.is_diag is_diag,double_array_parameter-method
Check if string is an empty line.is_empty_line
Say if line in record is an equation not.is_equation
Say if line in record is an IF-statement.is_if_statement
Is matrix positive definiteis_matrix_positive_definite
Say if line(s) in record is/are ODE or not.is_ode
Is record delimiter. A record delimiter is any line starting with [...].is_record_delimiter
Is strict record delimiter. A strict record delimiter is any line starting with [...] and followed by nothing but spaces or a possible comment.is_strict_record_delimiter
JSON element class.json_element-class
JSON to Campsis parameter.json_to_parameter
Instantiate a JSON element.JSONElement
Lag record class.lag_record-class
Create a lag time for the specified compartment.LagTime
Line-break class. A linebreak in the model.line_break-class
Create a new line break.LineBreak
Fill-in S4 object from the JSON content.load_from_json load_from_json,campsis_model,character-method load_from_json,campsis_model,json_element-method load_from_json,omega,json_element-method load_from_json,sigma,json_element-method load_from_json,theta,json_element-method
Main record class.main_record-class
Create MAIN code record.MainRecord
Manual replication settings class.manual_replication_settings-class
Create manual replication settings.ManualReplicationSettings
Map JSON properties to S4 slots.map_json_properties_to_s4_slots
Map S4 slots to JSON properties.map_s4_slots_to_json_properties
Max index.max_index max_index,parameters-method
Min index.min_index min_index,parameters-method
Model statement class. Any statement in a code record.model_statement-class
Model statements class. A list of statements.model_statements-class
Campsis model suite.model_suite
Create an empty list of model statements.ModelStatements
Move element 'x' from object to a certain place.move move,campsis_model,ANY,pmx_position-method move,code_records,code_record,pmx_position-method move,code_records,list,pmx_position-method move,code_records,model_statement,pmx_position-method move,code_records,model_statements,pmx_position-method
Convert code record for mrgsolve.mrgsolve_block
Get the CAPTURE block for mrgsolve.mrgsolve_capture
Get the compartment block for mrgsolve.mrgsolve_compartment
Get the MAIN block for mrgsolve.mrgsolve_main
Get the OMEGA/SIGMA matrix for mrgsolve.mrgsolve_matrix
Get the ODE block for mrgsolve.mrgsolve_ode
Get the parameters block for mrgsolve.mrgsolve_param
Get the TABLE block for mrgsolve.mrgsolve_table
Mrgsolve export type class.mrgsolve_type-class
Create a new ordinary differential equation (ODE).Ode
ODE record class.ode_record-class
ODE class. Any statement in the form d/dt(A_CMT) = B.ode-class
Create ODE code record.OdeRecord
Create an OMEGA parameter.Omega
Omega parameter class.omega-class
Create a block of OMEGA's.OmegaBlock
Create a list of OMEGA blocks.OmegaBlocks
Parameter class. Any parameter in a pharmacometric model.parameter-class
Create a list of parameters.Parameters
Parameters class.parameters-class
Parse IF-statement. Assumption: 'is_if_statement' method already called and returned TRUE.parse_if_statement
Parse statements code and return Campsis statements.parse_statements
Create a pattern.Pattern
Pattern class.pattern-class
PMX element class.pmx_element-class
PMX position by element class.pmx_position_by_element-class
PMX position by index class.pmx_position_by_index-class
PMX position class.pmx_position-class
Element position in list.Position
Process extra arguments.process_extra_arg
Properties record class.properties_record-class
(Infusion)-rate record class.rate_record-class
Generic read method to read data from a file or a folder.read
Read all parameters files at once.read.allparameters
Read a Campsis model.read.campsis
Read model file.read.model
Read parameters file.read.parameters
Read variance-covariance file.read.varcov
Replace element by another in list.replace replace,campsis_model,code_record-method replace,campsis_model,compartment-method replace,campsis_model,compartment_property-method replace,campsis_model,model_statement-method replace,campsis_model,parameter-method replace,code_records,model_statement-method replace,compartments,compartment_property-method replace,parameters,double_array_parameter-method replace,parameters,single_array_parameter-method replace,pmx_list,list-method replace,pmx_list,pmx_element-method replace,pmx_list,pmx_list-method replace,statements_record,model_statement-method
Replace all occurrences in object.replace_all replace_all,campsis_model,character,character-method replace_all,campsis_model,pattern,character-method replace_all,character,pattern,character-method replace_all,character,variable_pattern,character-method replace_all,code_record,pattern,character-method replace_all,code_records,pattern,character-method replace_all,compartment_property,pattern,character-method replace_all,equation,pattern,character-method replace_all,if_statement,pattern,character-method replace_all,model_statement,pattern,character-method replace_all,unknown_statement,pattern,character-method
Replicate generic object.replicate replicate,campsis_model,integer,auto_replication_settings-method replicate,campsis_model,integer,manual_replication_settings-method
Replicated Campsis model class.replicated_campsis_model-class
Replication settings interface.replication_settings-class
Get code for rxode2rxode_code
Get the OMEGA/SIGMA matrix for rxode2.rxode_matrix
Get the parameters vector for rxode2.rxode_params
RxODE/rxode2 export type class.rxode_type-class
Get a subset of an object.select select,compartment_properties-method select,data.frame-method select,parameters-method
Set the minimum and maximum value on a model parameter.set_min_max set_min_max,campsis_model,character,numeric,numeric-method set_min_max,campsis_model,parameter,numeric,numeric-method set_min_max,parameters,character,numeric,numeric-method set_min_max,parameters,parameter,numeric,numeric-method
Shift OMEGA indexes.shift_omega_indexes shift_omega_indexes,omega_block-method
Create a SIGMA parameter.Sigma
Sigma parameter class.sigma-class
Single-array parameter class. This parameter has a single index value.single_array_parameter-class
Sort the specified list.sort sort,campsis_model-method sort,code_records-method sort,compartments-method sort,compartment_properties-method sort,omega_blocks-method sort,parameters-method
Standardise.standardise standardise,campsis_model-method standardise,double_array_parameter-method standardise,parameters-method standardise,theta-method
Statements record class.statements_record-class
Create a THETA parameter.Theta
Theta parameter class.theta-class
to_string generic method.to_string to_string,comment-method to_string,compartment-method to_string,compartment_initial_condition-method to_string,compartment_property-method to_string,equation-method to_string,if_statement-method to_string,line_break-method to_string,mrgsolve_model-method to_string,ode-method to_string,unknown_statement-method
Trim character vector. Remove all leading and trailing spaces.trim
Unknown statement class. Any statement not recognized by campsismod.unknown_statement-class
Create a new ordinary differential equation (ODE).UnknownStatement
Update compartments list from the persisted records. Exported especially for package 'campsistrans'. However, this method should not be called.update_compartments
Variable pattern class.variable_pattern-class
Create a variable pattern.VariablePattern
Write generic object to files.write write,campsis_model,character-method write,code_records,character-method write,json_element,character-method write,parameters,character-method
Write subset of parameters (theta, omega or sigma).write_parameters
Write variance-covariance matrix.write_varcov