Inference

In Pumas, inference is performed after model fitting to obtain uncertainty estimates on the model's population-level parameters (fixed effects), which can then be used to derive standard errors and confidence intervals. This is accomplished by calling the infer function on the object returned by fit:

Pumas.infer — Function
infer(fpm; kwargs...)

Estimate the variance-covariance matrix and return a struct used for inference based on the fitted model fpm.

Keyword Arguments

  • level::Real (default: 0.95): the confidence level of the confidence intervals. The confidence intervals are calculated as the (1-level)/2 and (1+level)/2 quantiles of the estimated parameters.
  • sandwich_estimator::Bool (default: true): whether to use the sandwich estimator of the variance-covariance matrix.
  • rethrow_error::Bool (default: false): whether an error is thrown if the estimation of the variance-covariance matrix fails, or the exception is stored without throwing it.
  • ensemblealg (default: ensemblealg that was used during model fitting): the mode of parallelization. Possible options are: EnsembleSerial(), EnsembleThreads(), EnsembleDistributed() and EnsembleSplitThreads().

See also vcov.

infer(fpm, bts::Pumas.Bootstrap; level=0.95)

Perform bootstrapping by resampling the Subjects from the Population stored in fpm. The confidence intervals are calculated as the (1-level)/2 and (1+level)/2 quantiles of the estimated parameters. The number of samples used in the bootstrapping is bts.samples. bts.ensemblealg specifies the ensemblealg used here. If ensemblealg is EnsembleSerial(), a single thread will be used. If it is EnsembleThreads() (the default value), multiple threads will be used. If it is set to EnsembleDistributed() each fit will be sent to a worker in the worker pool. See the documentation of Bootstrap for more details on constructing an instance of Bootstrap.

infer(fpm, alg::MarginalMCMC; kwargs...)

Infer the uncertainty of the parameters of the fitted model fpm by sampling from the marginal likelihood with the Markov Chain Monte Carlo (MCMC) algorithm alg.

Keyword Arguments

  • level::Real (default: 0.95): the confidence level of the confidence intervals. The confidence intervals are calculated as the (1-level)/2 and (1+level)/2 quantiles of the sampled parameters.
infer(fpm, sir::SIR; proposal_covariance, level = 0.95, ensemblealg = EnsembleThreads()) -> FittedPumasModelInference

Perform sampling importance re-sampling (SIR) for the Subjects from the Population stored in the fitted Pumas model fpm, with the covariance matrix proposal_covariance of the initial proposal distribution. See SIR for the settings of the SIR procedure.

Rows and columns of proposal_covariance must be labelled with the names of the estimated parameters of fpm such that the covariance matrix is unambiguous, regardless of how the parameters are vectorized internally. Since proposal_covariance is supplied explicitly, the SIR procedure can be performed even if the computation of the variance-covariance matrix of fpm fails or yields a matrix that is not positive definite.

The confidence intervals are calculated as the (1-level)/2 and (1+level)/2 quantiles of the estimated parameters.

Keyword Arguments

  • proposal_covariance: the covariance matrix of the initial proposal distribution, in the space of the parameter estimates. The initial proposal distribution is used in the space of that matrix, i.e., neither the proposal_scale nor the proposal_shape of sir applies to it (see SIR). It must be a DimensionalData.DimArray that is symmetric and positive definite over the free parameters, and its rows and columns must be labelled with the names of the estimated parameters. The names of the estimated parameters are the parameter entries of the rows of coeftable(fpm) for which constant is false: Constant parameters are not estimated and must be omitted.
  • level::Real (default: 0.95): the confidence level of the confidence intervals.
  • ensemblealg (default: EnsembleThreads()): the mode of parallelization. Possible options are EnsembleThreads() to use multi-threading and EnsembleSerial() to use a single thread.

Examples

Assume fpm is the output of fit and Σ is a covariance matrix of the estimated parameters.

using DimensionalData

