ELECTRONIC SUPPLEMENTARY MATERIAL

General implementation of class Patient and Model

The definition of class Patient and Model form the basic structure for the program:

publicclassPatient

{

publicstring Name;

publicdouble[] Concentration;

publicDateTimeRegDate;

public Patient()

{

Name = "unknown";

Concentration = newdouble[] { 0, 0, 0, 0 };

RegDate = DateTime.Now;

}

}

abstractpublicclassModel : Patient

{

publicdouble AUC;

publicdouble[] Curve;

protecteddouble[] t;

public Model()

{

AUC = newdouble();

Curve = newdouble[60];

t = newdouble[] { 1, 3, 6, 8 };

}

protecteddouble[] CurveApprox(DoubleVector Solution, DoubleParameterizedFunction Function, int Start, int End)

{

double[] CA = newdouble[End - Start];

doubleEvX = newdouble();

for (inti = Start; i < End; i++)

{

EvX = i;

EvX = EvX / 5;

CA[i - Start] = Function.Evaluate(Solution, EvX);

}

return CA;

}

}

The compartment model implementation

The compartment model is implemented as class CompModel with initialization function:

publicclassCompModel : Model

{

publicCompModel(Patient Pat)

{

DoubleVectortv = newDoubleVector(t);

try

{

Name = Pat.Name;

Concentration = Pat.Concentration;

DoubleVectorConc = newDoubleVector(Concentration);

OneCompartmentOneCompModel = newOneCompartment();

OneVariableFunctionFitterTrustRegionMinimizer> fitter = newOneVariableFunctionFitterTrustRegionMinimizer>(OneCompModel);

DoubleVectorInitValues = newDoubleVector("[ 3000 0,5 0,01]");

DoubleVector Solution = fitter.Fit(tv, Conc, InitValues);

Curve = CurveApprox(Solution, OneCompModel, 0, 60);

AUC = Math.Round((Solution[0] * Solution[2] / (Solution[2] - Solution[1])) * (1 / Solution[1] - 1 / Solution[2]));

}

catch

{

MessageBox.Show("Cannot calculate AUC!");

}

}

}

The modified model inspired by Purves for non compartment curve fitting

This model is an implementation of formula (3) with an added estimate of tail AUC as mentioned earlier. The code for calculation of the vector Curve is not shown since it does not add any information about the algorithm implementation but takes several lines of code.

publicclassSjPuModel : Model

{

publicSjPuModel(Patient Pat)

{

try

{

string Name = Pat.Name;

double[] Concentration = Pat.Concentration;

double[] a = newdouble[4];

double[] b = newdouble[4];

double[] z = newdouble[4];

AUC = 0;

inti = 0;

int cut = 0;

// Decide where to cut between PTO and exponential fall

if (Concentration[2] > Concentration[0]) cut = 2;

else cut = 1;

// if C3 is more than C2 it is not possible to calculate the tail

if (Concentration[3] >= Concentration[2]) thrownewArgumentException();

else

{

// PTO

while (cut > i)

{

a[i] = (Concentration[i + 1] / t[i + 1] - Concentration[i] / t[i]) / (t[i + 1] - t[i]);

b[i] = (Concentration[i] / t[i] - a[i] * t[i]);

if (i == 0) AUC = a[0] / 3 * t[0] * t[0] * t[0] + 0.5 * b[0] * t[0] * t[0];

AUC = AUC + a[i] / 3 * (t[i + 1] * t[i + 1] * t[i + 1] - t[i] * t[i] * t[i]) + 0.5 * b[i] * (t[i + 1] * t[i + 1] - t[i] * t[i]);

i++;

}

// Exponential fall

while (3 > i)

{

z[i] = (t[i + 1] - t[i]) / Math.Log(Concentration[i + 1] / Concentration[i]);

AUC = AUC + (Concentration[i + 1] - Concentration[i]) * z[i];

i++;

}

// Tail calculation

AUC = AUC - Concentration[3] * z[2];

AUC = Math.Round(AUC);

}

}

catch

{

MessageBox.Show("Cannot calculate AUC!");

}

}

}

icc(C, model = "two way", type = "agreement")

Single Score Intraclass Correlation

Model: two way

Type : agreement

Subjects = 23

Raters = 2

ICC(A,1) = 0.864

F-Test, H0: r0 = 0 ; H1: r0 > 0

F(22,22.5) = 14.1 , p = 1.43e-08

95%-Confidence Interval for ICC Population Values:

0.708 < ICC < 0.939