The Pharmacokinetics dose response (Authors: Tom Gutman, jmG, Viktor, wschrabi)

You have input data that is not described at all. The names used are not at all mnemonic (presumably Xtime is time in minutes and Yconcentration is concentration is some unspecified units. You should have this described in your sheet, if the sheet is to be useful for anything more than a one Xtime use, to be then discarded and never looked at again. While Mathcads ODESolvers make using units a pain, you should either use units in Mathcad, or at least document the units for all variables. To further confuse things, here you label the Xtime as time and the concetration as Y. But later you use t or Xtime for time, and use x for the mass quantity. Consistent and mnemonic nomenclature helps make a sheet clearer, and reduces the chances of error.

the Data here are that from a pahtological dog (HF-V30) with infusion-pump

I have now defined the time as Xtime, which is the time where the concentration is observed.

For convergence check the data should be analysed with the

endpoint where the time >= 60 min.

You seem to be looking to see the extent to which the late samples affect the result. I'm not sure of the usefulness of that, a plot of the residuals (which should always be done) will show if there are anomalies with the late data. But still .....

A usefule utility function, a specialization of submatrix:

Project parameters

Dose injection [mg]

Duration_injection [min]

Initial Concentration

in Central comp't [mg/l]

in Peripheral coomp't [mg/l]

Infusionrate: (for an infusion pump)

You should be much more careful with your units, and the meaning of the variables. More definitions (verbal) are useful. Here you describe c10 and c20 as concentrations, but you eventually use them as initial values for the x1 and x2 variables, which are mass quantities. That is not consistent. Since the values are zero it doesn't affect the evential answers, but it is still logically incorrect.

Auxilliary parameters in the system

Again, more description and documentation needed. This is the external infusion rate (by inference). f is not very mnemonic for this function.

f(time) is the infusion rate and could be a konstant dose over the infusion time (= the duration of the injection, t) and after the t it could be a constant rate, when a pump is used. Otherwise it is 0. In our case we do not use a pump so it is r=0.

You are trying to do too much in this structure. You do not actually need the residuals, the predicted values are quite sufficient. But you do want to use the solution both for the parameter estimation and also for plotting. You should not have a duplicate of the ODESolve block for the two purposes. That's what functions are for, to reuse the same definition for multiple calculations.

Integration Xtime (in minutes)

1. Open the DE solver and dress the system c/w the initial DE parameters

There are still some issues with this. You have not really described what the variables are. x1 and x2 are the mass quantities in the two compartments. That should be stated explicitly. Especially as you are also working with concentrations (you have expressed the initial values as concentrations, and your input data is a concentration). You could set up the equation to be in terms of concentrations rather than mass quantities. Then you would have only one rate constant, but the two volumes would be involved in the equations. As it is the volumes are implicit in the rate constants and do not explicitly appear in the ODE. The volume is not needed as a parameter.

Guesses for minerr

Rather than residuals, calculate the predicted values and equate those to the input values.

Pragmatical relationships:

Descriptions, units, and perhaps some derivations would be helpful here.

Eliminationrate k01*Central Volume = CLEARANCE [ml/min]

t21[min] = Half life of tranfer Vol2 to Vol1 = ln(2)/k21

k21 is the constant for transfer from V1 to V2. It is not directly related to elimination. So t21 is the half life for equilibriation between the two compartments, not the half life of elimination.

Having done this once, it is unecessary to do it again. Besides which, as written, it is wrong. Sol is described with arguments of a, b, c and d, but these variables do not appear in the definition and so are meaningless. The values of the variables used are those defined above.

V1 is not needed to describe the solution. Only for expressing it as a concentration.

2. Assign the numerical algorithmic solutions X1, X2 to the end user.

The Maple code is a mess. It is full of variables that I have no idea what they mean or how they were calculated. There is nothing to relate the various expressions there to the original ODE. First, I will ignore all that and just look to duplicate the Maple solution in Mathcad.

The Maple solution uses a t of three rather than one. But it is for a different data set.

Three unknown variables, and (apparently) the initial dose.

The Maple stuff seems to be set up in terms of vol1, vol2, t21, and clearance. While a bit wordy, I will stick to that.

As a matter of readability, I prefer the programmed if structure to the if function:

Guess values:

A variant on this is to combine all the calculations into a single function. This allows using local variables rather than function definitions for the various intermediate variables. The advantage is much smaller, and more readable, expressions -- close to the Maple expressions. The disadvantage is that there is no easy way to evaluate and see the intermediate variables, making it difficult to validate the construct.

If you are going to analyze partial data, the place to set it up is here, rather than duplicate code later:

Guess values:

The results match the previous ones.

Mixing Matrix: In the rows there is the same substance and in the columns there is the mixingrelationship.

vol2I is the Vector for the changed Volume2

t21I is the Vector for the changed t21

Average artificial Protocol based on M1 and M2, on these models the Vol2 is changed.

(In the case of 2 changes: M1 has the Vol2=32.3720 l and M2 has the Vol2=10.2262 l)

Check and Control of the concentrations and mixing results:

Calculation of the standard deviation with the Fisher's Info Matrix:

Calculate the Products of the Sensi-Matrice

To use this for different analyses, you need to porivde the endpoint and also parameterize the parameter values (rather than use the current worksheet values).

Central differences are used for changing the parameters:

This looks for the first Parameter (vol1) as follows:



Parameterchange for vol1 left from the central point

Parameterchange for vol1 right from the central point

Since the residuals are often of interest in themselves, I prefer an approach that calculates the residuals and then uses them directly for the standard error calculations, rather than doing an explicit sum of squares.

The standard error, adjusted for degrees of freedom:

RESULTS of system parameters with standard deviations (central differences):

For the Monte Carlo Simulation we need a interferenced curve with a normal distributed random number vector:

The discussion was the question, if you must interference the random numbers with the idiale curve (that is the Estelberger assumption) or with the observed Yconcentration values. (that is the wrong assumption)

For the Simulation we need more such curves:

The first artificial interference over the idial curve are:

The first artificial interference over the measurement points are:

Guess values:

Guess values can be provided by worksheet assignments, or as arguments of the function. There is no need to do both. Since runs are for quite similar values, there is no need to parameterize the guess values, fixed values will do fine.

Calculation of the System Parameters for the artificial protocols:

SParaA is exactly MINI, without the extraneous parameters. Since the extraneous parameters were removed, it is exactly the same.

It's taking entirely too long to calculate SysParaArti many, many times. Once for each parameter value is enough!

Results of the Monte Carlo Simulation (Mean and Standard dev.) of wrong assumption:

Results of the Monte Carlo Simulation (Mean and Standard dev.) of Estelberger assumption:

RESULTS of system parameters with standard deviations from Fisher's Info Matrix (central differences):

Results from ODE:

Results from 2nd solution:

Note that different data sets (truncations) have different parameters and so the model and the residuals need to be calculated with the current values.

Here is the convergence of the original Yconcentration

Please notice: The assumption that the original Yconcentration should be nearly the same with the YMmean is not correct. You can see this, that the dlearance of the original concentration increases with time, and that is not with the YMmean concentration. So the mixing of the concentrations are not the same with the reality, as in reality the small molecules are feed into the concentration continously.

Convergence-Check of the Clearance for Times >= 60 min

Here is the convergence of the YM1 concentration

Convergence-Check of the Clearance for Times >= 60 min

Here is the convergence of the YM2 concentration

Convergence-Check of the Clearance for Times >= 60 min

Here is the convergence of the YMmean concentration

Convergence-Check of the Clearance for Times >= 60 min

Convergence Check over all entered t21-Values:

Convergence Check over all entered t21-Values for all mixing relationsships:

Column 0 is for the Systemparameters like in My3DConv above.

Column 1 is for the standard derviations done by Fisher`s sensivity analyses

Column 2 is the Fisher Info matrix.

Column 3 is the corresponding t21 value.

the corresponding t21 Values:

Clearance-Convergences for different t21-Values

All 3 curves in one diagram without the tol error bar:

Volume1-Convergences for different t21-Values

All 3 curves in one diagram without the tol error bar:

Volume2-Convergences for different t21-Values

All 3 curves in one diagram without the tol error bar:

t21-Convergences for different t21-Values

All 3 curves in one diagram without the tol error bar:

Clearance Change over protocol-length (XAchse) over all mixing relationsships:

corresp. t21 value for this Clearance diagram:

My preference for an analytic solution is one that starts with the actual ODE and is traceable back to that.

A simple general solution requires the exponential of a matrix. Easy enough to do with the eigenvector decomposition of a matrix. But what we really need is for a given A and many values of t. Eigenvector calculations are somewhat time-consuming. So we design a function that can, given A, create the function as a function of t.

Since we want to use the symbolic processor to extract information for the ODEs, we need to symbolically undefine variables that we wish to have symbolically.

We write the ODEs in the normal style, without the explict functional dependencies. We store them in a variable for further use.

We get complaints from the numeric processor about undefined variables. Those errors don't matter, the symbolic processor deals with undefined variables just fine. But the numeric processor gets into a huff when it is ignored. Just ignore it.

We want to get the expression for the vector of derivatives.

Solve produces a row vector rather than the stanandard (for Mathcad) column vector

Now we do a bit of general calculus. Consider the differential equation where A and B are constants. The solution will be of the form where C and D are constants. We can find D by differentiating the equation for y and equating it to the value from the ODE, and then equating terms. We get . We can solve that last equality for D (the y's cancel out) and get . We can find C from the inital (or boundary) value. If we have that then we can substitute and solve to get . Using these two solutions we can write a function to get C and D:

We can get the matrix A from the derivative expression by taking the Jacobian. A is a function of the three k values.

We can now write a function to generate the analytic solution. But we note that B is only piecewise constant, having one value from 0 to t and a different value beyond that. So we need to generate the solution as a piecewise function.

Now we can calculate the parameters:

Guess values

Pragmatical relationships:

Results match the numerical solution.

For reference, the two Xtime constants in the solution.

The corresponding characteristic times.

A modified model assuming a non-zero r, and an initial value corresponding to the equilibrium.

Now we can calculate the parameters:

Guess values

Pragmatical relationships:

Results match the numerical solution.

For reference, the two Xtime constants in the solution.

The corresponding characteristic times.

Equiblibrium (and initial) values of mass quantities

A modified model assuming a non-zero r applied to compartment 2, and an initial value corresponding to the equilibrium.

Now we can calculate the parameters:

Guess values

Pragmatical relationships:

Results match the numerical solution.

For reference, the two Xtime constants in the solution.

The corresponding characteristic times.

Equiblibrium (and initial) values of mass quantities