sir = SIR(; samples = 1000, resamples = 200)

# Names of the estimated parameters, e.g., `["tvcl", "tvvc", "Ω₁,₁", "Ω₂,₁", "Ω₂,₂", "σ"]`
ct = coeftable(fpm)
labels = ct.parameter[.!ct.constant]

infer(fpm, sir; proposal_covariance = DimArray(Σ, (X(labels), Y(labels))))

See also SIR, infer, coeftable, vcov.

infer(pmi::FittedPumasModelInference, sir::SIR; level = pmi.level, ensemblealg = EnsembleThreads()) -> FittedPumasModelInference

Perform sampling importance re-sampling (SIR) for the Subjects from the Population stored in the fitted Pumas model of the inference results pmi. See SIR for the settings of the SIR procedure.

The covariance matrix of the initial proposal distribution of the SIR procedure is derived from pmi: It is the variance-covariance matrix if pmi was computed with infer(fpm; ...), and the covariance matrix of the parameter samples if pmi was computed with Bootstrap, SIR, or MarginalMCMC. Hence the SIR procedure can be performed even if the computation of the robust variance-covariance matrix of the fitted Pumas model fails or yields a matrix that is not positive definite. In the latter case the initial proposal distribution is fitted to the parameter samples in the space that the proposal_scale and proposal_shape of sir select, whereas a variance-covariance matrix is used in its own space (see SIR).

The confidence intervals are calculated as the (1-level)/2 and (1+level)/2 quantiles of the estimated parameters.

Keyword Arguments

  • level::Real (default: pmi.level): the confidence level of the confidence intervals.
  • ensemblealg (default: EnsembleThreads()): the mode of parallelization. Possible options are EnsembleThreads() to use multi-threading and EnsembleSerial() to use a single thread. It is only used for the SIR procedure, hence the variance-covariance matrix of pmi can be computed with an ensemble algorithm that the SIR procedure does not support, e.g., infer(infer(fpm; ensemblealg = EnsembleDistributed()), sir).

Examples

Assume fpm is the output of fit.

sir = SIR(; samples = 1000, resamples = 200)

# Initial proposal based on the robust variance-covariance matrix of the fitted Pumas model
infer(infer(fpm), sir)

# Initial proposal based on the negative inverse Hessian
infer(infer(fpm; sandwich_estimator = false), sir)

# Initial proposal based on the covariance matrix of bootstrap estimates
infer(infer(fpm, Bootstrap(; samples = 200)), sir)

# Initial proposal based on the covariance matrix of marginal MCMC samples
infer(infer(fpm, MarginalMCMC(; approx = FOCE())), sir)

# Initial proposal based on the covariance matrix of the samples of a previous SIR procedure
infer(infer(fpm, sir), sir)

See also SIR, Bootstrap, MarginalMCMC, vcov.

The function can be specialized to behave differently by setting the second (optional) argument type to different values. Details of each specialization are given below.

The infer function accepts the following arguments:

  • fpm: a fitted Pumas model, typically returned by fit.
  • type: the second (optional) argument determines the inferential approach used. Details are given below.
  • level: for confidence intervals, the confidence level to use. Typically, 0.95, corresponding to 95% confidence intervals.
  • ...: further arguments, the meaning of which is dependent on the type of inference. Details are given below.

The function returns an object of type FittedPumasModelInference. Further functions can be called on this object, such as stderror to obtain the standard errors.

We now describe in more detail the different inferential approaches that can be used by specifying the type argument. The default is to use the asymptotic variance-covariance matrix obtained from the "robust" (also called "sandwich") estimator [14]. Other options include:

Inference from asymptotic variance-covariance matrices

This inferential approach is the default when no type is specified in infer:

infer(fpm)

