Main Content

Model the Population Pharmacokinetics of Phenobarbital in Neonates

This example shows how to build a simple nonlinear mixed-effects model from clinical pharmacokinetic data.

Data were collected on 59 pre-term infants given phenobarbital for prevention of seizures during the first 16 days after birth. Each individual received an initial dose followed by one or more sustaining doses by intravenous bolus administration. A total of between 1 and 6 concentration measurements were obtained from each individual at times other than dose times, as part of routine monitoring, for a total of 155 measurements. Infant weights and APGAR scores (a measure of newborn health) were also recorded.

This example uses data described in [1], a study funded by NIH/NIBIB grant P41-EB01975.

This example requires Statistics and Machine Learning Toolbox™.

Load the Data

These data were downloaded from the website http://depts.washington.edu/rfpk/ (no longer active) of the Resource Facility for Population Pharmacokinetics as a text file, and saved as a dataset array for ease of use.

load pheno.mat ds

Visualize the Data in a Trellis Plot

t = sbiotrellis(ds, 'ID', 'TIME', 'CONC', 'marker', 'o',...
       'markerfacecolor', [.7 .7 .7], 'markeredgecolor', 'r', ...
       'linestyle', 'none');

% Format the plot.
t.plottitle = 'States versus Time';
t.hFig.Color = [1 1 1];

Figure contains 64 axes objects. axes object 1 with title ID 1 contains a line object which displays its values using only markers. axes object 2 with title ID 2 contains a line object which displays its values using only markers. axes object 3 with title ID 3 contains a line object which displays its values using only markers. axes object 4 with title ID 4 contains a line object which displays its values using only markers. axes object 5 with title ID 5 contains a line object which displays its values using only markers. axes object 6 with title ID 6 contains a line object which displays its values using only markers. axes object 7 with title ID 7 contains a line object which displays its values using only markers. axes object 8 with title ID 8 contains a line object which displays its values using only markers. axes object 9 with title ID 9 contains a line object which displays its values using only markers. axes object 10 with title ID 10 contains a line object which displays its values using only markers. axes object 11 with title ID 11 contains a line object which displays its values using only markers. axes object 12 with title ID 12 contains a line object which displays its values using only markers. axes object 13 with title ID 13 contains a line object which displays its values using only markers. axes object 14 with title ID 14 contains a line object which displays its values using only markers. axes object 15 with title ID 15 contains a line object which displays its values using only markers. axes object 16 with title ID 16 contains a line object which displays its values using only markers. axes object 17 with title ID 17 contains a line object which displays its values using only markers. axes object 18 with title ID 18 contains a line object which displays its values using only markers. axes object 19 with title ID 19 contains a line object which displays its values using only markers. axes object 20 with title ID 20 contains a line object which displays its values using only markers. axes object 21 with title ID 21 contains a line object which displays its values using only markers. axes object 22 with title ID 22 contains a line object which displays its values using only markers. axes object 23 with title ID 23 contains a line object which displays its values using only markers. axes object 24 with title ID 24 contains a line object which displays its values using only markers. axes object 25 with title ID 25 contains a line object which displays its values using only markers. axes object 26 with title ID 26 contains a line object which displays its values using only markers. axes object 27 with title ID 27 contains a line object which displays its values using only markers. axes object 28 with title ID 28 contains a line object which displays its values using only markers. axes object 29 with title ID 29 contains a line object which displays its values using only markers. axes object 30 with title ID 30 contains a line object which displays its values using only markers. axes object 31 with title ID 31 contains a line object which displays its values using only markers. axes object 32 with title ID 32 contains a line object which displays its values using only markers. axes object 33 with title ID 33 contains a line object which displays its values using only markers. axes object 34 with title ID 34 contains a line object which displays its values using only markers. axes object 35 with title ID 35 contains a line object which displays its values using only markers. axes object 36 with title ID 36 contains a line object which displays its values using only markers. axes object 37 with title ID 37 contains a line object which displays its values using only markers. axes object 38 with title ID 38 contains a line object which displays its values using only markers. axes object 39 with title ID 39 contains a line object which displays its values using only markers. axes object 40 with title ID 40 contains a line object which displays its values using only markers. axes object 41 with title ID 41 contains a line object which displays its values using only markers. axes object 42 with title ID 42 contains a line object which displays its values using only markers. axes object 43 with title ID 43 contains a line object which displays its values using only markers. axes object 44 with title ID 44 contains a line object which displays its values using only markers. axes object 45 with title ID 45 contains a line object which displays its values using only markers. axes object 46 with title ID 46 contains a line object which displays its values using only markers. axes object 47 with title ID 47 contains a line object which displays its values using only markers. axes object 48 with title ID 48 contains a line object which displays its values using only markers. axes object 49 with title ID 49 contains a line object which displays its values using only markers. axes object 50 with title ID 50 contains a line object which displays its values using only markers. axes object 51 with title ID 51 contains a line object which displays its values using only markers. axes object 52 with title ID 52 contains a line object which displays its values using only markers. axes object 53 with title ID 53 contains a line object which displays its values using only markers. axes object 54 with title ID 54 contains a line object which displays its values using only markers. axes object 55 with title ID 55 contains a line object which displays its values using only markers. axes object 56 with title ID 56 contains a line object which displays its values using only markers. axes object 57 with title ID 57 contains a line object which displays its values using only markers. axes object 58 with title ID 58 contains a line object which displays its values using only markers. axes object 59 with title ID 59 contains a line object which displays its values using only markers. This object represents CONC. Axes object 60 is empty. Axes object 61 is empty. Axes object 62 is empty. Axes object 63 is empty. Axes object 64 is empty.

