PMED Undergraduate Workshop - Hands on Demos for PMED in R Software (Hands on Solution) - John Nardini, October 22, 2018
1. SAMSI PMED Hands-on problem set
Go to https://github.com/johnnardini/SAMSI_PMED_UG and download patient_data.Rdata
1. Load in and plot some of the patients’ data from patient_exp_data.zip over time. What
can you infer about a patient’s growth rate immediately from the visualization of the
graph?
If data increase, then k > 0 , if data decreases then k <0
2. Plot patient 1’s data over time as well as the cost function over a range of values of k.
What do you think their value of k is? You may assume the initial volume of all
patients is x0=10.
You may suggest to students plotting log(J(k)) if they are having trouble finding the
minimum. The minimum value should appear to be about 0.56
3. Use linear regression to estimate Patient 1’s growth rate. How does this result change if
you use Nelder-Mead? And what is the variance in their data?
With linear regression, I get k=0.5541 with variance 394.62
With Nelder-Mear, I get k =0.5541 with variance 0.2406
4. Say that we label each patient’s tumor as either benign if k<= 0 and malignant if k > 0.
Estimate the value of k for all patients. Which patients are benign and which are
malignant? Estimate each patient’s variance to also understand how certain you can be
of this decision
Maligant = 1 2 4 5 7 9 10 11 13 14 15 16 17 18 19 20 23 28
[19] 29 30 31 32 33 35 36 37 38 39 40 42 43 44 45 46 47 48
[37] 51 52 53 54 55 57 58 59 60 61 62 63 64 65 67 68 69 70
[55] 71 72 73 74 75 76 78 79 80 81 82 83 85 86 88 90 91 92
[73] 93 94 95 96 97 98 99 100
Benign = 3 6 8 12 21 22 24 25 26 27 34 41 49 50 56 66 77 84 87 89
5. Load in patient data from patient_logistic_data.zip. Here, patient data is assumed to
satisfy the logistic equation with solution
𝑥𝑥(𝑡𝑡) =
𝐿𝐿
1+
𝐿𝐿−𝑥𝑥0
𝑥𝑥0
𝑒𝑒−𝑘𝑘𝑘𝑘
with growth rate k , carrying capacity L, and initial value x0. Estimate k and L for each
patient. You may assume x0 = 10 for all patients. The following are the k and L estimate
value I got for each patient using the Nelder-Mead algorithm.
k_vec L_vec
1 1.2654676 8.304699e-01
2 11.7619727 1.615752e+00