The additional optional arguments are:

  • rethrow_error: whether to throw an error when it is not possible to compute the variance-covariance matrix (e.g., because the observed information matrix is not numerically positive definite). The default is to return a failed FittedPumasModelInference object but not throw an error.

  • sandwich_estimator: whether to use the "robust" variance-covariance estimator [14]. true to default. If false, then the inverse of the observed Fisher information (i.e., negative inverse Hessian of the log-likelihood) is used.

Note that the variance-covariance matrix can also be obtained directly by calling the vcov function directly on a fitted Pumas model (returned by fit).

Both estimators are computed from the objective function that the model was fitted with. A prior declared in the @param block therefore only contributes to them if the objective contains it, which is the case for a MAP fit and not for one with FO, FOCE, LaplaceI or NaivePooled.

Here is an example of obtaining confidence intervals by setting sandwich_estimator to false in order to not use the robust estimator:

my_infer = infer(fpm; sandwich_estimator = false)

The FittedPumasModelInference returned by infer has a show method that prints the estimates, standard errors and confidence intervals in the REPL. To extract this information in a DataFrame (e.g. for markdown reporting), the coeftable function can be used:

StatsAPI.coeftable — Function
coeftable(fpm::FittedPumasModel) -> DataFrame

Construct a DataFrame of parameter names, descriptions, and estimates from fpm. The description of each parameter comes from the model's @metadata block, and falls back to the parameter name when the model gives none.

coeftable(vfpm::Vector{<:FittedPumasModel}) -> DataFrame

Construct a DataFrame of parameter names, descriptions, and estimates and their standard deviation from vector of fitted single-subject models vfpm. The description of each parameter comes from the model's @metadata block, and falls back to the parameter name when the model gives none.

coeftable(pmi::FittedPumasModelInference; level = pmi.level) -> DataFrame

Construct a DataFrame of parameter names, descriptions, estimates, standard error, and confidence interval with confidence level level. The default value of level is the one that was passed in infer. The description of each parameter comes from the model's @metadata block, and falls back to the parameter name when the model gives none.

coeftable(fit::DissolutionFit) -> DataFrame

One row per formulation: formulation, then one column per parameter of the fitted model in field order (finf, mdt, b, int, tlag for a Weibull). The parameters in fit.constant were held fixed.

The returned DataFrame also has relative standard errors (RSEs) included, and a description column carrying the docstring of each parameter, as described in @metadata and Descriptions, falling back to the parameter name where none was given.

Additionally, you can also use the correlation_diagnostic to print a list of parameter pairs with high, medium or low correlations:

Pumas.correlation_diagnostic — Function
correlation_diagnostic(
  pmi::FittedPumasModelInference;
  high_cor_threshold::Real = 0.7,
  medium_cor_threshold::Real = high_cor_threshold / 2,
)

Extract lists of parameter pairs with high, medium or low correlations from an inference result output by infer.

Parameter pairs with high correlation are those with an absolute correlation higher than high_cor_threshold. Parameter pairs with a low correlation are those with an absolute correlation lower than medium_cor_threshold. The remaining parameter pairs have a medium correlation.

Example

Assume fpm is the output of fit. The following is an example of how to use correlation_diagnostic:

fpmi = infer(fpm)
correlation_diagnostic(fpmi)

Inference using the robust variance-covariance estimator is consistent under heteroscedasticity of residuals, but relies on asymptotic normality of the maximum likelihood estimator. While this is often a reasonable approximation for the parameters associated with the mean of the response variable, it is often a poor approximation for the variance parameters. Furthermore, confidence intervals derived using this approach do not necessarily respects bounds on the parameters, and it is not unlikely for a parameter that by definition is strictly positive (such as a clearance, volume or variance) to have an associated confidence interval that contains negative values. For that reason, inference based on other approaches, such as Bootstrap and SIR, may be preferable in some situations.

Bootstrap-based inference

Bootstrap-based inference is obtained by calling the function Bootstrap and passing the returned object of type Bootstrap as the type argument of infer. The resulting function signature is:

infer(fpm, Bootstrap())