Describe the Data

In order to perform nonlinear mixed-effects modeling on this dataset, we need to convert the data to a groupedData object, a container for holding tabular data that is divided into groups. The groupedData constructor automatically identifies commonly use variable names as the grouping variable or the independent (time) variable. Display the properties of the data and confirm that GroupVariableName and IndependentVariableName are correctly identified as 'ID' and 'TIME', respectively.

data = groupedData(ds);
data.Properties
ans = struct with fields:
                Description: ''
                   UserData: []
             DimensionNames: {'Observations'  'Variables'}
              VariableNames: {'ID'  'TIME'  'DOSE'  'WEIGHT'  'APGAR'  'CONC'}
       VariableDescriptions: {}
              VariableUnits: {}
         VariableContinuity: []
                   RowNames: {}
           CustomProperties: [1x1 matlab.tabular.CustomProperties]
          GroupVariableName: 'ID'
    IndependentVariableName: 'TIME'

Define the Model

We will fit a simple one-compartment model, with bolus dose administration and linear clearance elimination, to the data.

pkmd = PKModelDesign;
pkmd.addCompartment('Central', 'DosingType', 'Bolus', 'EliminationType', ...
    'Linear-Clearance', 'HasResponseVariable', true);
model = pkmd.construct;

% The model species |Drug_Central| corresponds to the data variable |CONC|.
responseMap = 'Drug_Central = CONC';

Specify Initial Estimates for the Parameters

The parameters fit in this model are the volume of the central compartment (Central) and the clearance rate (Cl_Central). NLMEFIT calculates fixed and random effects for each parameter. The underlying algorithm assumes parameters are normally distributed. This assumption may not hold for biological parameters that are constrained to be positive, such as volume and clearance. We need to specify a transform for the estimated parameters, such that the transformed parameters do follow a normal distribution. By default, SimBiology® chooses a log transform for all estimated parameters. Therefore, the model is:

log(Vi)=log(ϕV,i)=θV+ηV,i

and

log(Cli)=log(ϕCl,i)=θCl+ηCl,i,

where θ, eta, and ϕ are the fixed effects, random effects, and estimated parameter values respectively, calculated for each group i. We provide some arbitrary initial estimates for V and Cl in the absence of better empirical data.

estimatedParams = estimatedInfo({'log(Central)', 'log(Cl_Central)'}, ...
    'InitialValue', [1 1]);

Extract the Dosing Information from the Data

Create a sample dose that targets species Drug_Central and use the createDoses method to generate doses for each infant based on the dosing amount listed in variable DOSE.

sampleDose = sbiodose('sample', 'TargetName', 'Drug_Central');
doses = createDoses(data, 'DOSE', '', sampleDose);

Fit the Model

Slightly loosen the tolerances to speed up the fit.

fitOptions.Options = statset('TolFun', 1e-3, 'TolX', 1e-3);
[nlmeResults, simI, simP] = sbiofitmixed(model, data, responseMap, ...
    estimatedParams, doses, 'nlmefit', fitOptions);

Visualize the Fitted Model with the Data

Overlay the fitted simulation results on top of the observed data already displayed on the trellis plot. For the population results, simulations are run using the estimated fixed effects as the parameter values. For the individual results, simulations are run using the sum of the fixed and random effects as the parameter values.

