A project on oral administration of a medication -- parameter estimation.

Needs["Graphics`Colors`"];
<< Graphics`MultipleListPlot`

STEP 0:  TO DO THIS EXERCISE, YOU WILL NEED TO CAREFULLY READ AND UNDERSTAND THE DEMONSTRATION NOTEBOOK "INJECTION_MODEL.NB" (AVAILABLE ON THE CLASS WEB SITE) AS WELL AS  THE CLASS LECTURES CONCERNING THIS DEMONSTRATION.

STEP 1:  Project description.

An experimental brain enhancing medication CALCULEX is being tested in your laboratory.  The medication is administered orally, in liquid form.  It is absorbed from the intestine into the bloodstream, and then eliminated from the bloodstream through the kidneys and liver.  Your laboratory team suspects that a 2-parameter model such as the one discussed in class, and in the demonstration notebook "injection_model.nb" may be appropriate for CALCULEX.  You wish to estimate the parameters α and β and see if you can get a good fit to your data.

After the administration of the medication, blood samples are taken at 1/2 hour intervals during 24 hours.  Here are the experimental data.  (Of course, these data are unreasonably regular; real data are always messier!)

STEP 2: Data

data  = {{0.5, 21.279083417411044}, {1. , 30.687624798837998}, {1.5, 
            33.831571072507344}, {2. , 33.756387278721796}, {2.5, 
            32.10774815957943}, {3. , 29.766996054872866}, {3.5, 
            27.19894591813561}, {4. , 24.642162713466917}, {4.5, 
            22.21298095165011}, {5. , 19.962299931644125}, {5.5, 
            17.90653202646258}, {6. , 16.044410873576478}, {6.5, 
            14.366069800712808}, {7. , 12.857899977339535}, {7.5, 
            11.505109094433069}, {8. , 10.293031365415132}, {8.5, 
            9.207763251705302}, {9. , 8.236438507395158}, {9.5, 
            7.367313394211897}, {10. , 6.589754830435042}, {10.5, 
            5.894181553223815}, {11. , 5.27198507170371}, {11.5, 
            4.71544449393534}, {12. , 4.21764241956967}, {12.5, 
            3.772385370555159}, {13. , 3.374130244317747}, {13.5, 
            3.0179172290661938}, {14. , 2.6993090880528006}, {14.5, 
            2.4143364630395747}, {15. , 2.1594487382218217}, {15.5, 
            1.9314699743676456}, {16. , 1.7275594309113318}, {16.5, 
            1.5451762206749124}, {17. , 1.3820476768292278}, {17.5, 
            1.2361410488941686}, {18. , 1.105638181093431}, {18.5, 
            0.9889128608216072}, {19. , 0.8845105567637594}, {19.5, 
            0.7911302951691666}, {20. , 0.707608448977712}, {20.5, 
            0.6329042380888982}, {21. , 0.566086760252181}, {21.5, 
            0.5063233910571875}, {22. , 0.4528694085227481}, {22.5, 
            0.40505871302157115}, {23. , 0.36229552691449957}, {23.5, 
            0.3240469704700029}, {24. , 0.2898364215604899}};

We can present the data in a table as follows:

TableForm[data, 
      TableHeadings -> {None, {"time (hours)", "mg in \
blood"}}]

We plot the data points, and then we plot the data a second time with the successive data points joined by line segments to form a curve:

MultipleListPlot[data, 
      SymbolStyle ->  Red, 
 
      PlotJoined -> 
        False
]

MultipleListPlot[data, 
      SymbolStyle ->  Red, 
 
      PlotJoined -> True
]

STEP 3:  Logarithmic data

An important step in our discussion of parameter estimation in class was to apply the natural logarithm function to the measured data. You can apply natural logarithm function to the second coordinate of each data point with this command:

(Optional explanation of the mysterious appearance of the programming code below ; you don't have to read this explanation but I provide it in case you are curious.

& /@ data   applies a certain transformation to each element of our data list.
Each element in our data list consists of a pair {a, b}, where the first coordinate is time and the second coordinate a quanitity of the drug CALCULEX.  
#[[1]]  extracts the first coordinate a from such a pair.
#[[2]]  extracts the second coordinate b  from such a pair.
Log[#[[2]]]   applied the natural logarithm function to the second coordinate.
{#[[1]], Log[#[[2]]]}   replaces the original pair {a, b} with {a, Log[b]}.

End of the optional explanation.)

logdata  =  {#[[1]],  Log[#[[2]]]} &  /@  
          data;

TableForm[logdata, 
      TableHeadings -> {None, {"time (hours)", "log of mg in blood\
"}}]

Let's see what the plot of the logarithmic data looks like:

MultipleListPlot[logdata, 
      SymbolStyle ->  Red, 
 
      PlotJoined -> True
]

Your problem:   Using this information  (in particular the logarithmic data)   find parameters α and β such that the model with those parameters best fit the experimental data.  Also find K = ((50 α)/(α  - β)).
Compare the given data with the curve y  =  
        K ((e^(-β t)) - (e^(-α t)))predicted by the model; that is, plot the curve y  =  
        K ((e^(-β t)) - (e^(-α t)))using the parameters α,  β, and K which you have computed, and comment on the similarity or lack of similarity of your computed curve to the given data.