There are no additional keyword arguments to the infer function, but Bootstrap has a number of optional arguments that can be used to control the bootstrap procedure. It has the following signature:

Pumas.Bootstrap — Type
Bootstrap(;
    rng::Random.AbstractRNG = Random.default_rng(),
    samples::Integer = 200,
    stratify_by::Union{Nothing,Vector{Symbol}} = nothing,
    ensemblealg::SciMLBase.EnsembleAlgorithm = EnsembleThreads(),
)

Construct a Bootstrap object that can be supplied to infer to perform bootstrap-based inference with the provided settings.

See ?infer and the Inference documentation for more information about obtaining inference results.

Arguments

  • rng: Pseudo-random number generator used for resampling the population.
  • samples: Number of resampled populations.
  • stratify_by: Vector of names of covariate(s) used for stratification in the resampling scheme. By default (stratify_by = nothing), no stratification is applied. The vector must contain at least one covariate; pass nothing to disable stratification.
  • ensemblealg: Mode of parallelization across fit calls of the resampled populations. Possible options are: EnsembleSerial(), EnsembleThreads() and EnsembleDistributed(). Note that each resampled population is fit using the same mode of parallelization as the fit of the original population.

The type of bootstrap procedure used is nonparametric bootstrap, also called paired bootstrap [15]. Bootstrap datasets are obtained by resampling individuals from the original dataset with replacement (all records associated with the sampled individual are included), after stratifying by any covariates specified. The stratification ensures that the number of individuals in each stratum remains the same in each resampled dataset, which can help with the stability of the estimator. For example, if an analysis consists of two studies, a small study with rich sampling, and a large study with sparse sampling, stratifying on the study will ensure that each resampled dataset has the same number of subjects with rich sampling. The fitting algorithm is applied to each resampled dataset to obtain $N$ estimates for each parameter, where $N$ is the number of replicates specified in samples. This collection is treated as a random draw from the sampling distribution of the estimator for the parameters, and a nonparametric 95% confidence interval is obtained from the 2.5th and 97.5th quantiles of this sample.

Inference based on the nonparametric bootstrap approach is often considered more reliable than using the asymptotic variance-covariance matrix, but is computationally intensive. Unlike the latter approach, bounds on the parameters are respected (e.g. the confidence interval for a strictly positive parameter cannot contain negative values).

Here's an example with all options specified:

using Random

my_bootstrap = infer(
    fpm,
    Bootstrap(;
        rn = MersenneTwister(1234),
        sample = 500,
        stratify_by = [:sex, :trt],
        ensemblealg = EnsembleThreads(),
    ),
)

If any of the sample fits requires closer inspection or post-processing, it is possible to get a filtered vector of only the successful fits with the successful_fits function. The included fits are those that did not error. In this case, the appropriate function call would be successful_fits(my_bootstrap). Notice, that for the inference based on the bootstrap procedure to be valid, most fits should have been successful in the sense that an error was not thrown. If several of the fits failed it is important to try to get a better understanding of why that happened before using the results. The coeftable function will work on the returned object, and the confidence interval, relative standard errors, and standard errors will be bootstrap-based.

The bootstrap requires a FittedPumasModel; FittedPumasEMModel support is coming in a future version of Pumas.

Sampling importance resampling (SIR)

As an alternative to the nonparametric bootstrap procedures (which can be computationally intensive or unfeasible with small sample sizes), [16] suggests the sampling importance resampling (SIR) procedure for estimating the uncertainty. This can be obtained by calling the function SIR and passing the returned object of type SIR as the type argument (second optional positional argument) of infer:

Pumas.SIR — Type
SIR(;
    rng::Random.AbstractRNG = Random.default_rng(),
    samples::Union{Int,Vector{Int}},
    resamples::Union{Int,Vector{Int}},
    proposal_scale::Union{NaturalScale,UnconstrainedScale} = UnconstrainedScale(),
    proposal_shape::Union{Nothing,YeoJohnson} = nothing,
)