t.plot(simP, [], '', 'Drug_Central');
t.plot(simI, [], '', 'Drug_Central',...
    'legend',{'Observed', 'Fit-Pop.', 'Fit-Indiv.'});

Figure contains 64 axes objects. Axes object 1 with title Run 1 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 2 with title Run 2 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with title Run 3 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 4 with title Run 4 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 5 with title Run 5 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 6 with title Run 6 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 7 with title Run 7 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 8 with title Run 8 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 9 with title Run 9 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 10 with title Run 10 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 11 with title Run 11 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 12 with title Run 12 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 13 with title Run 13 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 14 with title Run 14 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 15 with title Run 15 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 16 with title Run 16 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 17 with title Run 17 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 18 with title Run 18 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 19 with title Run 19 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 20 with title Run 20 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 21 with title Run 21 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 22 with title Run 22 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 23 with title Run 23 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 24 with title Run 24 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 25 with title Run 25 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 26 with title Run 26 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 27 with title Run 27 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 28 with title Run 28 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 29 with title Run 29 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 30 with title Run 30 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 31 with title Run 31 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 32 with title Run 32 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 33 with title Run 33 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 34 with title Run 34 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 35 with title Run 35 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 36 with title Run 36 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 37 with title Run 37 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 38 with title Run 38 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 39 with title Run 39 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 40 with title Run 40 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 41 with title Run 41 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 42 with title Run 42 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 43 with title Run 43 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 44 with title Run 44 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 45 with title Run 45 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 46 with title Run 46 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 47 with title Run 47 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 48 with title Run 48 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 49 with title Run 49 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 50 with title Run 50 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 51 with title Run 51 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 52 with title Run 52 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 53 with title Run 53 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 54 with title Run 54 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 55 with title Run 55 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 56 with title Run 56 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 57 with title Run 57 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 58 with title Run 58 contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 59 with title Run 59 contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Observed, Fit-Pop., Fit-Indiv.. Axes object 60 is empty. Axes object 61 is empty. Axes object 62 is empty. Axes object 63 is empty. Axes object 64 is empty.

Examine Fitted Parameters and Covariances

disp('Summary of initial results');
Summary of initial results
disp('Parameter Estimates Without Random Effects:');
Parameter Estimates Without Random Effects:
disp(nlmeResults.PopulationParameterEstimates(1:2,:));
    Group         Name         Estimate
    _____    ______________    ________

      1      {'Central'   }      1.4086
      1      {'Cl_Central'}    0.006137
disp('Estimated Fixed Effects:');
Estimated Fixed Effects:
disp(nlmeResults.FixedEffects);
       Name        Description      Estimate    StandardError
    __________    ______________    ________    _____________

    {'theta1'}    {'Central'   }    0.34257       0.061246   
    {'theta2'}    {'Cl_Central'}    -5.0934       0.079501   
disp('Estimated Covariance Matrix of Random Effects:');
Estimated Covariance Matrix of Random Effects:
disp(nlmeResults.RandomEffectCovarianceMatrix);
             eta1       eta2  
            _______    _______

    eta1    0.20323          0
    eta2          0    0.19338

Generate a Box Plot of the Estimated Parameters

This example uses MATLAB® plotting commands to visualize the results. Several commonly used plots are also available as built-in options when performing parameter fits through the SimBiology® desktop interface.

% Create a box plot of the calculated random effects.
boxplot(nlmeResults);

Figure contains an axes object. The axes object contains 14 objects of type line. One or more of the lines displays its values using only markers

Generate a Plot of the Residuals over Time

% The vector of observation data also includes NaN's at the time points at
% which doses were given. We need to remove these NaN's to be able to plot
% the residuals over time.
timeVec = data.(data.Properties.IndependentVariableName);
obsData = data.CONC;
indicesToKeep = ~isnan(obsData);
timeVec = timeVec(indicesToKeep);

% Get the residuals from the fitting results.
indRes = nlmeResults.stats.ires(indicesToKeep);
popRes = nlmeResults.stats.pres(indicesToKeep);

% Plot the residuals. Get a handle to the plot to be able to add more data
% to it later.
resplot = figure;
plot(timeVec,indRes,'d','MarkerFaceColor','b','markerEdgeColor','b');
hold on;
plot(timeVec,popRes,'d','MarkerFaceColor','w','markerEdgeColor','b');
hold off;

% Create a reference line representing a zero residual, and set its
% properties to omit this line from the plot legend.
refl = refline(0,0);
refl.Annotation.LegendInformation.IconDisplayStyle = 'off';

