Skip to contents

[Stable]

This object is created after a successful run of the simulator.

Details

There are two methods of creating a PM_sim object.

  • PM_result$sim()

  • PM_sim$new()

These both call SIMrun to execute the simulation and SIMparse to process the results and return the PM_sim objects. See help on both of these functions for further details.

Public fields

obs

Observations for each output as a data frame with columns id, time, out, outeq, or in the case of multiple regimens in the template data file, a list of such data frames

amt

Amounts in each compartment as a data frame with columns id, time, out, comp, or in the case of multiple regimens in the template data file, a list of such data frames

parValues

Retained simulated parameter values after discarding any due to truncation limits, as a data frame with columns id and parameters for each simulated subject, or in the case of multiple regimens in the template data file, a list of such data frames

totalSets

Number of all simulated parameter values needed to obtain the requested number of simulated sets within any limits

totalMeans

Vector of means of all simulated parameter values, or in the case of multiple regimens in the template data file, a list of such vectors

totalCov

Covariance matrix for all simulated parameter values, or in the case of multiple regimens in the template data file, a list of such matrices

data

For one simulation regimen in the template data, a list of class PMsim that contains all the above elements. For multiple simulation regimens, a list of class PM_simlist that contains as many PMsim objects as regimens in the template data file used for the simulation, i.e data will be a list of lists.

Methods


Method new()

This is a wrapper function that combines SIMrun and SIMparse in R6. It can be called directly or via the $sim method for PM_result objects.

Usage

PM_sim$new(poppar, ...)

Arguments

poppar

One of four things:

  • Population prior parameters as a PM_final object found in PM_result$final. Normally these would be supplied by calling the $sim method for a PM_result object, e.g. PmetricsData::NPex$sim(...).

  • A manually specified prior, see SIMrun for more details.

  • The name of a previously saved simulation via the $save method. The file will be loaded.

  • The results of running SIMparse on a prior simulation.

...

Additional parameters to be passed to SIMrun and optionally, combine = TRUE as an argument will be passed to SIMparse.

Returns

A PM_sim object created by calling SIMparse at the completion of the simulation.


Method save()

Save the current PM_sim object into a .rds file.

Usage

PM_sim$save(file_name = "PMsim.rds")

Arguments

file_name

Name of the file to be created, the default is PMsim.rds


Method plot()

Plot PM_sim object.

Usage

PM_sim$plot(at = 1, ...)

Arguments

at

Index of the PM_sim object to be plotted. Default is 1. result.

...

Arguments passed to plot.PM_sim.


Method pta()

Estimates the Probability of Target Attaintment (PTA), based on the results of the current Simulation.

Usage

PM_sim$pta(...)

Arguments

...

Additional parameters, refer to makePTA


Method auc()

Calculates the AUC of the specified simulation

Usage

PM_sim$auc(at = 1, ...)

Arguments

at

Index of the PM_sim object to use. Default is 1.

...

Arguments passed to makeAUC.


Method summary()

Summarize simulation

Usage

PM_sim$summary(at = 1, field, by, individual = FALSE)

Arguments

at

Index of the PM_sim object to be summarized. Default is 1.

field

Quoted character value, one of

  • obs for simulated observations

  • amt for simulated amounts in each compartment

  • parValues for simulated parameter values

by

Optional quoted column name(s) to group by, e.g. by = "id" or by = c("id", "outeq").

individual

If "id" is included within by, the summary statistics will be calculated for each individual, i.e. each individual's mean, sd, median, min and max observations. If individual is FALSE (the default), then those summaries will again be summarized to present, for example, the mean of all subjects' mean observations, or the mean of their maximum observations. This argument will be ignored if "id" is not in by.

Returns

If by is ommitted, a data frame with rows for each data element except ID, and columns labeled as mean, sd, median, min and max. If by is specified, return will be a list with named elements mean, sd, median, min and max, each containing the corresponding value for each group in by.


Method run()

[Deprecated]

Deprecated method to run a simulation. Replaced by PM_sim$new() to be consistent with R6.

Usage

PM_sim$run(...)

Arguments

...

Not used.


Method load()

[Deprecated]

Deprecated method to load a prior simulation. Replaced by PM_sim$new() to be consistent with R6.

Usage

PM_sim$load(...)

Arguments

...

Not used.


Method clone()

The objects of this class are cloneable with this method.

Usage

PM_sim$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.