Construct an SIR object that can be used in infer function calls to perform sampling importance re-sampling (SIR) with the supplied settings. See ?infer and the Inference documentation for more information about obtaining inference results.

Confidence intervals based on SIR respect bounds on the parameters (e.g., the confidence interval for a strictly positive parameter cannot contain negative values).

In each iteration, parameter samples are drawn from a multivariate normal proposal distribution whose mean is set to the parameter estimates of the fitted Pumas model. In the initial iteration, the covariance matrix of the proposal distribution is either supplied by the user or derived from the inference results that the SIR procedure is based on: It is the variance-covariance matrix if the SIR procedure is based on the results of an infer call, and the covariance matrix of the parameter samples if it is based on the results of a Bootstrap, SIR, or MarginalMCMC inference (see infer). In subsequent iterations, the covariance matrix of the proposal distribution is set to the empirical covariance matrix of the parameter samples resampled in the previous iteration. In each iteration, parameter samples are resampled by weighted sampling without replacement.

The proposal_scale and proposal_shape keyword arguments select the space in which a proposal distribution is fitted to parameter samples. They apply to the proposal distributions of the second and all subsequent iterations, and to the one of the initial iteration if the SIR procedure is based on the parameter samples of a Bootstrap, SIR, or MarginalMCMC inference. A proposal distribution that is built from a covariance matrix is used in the space of that matrix, and neither keyword argument affects it.

Keyword Arguments

  • rng: the pseudo-random number generator used within the SIR procedure.

  • samples: the number(s) of parameter samples simulated from the proposal distribution in each iteration.

  • resamples: the number(s) of parameter samples to resample in each iteration. In each iteration, the number of resampled parameter samples must not be greater than the number of originally sampled parameters. In every iteration but the final one, it must be greater than the number of estimated parameters as well since otherwise the covariance matrix of the proposal distribution of the next iteration is singular.

  • proposal_scale: the scale of the parameters that a proposal distribution is fitted on. Supported values:

    • UnconstrainedScale() (default): the unconstrained parameterization that Pumas uses internally. Every sample corresponds to a valid parameter value, and hence no sample is rejected.
    • NaturalScale(): the parameters in their original domain, which is also the scale that covariance matrices are expressed on. Samples that violate the domain constraints of the parameters are rejected.
  • proposal_shape: how the marginals of the parameter samples are reshaped before a proposal distribution is fitted to them. Supported values:

    • nothing (default): not at all.
    • YeoJohnson(): with a Yeo-Johnson transformation, one parameter per marginal, estimated from the samples. Samples outside of the image of the transformation are rejected.

Both samples and resamples must be supplied since there are no default values for these keyword arguments.

Note

If the SIR procedure is based on the results of an infer call, the initial proposal distribution is based on the robust variance-covariance matrix and will therefore fail whenever the computation of the robust variance-covariance matrix fails. The SIR procedure can be based on the results of an infer call with sandwich_estimator = false, or of a Bootstrap or MarginalMCMC inference, instead (see infer). Alternatively, the covariance matrix of the initial proposal distribution can be supplied explicitly with the proposal_covariance keyword argument of infer (see infer). The same alternatives are available if the robust variance-covariance matrix is not positive definite.

Confidence intervals based on SIR respect bounds on the parameters (e.g. the confidence interval for a strictly positive parameter cannot contain negative values), since they are quantiles of resampled parameter values and every such value lies in the domain of its parameter.

Here is an example of using how to use SIR in Pumas:

my_inference = infer(fpm)
my_sir = infer(my_inference, SIR(; samples = 300, resamples = 100))

The first infer call computes the variance-covariance matrix that the initial proposal distribution is based on. Passing the fitted model directly, as infer(fpm, SIR(...)), is deprecated.