% Label the plot.
title('Residuals versus Time');
xlabel('Time');
ylabel('Residuals');
legend({'Individual','Population'});

Figure contains an axes object. The axes object with title Residuals versus Time, xlabel Time, ylabel Residuals contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Individual, Population.

Extract Group-dependent Covariate Values from the Dataset

Get the mean value of each covariate for each group.

covariateLabels = {'WEIGHT', 'APGAR'};
covariates = grpstats(ds, data.Properties.GroupVariableName, 'mean',...
    'DataVars', covariateLabels);

Examine NLME Parameter Fit Results for Possible Covariate Dependencies

% Get the parameter values for each group (empirical Bayes estimates). 
paramValues = nlmeResults.IndividualParameterEstimates.Estimate;
isCentral = strcmp('Central', nlmeResults.IndividualParameterEstimates.Name);
isCl = strcmp('Cl_Central', nlmeResults.IndividualParameterEstimates.Name);

% Plot the parameter values vs. covariates for each group.
figure;
subplot(2,2,1);
plot(covariates.mean_WEIGHT,paramValues(isCentral), '.');
ylabel('Volume');

subplot(2,2,3);
plot(covariates.mean_WEIGHT,paramValues(isCl), '.');
ylabel('Clearance');
xlabel('weight');

subplot(2,2,2);
plot(covariates.mean_APGAR, paramValues(isCentral), '.');

subplot(2,2,4);
plot(covariates.mean_APGAR, paramValues(isCl), '.');
xlabel('APGAR');

Figure contains 4 axes objects. axes object 1 with ylabel Volume contains a line object which displays its values using only markers. axes object 2 with xlabel weight, ylabel Clearance contains a line object which displays its values using only markers. Axes object 3 contains a line object which displays its values using only markers. axes object 4 with xlabel APGAR contains a line object which displays its values using only markers.

Create a CovariateModel to Model the Covariate Dependencies

Based on the plots, there appears to be a correlation between volume and weight, clearance and weight, and possibly volume and APGAR score. We choose to focus on the effect of weight by modeling two of these covariate dependencies: volume ("Central") varying with weight and clearance ("Cl_Central") varying with weight. Our model is:

log(Vi)=log(ϕV,i)=θV+θV/weight*weighti+ηV,i

and

log(Cli)=log(ϕCl,i)=θCl+θCl/weight*weighti+ηCl,i

% Define the covariate model.
covmodel            = CovariateModel;
covmodel.Expression = ({'Central = exp(theta1 + theta2*WEIGHT + eta1)','Cl_Central = exp(theta3 + theta4*WEIGHT + eta2)'});

% Use constructDefaultInitialEstimate to create a initialEstimates struct.
initialEstimates = covmodel.constructDefaultFixedEffectValues;
disp('Fixed Effects Description:');
Fixed Effects Description:
disp(covmodel.FixedEffectDescription);
    {'Central'          }
    {'Cl_Central'       }
    {'Central/WEIGHT'   }
    {'Cl_Central/WEIGHT'}

Update the initial estimates using the values estimated from fitting the base model.

initialEstimates.theta1 = nlmeResults.FixedEffects.Estimate(1);
initialEstimates.theta3 = nlmeResults.FixedEffects.Estimate(2);
covmodel.FixedEffectValues = initialEstimates;

Fit the Model

[nlmeResults_cov, simI_cov, simP_cov] = sbiofitmixed(model, data, responseMap, ...
    covmodel, doses, 'nlmefit', fitOptions);

Examine Fitted Parameters and Covariances

