Load the tumor growth data set from the url http://benzekry.perso.math.cnrs.fr/DONNEES/data_exam.csv
into a dataframe
df = read.csv('http://benzekry.perso.math.cnrs.fr/DONNEES/data_exam.csv', sep=";")
Load the time vector in a variable time
Load the volume data in a variable V
We will first assume a constant error model (i.e. σj=σ,∀j) and an exponential structural model: V(t;(V0,α))=V0eαt. We can transform the problem so that it reduces to a linear regression.
Define a variable y
as the log of V
Using the formula seen in class, build the least-squares matrix M for fitting y
Solve the system corresponding to the linear regression
Plot the regression line together with the data
Considering that the number of injected cells is 106 cells, which corresponds to V0=1 mm3, and looking at the fit, what do you conclude about the validity of the exponential model?
The estimate of σ2 is given by s2=1n−2n∑j=1(yj−Mˆθ)2 with ˆθ the vector of optimal parameters just found and n is the number of time points.
If residuals=y−Mˆθ is the vector of residuals, then s2 can be computed as s2=1n−2residualsT⋅residuals with residualsT the tranpose of the vector residuals. Using these considerations, compute s2.
Deduce the estimation of the covariance matrix of the parameter estimates, given by s2(MTM)−1
Compute the standard errors on the parameter estimates.
Use the built-in ordinary linear least-squares function lm()
to verify the results