The SIR procedure can equally be based on the parameter samples of a Bootstrap, SIR or MarginalMCMC inference, in which case their empirical covariance matrix is used. That is an alternative whenever the robust variance-covariance matrix cannot be computed or is not positive definite, as is supplying the covariance matrix of the initial proposal distribution directly with the proposal_covariance keyword argument of infer.

The space the proposal distribution is fitted on

Whenever a proposal distribution is fitted to parameter samples instead of being built from a covariance matrix, two keyword arguments of SIR select the space it is fitted on.

proposal_scale selects the scale of the parameters. The default, UnconstrainedScale(), is the unconstrained parameterization that Pumas uses internally. Every draw from the proposal distribution corresponds to a valid parameter value, so no draw is ever rejected. The alternative, NaturalScale(), is the original domain of the parameters, which is also the scale that covariance matrices are expressed on. On that scale a draw can violate the bounds of a parameter, and such draws are rejected.

proposal_shape selects whether the marginals of the parameter samples are reshaped before the proposal distribution is fitted to them. The default, nothing, leaves them as they are. YeoJohnson() applies a Yeo-Johnson transformation with one parameter per marginal, estimated from the samples themselves, and rejects the draws that fall outside the image of the transformation. The proposal distribution is Gaussian on the space it is fitted on, and the unconstrained scale already removes much of the skewness that the bounds of a parameter induce, for instance by taking the logarithm of a strictly positive parameter. Reshaping the marginals addresses the skewness that is left on the selected scale.

Both keyword arguments apply to the proposal distributions of the second and all subsequent iterations. They apply to the one of the initial iteration only if the SIR procedure is based on the parameter samples of a Bootstrap, SIR or MarginalMCMC inference. A proposal distribution that is built from a covariance matrix is used in the space of that matrix, and neither keyword argument affects it. That covers the initial iteration of a procedure based on an infer call, as well as a covariance matrix supplied through proposal_covariance. Neither keyword argument therefore has any effect on a single-iteration SIR procedure such as the one in the example above.

The coeftable function will work on the returned object, and the confidence interval, relative standard errors, and standard errors will be based on SIR.

Inference based on samples from the marginal likelihood using MarginalMCMC

Instead of using the SIR sampling scheme it is possible to use MarginalMCMC as a way to generate an inference output. It uses a marginal Hamiltonian Monte Carlo (HMC) based No-U-Turn Sampler (NUTS) algorithm where the subject-specific parameters are marginalized and only the population parameters are sampled. The generated chain is the same as would have been generated from

alg = MarginalMCMC(; approx = LaplaceI())
(; model, data, kwargs) = fpm
param = coef(fpm)
result = fit(model, data, param, alg; kwargs.constantcoef)

The approx keyword argument selects the method used to marginalize the subject-specific parameters. Constructing a MarginalMCMC without it is deprecated: it warns and falls back to LaplaceI.

but it is set up in a way where it can be used with the usual inference oriented functions such as vcov and stderror.

Pumas.MarginalMCMC — Type
MarginalMCMC

An instance of the marginal Hamiltonian Monte Carlo (HMC) based No-U-Turn Sampler (NUTS) algorithm where the subject-specific parameters are marginalized and only the population parameters are sampled. All the options of the algorithm can be passed to the constructor of MarginalMCMC as keyword arguments. Example:

alg = MarginalMCMC(; approx = LaplaceI(), nsamples = 2000, nadapts = 1000)

The main options that can be set are:

  • approx: The likelihood-approximation algorithm used to marginalize out the subject-specific parameters. It can be set to FO(), FOCE(), or LaplaceI(), for example.
  • target_accept (default: 0.8): Target acceptance ratio for the NUTS algorithm.
  • nsamples (default: 2000): Number of Markov Chain Monte Carlo (MCMC) samples to generate, including adaptation samples.
  • nadapts (default: nsamples ÷ 2): Number of adaptation steps in the NUTS algorithm.
  • nchains (default: 4): Number of MCMC chains to sample.
  • ess_per_chain (default: ∞): Target effective sample size (ESS) per chain. Sampling terminates if the target is reached.
  • check_every (default: max(2, ess_per_chain ÷ 5)): Number of samples after which the ESS per chain is checked; only relevant when ess_per_chain is finite.
  • time_limit (default: ∞): Time limit for sampling in seconds. Sampling terminates if the time limit is reached.