disp('Summary of results when modeling covariate dependencies');
Summary of results when modeling covariate dependencies
disp('Parameter Estimates Without Random Effects:');
Parameter Estimates Without Random Effects:
disp(nlmeResults_cov.PopulationParameterEstimates);
    Group         Name         Estimate 
    _____    ______________    _________

     1       {'Central'   }       1.2973
     1       {'Cl_Central'}    0.0061576
     2       {'Central'   }       1.3682
     2       {'Cl_Central'}    0.0065512
     3       {'Central'   }       1.3682
     3       {'Cl_Central'}    0.0065512
     4       {'Central'   }      0.99431
     4       {'Cl_Central'}    0.0045173
     5       {'Central'   }       1.2973
     5       {'Cl_Central'}    0.0061576
     6       {'Central'   }       1.1664
     6       {'Cl_Central'}      0.00544
     7       {'Central'   }       1.0486
     7       {'Cl_Central'}     0.004806
     8       {'Central'   }       1.1664
     8       {'Cl_Central'}      0.00544
     9       {'Central'   }       1.2973
     9       {'Cl_Central'}    0.0061576
     10      {'Central'   }       1.2973
     10      {'Cl_Central'}    0.0061576
     11      {'Central'   }       1.1664
     11      {'Cl_Central'}      0.00544
     12      {'Central'   }       1.2301
     12      {'Cl_Central'}    0.0057877
     13      {'Central'   }       1.1059
     13      {'Cl_Central'}    0.0051132
     14      {'Central'   }       1.1059
     14      {'Cl_Central'}    0.0051132
     15      {'Central'   }       1.2301
     15      {'Cl_Central'}    0.0057877
     16      {'Central'   }       1.1664
     16      {'Cl_Central'}      0.00544
     17      {'Central'   }       1.1059
     17      {'Cl_Central'}    0.0051132
     18      {'Central'   }       1.0486
     18      {'Cl_Central'}     0.004806
     19      {'Central'   }       1.0486
     19      {'Cl_Central'}     0.004806
     20      {'Central'   }       1.1664
     20      {'Cl_Central'}      0.00544
     21      {'Central'   }        1.605
     21      {'Cl_Central'}    0.0078894
     22      {'Central'   }       1.3682
     22      {'Cl_Central'}    0.0065512
     23      {'Central'   }       3.2052
     23      {'Cl_Central'}     0.017654
     24      {'Central'   }       3.3803
     24      {'Cl_Central'}     0.018782
     25      {'Central'   }      0.89394
     25      {'Cl_Central'}    0.0039908
     26      {'Central'   }       3.9653
     26      {'Cl_Central'}     0.022619
     27      {'Central'   }       1.6927
     27      {'Cl_Central'}    0.0083936
     28      {'Central'   }       3.3803
     28      {'Cl_Central'}     0.018782
     29      {'Central'   }       1.0486
     29      {'Cl_Central'}     0.004806
     30      {'Central'   }        1.605
     30      {'Cl_Central'}    0.0078894
     31      {'Central'   }       1.2973
     31      {'Cl_Central'}    0.0061576
     32      {'Central'   }       4.1819
     32      {'Cl_Central'}     0.024064
     33      {'Central'   }       1.5218
     33      {'Cl_Central'}    0.0074154
     34      {'Central'   }       1.5218
     34      {'Cl_Central'}    0.0074154
     35      {'Central'   }       2.3292
     35      {'Cl_Central'}     0.012173
     36      {'Central'   }       1.3682
     36      {'Cl_Central'}    0.0065512
     37      {'Central'   }       1.1664
     37      {'Cl_Central'}      0.00544
     38      {'Central'   }       1.2301
     38      {'Cl_Central'}    0.0057877
     39      {'Central'   }       1.6927
     39      {'Cl_Central'}    0.0083936
     40      {'Central'   }       1.1059
     40      {'Cl_Central'}    0.0051132
     41      {'Central'   }       1.5218
     41      {'Cl_Central'}    0.0074154
     42      {'Central'   }       2.7323
     42      {'Cl_Central'}     0.014659
     43      {'Central'   }      0.99431
     43      {'Cl_Central'}    0.0045173
     44      {'Central'   }       1.2973
     44      {'Cl_Central'}    0.0061576
     45      {'Central'   }      0.94279
     45      {'Cl_Central'}    0.0042459
     46      {'Central'   }       1.1059
     46      {'Cl_Central'}    0.0051132
     47      {'Central'   }       2.4565
     47      {'Cl_Central'}     0.012951
     48      {'Central'   }      0.89394
     48      {'Cl_Central'}    0.0039908
     49      {'Central'   }       1.2301
     49      {'Cl_Central'}    0.0057877
     50      {'Central'   }       1.1059
     50      {'Cl_Central'}    0.0051132
     51      {'Central'   }      0.99431
     51      {'Cl_Central'}    0.0045173
     52      {'Central'   }      0.99431
     52      {'Cl_Central'}    0.0045173
     53      {'Central'   }       1.5218
     53      {'Cl_Central'}    0.0074154
     54      {'Central'   }        1.605
     54      {'Cl_Central'}    0.0078894
     55      {'Central'   }       1.1059
     55      {'Cl_Central'}    0.0051132
     56      {'Central'   }      0.84763
     56      {'Cl_Central'}     0.003751
     57      {'Central'   }       1.8827
     57      {'Cl_Central'}    0.0095009
     58      {'Central'   }       1.2973
     58      {'Cl_Central'}    0.0061576
     59      {'Central'   }       1.1059
     59      {'Cl_Central'}    0.0051132