To customize the differential equation solver, the parallelism, the random number generator, or to fix some parameters during sampling, use the diffeq_options, ensemblealg, parallel_chains, parallel_subjects, rng, and constantcoef keyword arguments of fit.

Here is an example of using how to use SIR in Pumas:

my_marginalmcmc = infer(my_fit, MarginalMCMC(; approx = LaplaceI()))

The coeftable function will work on the returned object, and the confidence interval, relative standard errors, and standard errors will be based on the MarginalMCMC with a burn-in period.

MarginalMCMC requires a FittedPumasModel, FittedPumasEMModel support is coming in a future version of Pumas.

Calculating mean values and variance-covariance matrices from Bootstrap and SIR

With the output from an infer call using Bootstrap or SIR in hand, it is possible to get mean values of the sampled parameters and a variance-covariance matrix based on the same. If the output of the infer call was named infer_output, these quantities are simply produced using the following code:

mean(infer_output)
vcov(infer_output)

Getting the samples themselves (samples_table)

The summaries above are computed from the individual parameter samples that Bootstrap, SIR and MarginalMCMC produce. Those samples can be obtained directly with samples_table, which returns them as a DataFrame with one row per sample and one column per parameter, alongside a few columns describing the sample itself, such as its loglikelihood:

samples_table(infer_output)

This is useful for plotting the sampling distribution of a parameter, or for any other summary than the mean and variance-covariance matrix.

Pumas.samples_table — Function
samples_table(infer_result) -> DataFrame

Return a DataFrame of parameter samples from a non-asymptotic inference result returned by infer, with one row per sample and one column per parameter. Supported for Bootstrap, SIR, and MarginalMCMC results.

For Bootstrap results, an additional loglikelihood column reports the log-likelihood of the bootstrapped parameter estimates.

For SIR results, the returned data frame contains the SIR proposal samples across all iterations. Columns iteration and resampled specify the iteration number of each proposal sample and whether the proposal sample was resampled. The additional loglikelihood column reports the log-likelihood of the samples.

Extracting standard errors (stderror)

The stderror function is used to extract standard errors from either a FittedPumasModel object returned by fit or a FittedPumasModelInference object returned by infer:

StatsAPI.stderror — Function
stderror(f::AbstractFittedPumasModel) -> NamedTuple

Compute the standard errors of the population parameters and return the result as a NamedTuple matching the NamedTuple of population parameters.

When calling stderror on a infer object, the type of standard errors returned will depend on the options passed to infer. For instance, if nonparametric bootstrap inference was performed, then the standard errors will be bootstrap-based.

Calling stderror directly on a fitted Pumas model object will result in using the default arguments to infer, i.e. standard errors based on the robust variance-covariance matrix. They can be inefficient because it may result in the variance-covariance matrix being re-calculated unnecessarily it is therefore recommended to not call stderror directly on a fitted Pumas model object, but to call infer first and store the object, which is then passed to stderror.

Condition number

Many pharmacometricians use the condition number to gauge if a model is stable or not. While we do not necessarily recommend the condition number as a good measurement of this the number is available by calling the cond function with the inference output as input. This will calculate the condition number of the correlation matrix implied by the variance-covariance matrix. This can be changed to the condition number of the variance-covariance matrix by setting the keyword correlation to false.

LinearAlgebra.cond — Function
cond(pmi::FittedPumasModelInference; correlation = true)

Return the condition number of the correlation matrix (or variance-covariance matrix with correlation = false) of the free parameters stored in pmi. Throws an error if pmi is the result of a call to infer with Pumas.Bootstrap or if the variance-covariance calculation failed.