disp('Estimated Fixed Effects:');
Estimated Fixed Effects:
disp(nlmeResults_cov.FixedEffects);
       Name            Description         Estimate    StandardError
    __________    _____________________    ________    _____________

    {'theta1'}    {'Central'          }    -0.48453      0.067952   
    {'theta3'}    {'Cl_Central'       }     -5.9575       0.12199   
    {'theta2'}    {'Central/WEIGHT'   }     0.53203      0.040788   
    {'theta4'}    {'Cl_Central/WEIGHT'}     0.61957      0.074264   
disp('Estimated Covariance Matrix:');
Estimated Covariance Matrix:
disp(nlmeResults_cov.RandomEffectCovarianceMatrix);
              eta1       eta2  
            ________    _______

    eta1    0.029793          0
    eta2           0    0.04644

Visualize the Fitted Model with the Data

t.plot(simP_cov, [], '', 'Drug_Central');
t.plot(simI_cov, [], '', 'Drug_Central',...
    'legend',{'Observed', 'Fit-Pop..', 'Fit-Indiv.', 'Cov. Fit-Pop.', 'Cov. Fit-Indiv.'});

Figure contains 64 axes objects. Axes object 1 with title Run 1 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 2 with title Run 2 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with title Run 3 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 4 with title Run 4 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 5 with title Run 5 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 6 with title Run 6 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 7 with title Run 7 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 8 with title Run 8 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 9 with title Run 9 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 10 with title Run 10 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 11 with title Run 11 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 12 with title Run 12 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 13 with title Run 13 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 14 with title Run 14 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 15 with title Run 15 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 16 with title Run 16 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 17 with title Run 17 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 18 with title Run 18 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 19 with title Run 19 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 20 with title Run 20 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 21 with title Run 21 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 22 with title Run 22 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 23 with title Run 23 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 24 with title Run 24 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 25 with title Run 25 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 26 with title Run 26 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 27 with title Run 27 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 28 with title Run 28 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 29 with title Run 29 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 30 with title Run 30 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 31 with title Run 31 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 32 with title Run 32 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 33 with title Run 33 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 34 with title Run 34 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 35 with title Run 35 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 36 with title Run 36 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 37 with title Run 37 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 38 with title Run 38 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 39 with title Run 39 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 40 with title Run 40 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 41 with title Run 41 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 42 with title Run 42 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 43 with title Run 43 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 44 with title Run 44 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 45 with title Run 45 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 46 with title Run 46 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 47 with title Run 47 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 48 with title Run 48 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 49 with title Run 49 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 50 with title Run 50 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 51 with title Run 51 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 52 with title Run 52 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 53 with title Run 53 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 54 with title Run 54 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 55 with title Run 55 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 56 with title Run 56 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 57 with title Run 57 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 58 with title Run 58 contains 5 objects of type line. One or more of the lines displays its values using only markers Axes object 59 with title Run 59 contains 5 objects of type line. One or more of the lines displays its values using only markers These objects represent Observed, Fit-Pop.., Fit-Indiv., Cov. Fit-Pop., Cov. Fit-Indiv.. Axes object 60 is empty. Axes object 61 is empty. Axes object 62 is empty. Axes object 63 is empty. Axes object 64 is empty.

Compare the Residuals to Those from a Model Without Covariate Dependencies

The following plot shows that the population residuals are smaller in the covariate model fit compared to the original fit.

% Get the residuals from the fitting results.
indRes = nlmeResults_cov.stats.ires(indicesToKeep);
popRes = nlmeResults_cov.stats.pres(indicesToKeep);

% Return to the original residual plot figure and add the new data.
figure(resplot);
hold on;
plot(timeVec,indRes,'d','MarkerFaceColor','r','markerEdgeColor','r');
plot(timeVec,popRes,'d','MarkerFaceColor','w','markerEdgeColor','r');
hold off;

% Update the legend.
legend('off');
legend({'Individual','Population','Individual(Cov.)','Population(Cov.)'});

Figure contains an axes object. The axes object with title Residuals versus Time, xlabel Time, ylabel Residuals contains 5 objects of type line. One or more of the lines displays its values using only markers These objects represent Individual, Population, Individual(Cov.), Population(Cov.).

References

[1] Grasela TH Jr, Donn SM. Neonatal population pharmacokinetics of phenobarbital derived from routine clinical data. Dev Pharmacol Ther 1985:8(6). 374-83.