Hello, I am having a difficult time trying to understand
what I need to do to include parameter estimation in my program.
I am trying to use the fitOdeModel function from the simecol package.
Currently my output is a list of data frames because I use an lapply function call on the
data and the odemodel.
Some advise I was given was to make my model and the lapply function together into an object with the
class "simObj", without the out(sim()) call, is this possible? Then I could use that in
the FitOdeModel function.
Are there any suggestions about how to link my model through the lapply function to
the parameter estimation function FitOdeModel?
I know the observer slot "generally" does not work with Odemodels but is there a way to use it in my case please see code below.
Can I hold all the results until all the lapply function uses all the input columns, and
then return the data in a data frame? If I would try this I suppose I would have to put
these statements into the function that my lapply function calls and not the odemodel???
Is it possible to put the apply function into the MAIN function of my odeModel and change
the input to the complete dosing data set? This way I could simply insert the odeModel
into the FitOdeModel function???
FourCompApplyTest<- new("odeModel",
main = function (time, init, parms,x) {
with(as.list(c(parms, init,inputs)), {
Dose <- inputs$Dose(time)
Doselevel <- inputs$Doselevel(time)
Ke<- exp(alpha.e + beta.e*Doselevel) #
Klf <- exp(alpha.lf + beta.lf*Doselevel) #
Kfl<- exp(alpha.fl + beta.fl*Doselevel)
dCst <- Dose*bio - Kst*Cst #STOMACH
dClum <- Kst*Cst - Kabs*Clum #LUMAN
dCl <-(1-a)*Kabs*Clum -(Ke+Klf)*Cl + Kfl*Cf #LIVER
dCf <- Klf*Cl - Kfl*Cf #FAT
list(c(dCst,dClum,dCl,dCf),c(DoseL=Doselevel,Ke=Ke,Klf=Klf,Kfl=Kfl))
})
},
parms =c(Kst =8.64, Kabs=4.8, a = .5,
alpha.e =-2.944, beta.e=-0.001,
alpha.fl=-4.133,beta.fl=-0.001,
alpha.lf=-4.003, beta.lf=-0.001, bio = 1),
inputs = list(Dose = approxfun(0:727, x[4:731], rule=2),
Doselevel = approxfun(0:727, rep(x[2],728), rule=2)),
times = c(0,91, 210, 364, 726),
init =c(Cst = 0, Clum =0,Cl = 0, Cf = 0),
solver = "lsoda"
)
system.time( FourCompOutputTest <- sim( FourCompApplyTest))#,hmax=1,maxsteps=500000))
FourCompOutputTest
f2test <- function(x) {
inp <- list(Dose = approxfun(0:727, x[4:731], rule=2),
Doselevel = approxfun(0:727, rep(x[2],728), rule=2)
)
inputs(FourcompApply1) <- inp
if(x[3]==13) times(FourCompApplyTest) <-c(0,91);
if(x[3]==30) times(FourCompApplyTest) <-c(0,91, 210);
if(x[3]==52) times(FourCompApplyTest) <-c(0,91, 210, 364);
out(sim(FourCompApplyTest,hmax=1,maxsteps=500000))
}
lapply(x.all[c(2,17)], f2test)
#below is an example of the input data. I have 150 cols.
first 3 rows are animal #, dose levelm and obs time.
doses are 5 times a week.
x.all[c(2,17)]
X194 X467
Animal. 194.00000 467.00000
d. 10.00000 100.00000
t. 13.00000 104.00000
Week.0.M 0.58410 5.85420
Week.0.Tu 0.58410 5.85420
Week.0.W 0.58410 5.85420
Week.0.Th 0.58410 5.85420
Week.0.Fr 0.58410 5.85420
Week.0.Sa 0.00000 0.00000
Week.0.Su 0.00000 0.00000
Week.1.M 0.64317 6.60660
Week.1.Tu 0.64317 6.60660
Week.1.W 0.64317 6.60660
Week.1.Th 0.64317 6.60660
Week.1.Fr 0.64317 6.60660
Week.1.Sa 0.00000 0.00000
Week.1.Su 0.00000 0.00000
Week.2.M 0.70752 6.90360
Week.2.Tu 0.70752 6.90360
Week.2.W 0.70752 6.90360
Week.2.Th 0.70752 6.90360
Week.2.Fr 0.70752 6.90360
Week.2.Sa 0.00000 0.00000
Week.2.Su 0.00000 0.00000
Week.3.M 0.72534 7.84080
Week.3.Tu 0.72534 7.84080
Week.3.W 0.72534 7.84080
Week.3.Th 0.72534 7.84080
Week.3.Fr 0.72534 7.84080
Week.3.Sa 0.00000 0.00000
Week.3.Su 0.00000 0.00000
Week.4.M 0.76461 7.47450
Week.4.Tu 0.76461 7.47450
Week.4.W 0.76461 7.47450
Week.4.Th 0.76461 7.47450
Week.4.Fr 0.76461 7.47450
Week.4.Sa 0.00000 0.00000
Week.4.Su 0.00000 0.00000
Week.5.M 0.84579 7.90680
Week.5.Tu 0.84579 7.90680
Week.5.W 0.84579 7.90680
Week.5.Th 0.84579 7.90680
Week.5.Fr 0.84579 7.90680
Week.5.Sa 0.00000 0.00000
Week.5.Su 0.00000 0.00000
Week.6.M 0.84282 8.44470
Week.6.Tu 0.84282 8.44470
Week.6.W 0.84282 8.44470
Week.6.Th 0.84282 8.44470
Week.6.Fr 0.84282 8.44470
Week.6.Sa 0.00000 0.00000
Week.6.Su 0.00000 0.00000
Week.7.M 0.84447 8.51730
Week.7.Tu 0.84447 8.51730
Week.7.W 0.84447 8.51730
Week.7.Th 0.84447 8.51730
Week.7.Fr 0.84447 8.51730
Week.7.Sa 0.00000 0.00000
Week.7.Su 0.00000 0.00000
Week.8.M 0.82203 8.53710
Week.8.Tu 0.82203 8.53710
Week.8.W 0.82203 8.53710
Week.8.Th 0.82203 8.53710
Week.8.Fr 0.82203 8.53710
Week.8.Sa 0.00000 0.00000
Week.8.Su 0.00000 0.00000
Week.9.M 0.89562 8.63940
Week.9.Tu 0.89562 8.63940
Week.9.W 0.89562 8.63940
Week.9.Th 0.89562 8.63940
Week.9.Fr 0.89562 8.63940
Week.9.Sa 0.00000 0.00000
Week.9.Su 0.00000 0.00000
Week.10.M 0.93159 8.72850
Week.10.Tu 0.93159 8.72850
Week.10.W 0.93159 8.72850
Week.10.Th 0.93159 8.72850
Week.10.Fr 0.93159 8.72850
Week.10.Sa 0.00000 0.00000
Week.10.Su 0.00000 0.00000
Week.11.M 0.92664 8.88030
Week.11.Tu 0.92664 8.88030
Week.11.W 0.92664 8.88030
Week.11.Th 0.92664 8.88030
Week.11.Fr 0.92664 8.88030
Week.11.Sa 0.00000 0.00000
Week.11.Su 0.00000 0.00000
Week.12.M 0.91311 8.90670
Week.12.Tu 0.91311 8.90670
Week.12.W 0.91311 8.90670
Week.12.Th 0.91311 8.90670
Week.12.Fr 0.91311 8.90670
Week.12.Sa 0.00000 0.00000
Week.12.Su 0.00000 0.00000
Week.13.M 0.94248 9.06180
Week.13.Tu 0.94248 9.06180
Week.13.W 0.94248 9.06180
Week.13.Th 0.94248 9.06180
Week.13.Fr 0.94248 9.06180
Week.13.Sa 0.00000 0.00000
Week.13.Su 0.00000 0.00000
Week.14.M 0.00000 9.06180
Week.14.Tu 0.00000 9.06180
Week.14.W 0.00000 9.06180
Week.14.Th 0.00000 9.06180
Week.14.Fr 0.00000 9.06180
Week.14.Sa 0.00000 0.00000
Week.14.Su 0.00000 0.00000
Week.15.M 0.00000 9.06180
Week.15.Tu 0.00000 9.06180
Week.15.W 0.00000 9.06180
Week.15.Th 0.00000 9.06180
Week.15.Fr 0.00000 9.06180
Week.15.Sa 0.00000 0.00000
Week.15.Su 0.00000 0.00000
Week.16.M 0.00000 9.21690
Week.16.Tu 0.00000 9.21690
Week.16.W 0.00000 9.21690
Week.16.Th 0.00000 9.21690
Week.16.Fr 0.00000 9.21690
Week.16.Sa 0.00000 0.00000
Week.16.Su 0.00000 0.00000
Week.17.M 0.00000 9.50400
Week.17.Tu 0.00000 9.50400
Week.17.W 0.00000 9.50400
Week.17.Th 0.00000 9.50400
Week.17.Fr 0.00000 9.50400
Week.17.Sa 0.00000 0.00000
Week.17.Su 0.00000 0.00000
Week.18.M 0.00000 9.50400
Week.18.Tu 0.00000 9.50400
Week.18.W 0.00000 9.50400
Week.18.Th 0.00000 9.50400
Week.18.Fr 0.00000 9.50400
Week.18.Sa 0.00000 0.00000
Week.18.Su 0.00000 0.00000
Week.19.M 0.00000 9.50400
Week.19.Tu 0.00000 9.50400
Week.19.W 0.00000 9.50400
Week.19.Th 0.00000 9.50400
Week.19.Fr 0.00000 9.50400
Week.19.Sa 0.00000 0.00000
Week.19.Su 0.00000 0.00000
Week.20.M 0.00000 9.79110
Week.20.Tu 0.00000 9.79110
Week.20.W 0.00000 9.79110
Week.20.Th 0.00000 9.79110
Week.20.Fr 0.00000 9.79110
Week.20.Sa 0.00000 0.00000
Week.20.Su 0.00000 0.00000
Week.21.M 0.00000 9.79275
Week.21.Tu 0.00000 9.79275
Week.21.W 0.00000 9.79275
Week.21.Th 0.00000 9.79275
Week.21.Fr 0.00000 9.79275
Week.21.Sa 0.00000 0.00000
Week.21.Su 0.00000 0.00000
Week.22.M 0.00000 9.79275
Week.22.Tu 0.00000 9.79275
Week.22.W 0.00000 9.79275
Week.22.Th 0.00000 9.79275
Week.22.Fr 0.00000 9.79275
Week.22.Sa 0.00000 0.00000
Week.22.Su 0.00000 0.00000
Week.23.M 0.00000 9.79275
Week.23.Tu 0.00000 9.79275
Week.23.W 0.00000 9.79275
Week.23.Th 0.00000 9.79275
Week.23.Fr 0.00000 9.79275
Week.23.Sa 0.00000 0.00000
Week.23.Su 0.00000 0.00000
Week.24.M 0.00000 9.79440
Week.24.Tu 0.00000 9.79440
Week.24.W 0.00000 9.79440
Week.24.Th 0.00000 9.79440
Week.24.Fr 0.00000 9.79440
Week.24.Sa 0.00000 0.00000
Week.24.Su 0.00000 0.00000
Week.25.M 0.00000 9.89670
Week.25.Tu 0.00000 9.89670
Week.25.W 0.00000 9.89670
Week.25.Th 0.00000 9.89670
Week.25.Fr 0.00000 9.89670
Week.25.Sa 0.00000 0.00000
Week.25.Su 0.00000 0.00000
Week.26.M 0.00000 9.89670
Week.26.Tu 0.00000 9.89670
Week.26.W 0.00000 9.89670
Week.26.Th 0.00000 9.89670
Week.26.Fr 0.00000 9.89670
Week.26.Sa 0.00000 0.00000
Week.26.Su 0.00000 0.00000
Week.27.M 0.00000 9.89670
Week.27.Tu 0.00000 9.89670
Week.27.W 0.00000 9.89670
Week.27.Th 0.00000 9.89670
Week.27.Fr 0.00000 9.89670
Week.27.Sa 0.00000 0.00000
Week.27.Su 0.00000 0.00000
Week.28.M 0.00000 9.99900
Week.28.Tu 0.00000 9.99900
Week.28.W 0.00000 9.99900
Week.28.Th 0.00000 9.99900
Week.28.Fr 0.00000 9.99900
Week.28.Sa 0.00000 0.00000
Week.28.Su 0.00000 0.00000
Week.29.M 0.00000 10.04025
Week.29.Tu 0.00000 10.04025
Week.29.W 0.00000 10.04025
Week.29.Th 0.00000 10.04025
Week.29.Fr 0.00000 10.04025
Week.29.Sa 0.00000 0.00000
Week.29.Su 0.00000 0.00000
Week.30.M 0.00000 10.04025
Week.30.Tu 0.00000 10.04025
Week.30.W 0.00000 10.04025
Week.30.Th 0.00000 10.04025
Week.30.Fr 0.00000 10.04025
Week.30.Sa 0.00000 0.00000
Week.30.Su 0.00000 0.00000
Week.31.M 0.00000 10.04025
Week.31.Tu 0.00000 10.04025
Week.31.W 0.00000 10.04025
Week.31.Th 0.00000 10.04025
Week.31.Fr 0.00000 10.04025
Week.31.Sa 0.00000 0.00000
Week.31.Su 0.00000 0.00000
Week.32.M 0.00000 10.08150
Week.32.Tu 0.00000 10.08150
Week.32.W 0.00000 10.08150
Week.32.Th 0.00000 10.08150
Week.32.Fr 0.00000 10.08150
Week.32.Sa 0.00000 0.00000
Week.32.Su 0.00000 0.00000
Week.33.M 0.00000 10.09965
Week.33.Tu 0.00000 10.09965
Week.33.W 0.00000 10.09965
Week.33.Th 0.00000 10.09965
Week.33.Fr 0.00000 10.09965
Week.33.Sa 0.00000 0.00000
Week.33.Su 0.00000 0.00000
Week.34.M 0.00000 10.09965
Week.34.Tu 0.00000 10.09965
Week.34.W 0.00000 10.09965
Week.34.Th 0.00000 10.09965
Week.34.Fr 0.00000 10.09965
Week.34.Sa 0.00000 0.00000
Week.34.Su 0.00000 0.00000
Week.35.M 0.00000 10.09965
Week.35.Tu 0.00000 10.09965
Week.35.W 0.00000 10.09965
Week.35.Th 0.00000 10.09965
Week.35.Fr 0.00000 10.09965
Week.35.Sa 0.00000 0.00000
Week.35.Su 0.00000 0.00000
Week.36.M 0.00000 10.11780
Week.36.Tu 0.00000 10.11780
Week.36.W 0.00000 10.11780
Week.36.Th 0.00000 10.11780
Week.36.Fr 0.00000 10.11780
Week.36.Sa 0.00000 0.00000
Week.36.Su 0.00000 0.00000
Week.37.M 0.00000 10.15905
Week.37.Tu 0.00000 10.15905
Week.37.W 0.00000 10.15905
Week.37.Th 0.00000 10.15905
Week.37.Fr 0.00000 10.15905
Week.37.Sa 0.00000 0.00000
Week.37.Su 0.00000 0.00000
Week.38.M 0.00000 10.15905
Week.38.Tu 0.00000 10.15905
Week.38.W 0.00000 10.15905
Week.38.Th 0.00000 10.15905
Week.38.Fr 0.00000 10.15905
Week.38.Sa 0.00000 0.00000
Week.38.Su 0.00000 0.00000
Week.39.M 0.00000 10.15905
Week.39.Tu 0.00000 10.15905
Week.39.W 0.00000 10.15905
Week.39.Th 0.00000 10.15905
Week.39.Fr 0.00000 10.15905
Week.39.Sa 0.00000 0.00000
Week.39.Su 0.00000 0.00000
Week.40.M 0.00000 10.20030
Week.40.Tu 0.00000 10.20030
Week.40.W 0.00000 10.20030
Week.40.Th 0.00000 10.20030
Week.40.Fr 0.00000 10.20030
Week.40.Sa 0.00000 0.00000
Week.40.Su 0.00000 0.00000
Week.41.M 0.00000 10.32735
Week.41.Tu 0.00000 10.32735
Week.41.W 0.00000 10.32735
Week.41.Th 0.00000 10.32735
Week.41.Fr 0.00000 10.32735
Week.41.Sa 0.00000 0.00000
Week.41.Su 0.00000 0.00000
Week.42.M 0.00000 10.32735
Week.42.Tu 0.00000 10.32735
Week.42.W 0.00000 10.32735
Week.42.Th 0.00000 10.32735
Week.42.Fr 0.00000 10.32735
Week.42.Sa 0.00000 0.00000
Week.42.Su 0.00000 0.00000
Week.43.M 0.00000 10.32735
Week.43.Tu 0.00000 10.32735
Week.43.W 0.00000 10.32735
Week.43.Th 0.00000 10.32735
Week.43.Fr 0.00000 10.32735
Week.43.Sa 0.00000 0.00000
Week.43.Su 0.00000 0.00000
Week.44.M 0.00000 10.45440
Week.44.Tu 0.00000 10.45440
Week.44.W 0.00000 10.45440
Week.44.Th 0.00000 10.45440
Week.44.Fr 0.00000 10.45440
Week.44.Sa 0.00000 0.00000
Week.44.Su 0.00000 0.00000
Week.45.M 0.00000 10.51545
Week.45.Tu 0.00000 10.51545
Week.45.W 0.00000 10.51545
Week.45.Th 0.00000 10.51545
Week.45.Fr 0.00000 10.51545
Week.45.Sa 0.00000 0.00000
Week.45.Su 0.00000 0.00000
Week.46.M 0.00000 10.51545
Week.46.Tu 0.00000 10.51545
Week.46.W 0.00000 10.51545
Week.46.Th 0.00000 10.51545
Week.46.Fr 0.00000 10.51545
Week.46.Sa 0.00000 0.00000
Week.46.Su 0.00000 0.00000
Week.47.M 0.00000 10.51545
Week.47.Tu 0.00000 10.51545
Week.47.W 0.00000 10.51545
Week.47.Th 0.00000 10.51545
Week.47.Fr 0.00000 10.51545
Week.47.Sa 0.00000 0.00000
Week.47.Su 0.00000 0.00000
Week.48.M 0.00000 10.57650
Week.48.Tu 0.00000 10.57650
Week.48.W 0.00000 10.57650
Week.48.Th 0.00000 10.57650
Week.48.Fr 0.00000 10.57650
Week.48.Sa 0.00000 0.00000
Week.48.Su 0.00000 0.00000
Week.49.M 0.00000 10.62270
Week.49.Tu 0.00000 10.62270
Week.49.W 0.00000 10.62270
Week.49.Th 0.00000 10.62270
Week.49.Fr 0.00000 10.62270
Week.49.Sa 0.00000 0.00000
Week.49.Su 0.00000 0.00000
Week.50.M 0.00000 10.62270
Week.50.Tu 0.00000 10.62270
Week.50.W 0.00000 10.62270
Week.50.Th 0.00000 10.62270
Week.50.Fr 0.00000 10.62270
Week.50.Sa 0.00000 0.00000
Week.50.Su 0.00000 0.00000
Week.51.M 0.00000 10.62270
Week.51.Tu 0.00000 10.62270
Week.51.W 0.00000 10.62270
Week.51.Th 0.00000 10.62270
Week.51.Fr 0.00000 10.62270
Week.51.Sa 0.00000 0.00000
Week.51.Su 0.00000 0.00000
Week.52.M 0.00000 10.66890
Week.52.Tu 0.00000 10.66890
Week.52.W 0.00000 10.66890
Week.52.Th 0.00000 10.66890
Week.52.Fr 0.00000 10.66890
Week.52.Sa 0.00000 0.00000
Week.52.Su 0.00000 0.00000
Week.53.M 0.00000 10.69365
Week.53.Tu 0.00000 10.69365
Week.53.W 0.00000 10.69365
Week.53.Th 0.00000 10.69365
Week.53.Fr 0.00000 10.69365
Week.53.Sa 0.00000 0.00000
Week.53.Su 0.00000 0.00000
Week.54.M 0.00000 10.69365
Week.54.Tu 0.00000 10.69365
Week.54.W 0.00000 10.69365
Week.54.Th 0.00000 10.69365
Week.54.Fr 0.00000 10.69365
Week.54.Sa 0.00000 0.00000
Week.54.Su 0.00000 0.00000
Week.55.M 0.00000 10.69365
Week.55.Tu 0.00000 10.69365
Week.55.W 0.00000 10.69365
Week.55.Th 0.00000 10.69365
Week.55.Fr 0.00000 10.69365
Week.55.Sa 0.00000 0.00000
Week.55.Su 0.00000 0.00000
Week.56.M 0.00000 10.71840
Week.56.Tu 0.00000 10.71840
Week.56.W 0.00000 10.71840
Week.56.Th 0.00000 10.71840
Week.56.Fr 0.00000 10.71840
Week.56.Sa 0.00000 0.00000
Week.56.Su 0.00000 0.00000
Week.57.M 0.00000 10.86525
Week.57.Tu 0.00000 10.86525
Week.57.W 0.00000 10.86525
Week.57.Th 0.00000 10.86525
Week.57.Fr 0.00000 10.86525
Week.57.Sa 0.00000 0.00000
Week.57.Su 0.00000 0.00000
Week.58.M 0.00000 10.86525
Week.58.Tu 0.00000 10.86525
Week.58.W 0.00000 10.86525
Week.58.Th 0.00000 10.86525
Week.58.Fr 0.00000 10.86525
Week.58.Sa 0.00000 0.00000
Week.58.Su 0.00000 0.00000
Week.59.M 0.00000 10.86525
Week.59.Tu 0.00000 10.86525
Week.59.W 0.00000 10.86525
Week.59.Th 0.00000 10.86525
Week.59.Fr 0.00000 10.86525
Week.59.Sa 0.00000 0.00000
Week.59.Su 0.00000 0.00000
Week.60.M 0.00000 11.01210
Week.60.Tu 0.00000 11.01210
Week.60.W 0.00000 11.01210
Week.60.Th 0.00000 11.01210
Week.60.Fr 0.00000 11.01210
Week.60.Sa 0.00000 0.00000
Week.60.Su 0.00000 0.00000
Week.61.M 0.00000 10.53690
Week.61.Tu 0.00000 10.53690
Week.61.W 0.00000 10.53690
Week.61.Th 0.00000 10.53690
Week.61.Fr 0.00000 10.53690
Week.61.Sa 0.00000 0.00000
Week.61.Su 0.00000 0.00000
Week.62.M 0.00000 10.53690
Week.62.Tu 0.00000 10.53690
Week.62.W 0.00000 10.53690
Week.62.Th 0.00000 10.53690
Week.62.Fr 0.00000 10.53690
Week.62.Sa 0.00000 0.00000
Week.62.Su 0.00000 0.00000
Week.63.M 0.00000 10.53690
Week.63.Tu 0.00000 10.53690
Week.63.W 0.00000 10.53690
Week.63.Th 0.00000 10.53690
Week.63.Fr 0.00000 10.53690
Week.63.Sa 0.00000 0.00000
Week.63.Su 0.00000 0.00000
Week.64.M 0.00000 11.12100
Week.64.Tu 0.00000 11.12100
Week.64.W 0.00000 11.12100
Week.64.Th 0.00000 11.12100
Week.64.Fr 0.00000 11.12100
Week.64.Sa 0.00000 0.00000
Week.64.Su 0.00000 0.00000
Week.65.M 0.00000 11.10285
Week.65.Tu 0.00000 11.10285
Week.65.W 0.00000 11.10285
Week.65.Th 0.00000 11.10285
Week.65.Fr 0.00000 11.10285
Week.65.Sa 0.00000 0.00000
Week.65.Su 0.00000 0.00000
Week.66.M 0.00000 11.10285
Week.66.Tu 0.00000 11.10285
Week.66.W 0.00000 11.10285
Week.66.Th 0.00000 11.10285
Week.66.Fr 0.00000 11.10285
Week.66.Sa 0.00000 0.00000
Week.66.Su 0.00000 0.00000
Week.67.M 0.00000 11.10285
Week.67.Tu 0.00000 11.10285
Week.67.W 0.00000 11.10285
Week.67.Th 0.00000 11.10285
Week.67.Fr 0.00000 11.10285
Week.67.Sa 0.00000 0.00000
Week.67.Su 0.00000 0.00000
Week.68.M 0.00000 11.08470
Week.68.Tu 0.00000 11.08470
Week.68.W 0.00000 11.08470
Week.68.Th 0.00000 11.08470
Week.68.Fr 0.00000 11.08470
Week.68.Sa 0.00000 0.00000
Week.68.Su 0.00000 0.00000
Week.69.M 0.00000 11.19690
Week.69.Tu 0.00000 11.19690
Week.69.W 0.00000 11.19690
Week.69.Th 0.00000 11.19690
Week.69.Fr 0.00000 11.19690
Week.69.Sa 0.00000 0.00000
Week.69.Su 0.00000 0.00000
Week.70.M 0.00000 11.19690
Week.70.Tu 0.00000 11.19690
Week.70.W 0.00000 11.19690
Week.70.Th 0.00000 11.19690
Week.70.Fr 0.00000 11.19690
Week.70.Sa 0.00000 0.00000
Week.70.Su 0.00000 0.00000
Week.71.M 0.00000 11.19690
Week.71.Tu 0.00000 11.19690
Week.71.W 0.00000 11.19690
Week.71.Th 0.00000 11.19690
Week.71.Fr 0.00000 11.19690
Week.71.Sa 0.00000 0.00000
Week.71.Su 0.00000 0.00000
Week.72.M 0.00000 11.30910
Week.72.Tu 0.00000 11.30910
Week.72.W 0.00000 11.30910
Week.72.Th 0.00000 11.30910
Week.72.Fr 0.00000 11.30910
Week.72.Sa 0.00000 0.00000
Week.72.Su 0.00000 0.00000
Week.73.M 0.00000 11.09295
Week.73.Tu 0.00000 11.09295
Week.73.W 0.00000 11.09295
Week.73.Th 0.00000 11.09295
Week.73.Fr 0.00000 11.09295
Week.73.Sa 0.00000 0.00000
Week.73.Su 0.00000 0.00000
Week.74.M 0.00000 11.09295
Week.74.Tu 0.00000 11.09295
Week.74.W 0.00000 11.09295
Week.74.Th 0.00000 11.09295
Week.74.Fr 0.00000 11.09295
Week.74.Sa 0.00000 0.00000
Week.74.Su 0.00000 0.00000
Week.75.M 0.00000 11.09295
Week.75.Tu 0.00000 11.09295
Week.75.W 0.00000 11.09295
Week.75.Th 0.00000 11.09295
Week.75.Fr 0.00000 11.09295
Week.75.Sa 0.00000 0.00000
Week.75.Su 0.00000 0.00000
Week.76.M 0.00000 10.87680
Week.76.Tu 0.00000 10.87680
Week.76.W 0.00000 10.87680
Week.76.Th 0.00000 10.87680
Week.76.Fr 0.00000 10.87680
Week.76.Sa 0.00000 0.00000
Week.76.Su 0.00000 0.00000
Week.77.M 0.00000 10.91805
Week.77.Tu 0.00000 10.91805
Week.77.W 0.00000 10.91805
Week.77.Th 0.00000 10.91805
Week.77.Fr 0.00000 10.91805
Week.77.Sa 0.00000 0.00000
Week.77.Su 0.00000 0.00000
Week.78.M 0.00000 10.91805
Week.78.Tu 0.00000 10.91805
Week.78.W 0.00000 10.91805
Week.78.Th 0.00000 10.91805
Week.78.Fr 0.00000 10.91805
Week.78.Sa 0.00000 0.00000
Week.78.Su 0.00000 0.00000
Week.79.M 0.00000 10.91805
Week.79.Tu 0.00000 10.91805
Week.79.W 0.00000 10.91805
Week.79.Th 0.00000 10.91805
Week.79.Fr 0.00000 10.91805
Week.79.Sa 0.00000 0.00000
Week.79.Su 0.00000 0.00000
Week.80.M 0.00000 10.95930
Week.80.Tu 0.00000 10.95930
Week.80.W 0.00000 10.95930
Week.80.Th 0.00000 10.95930
Week.80.Fr 0.00000 10.95930
Week.80.Sa 0.00000 0.00000
Week.80.Su 0.00000 0.00000
Week.81.M 0.00000 10.97910
Week.81.Tu 0.00000 10.97910
Week.81.W 0.00000 10.97910
Week.81.Th 0.00000 10.97910
Week.81.Fr 0.00000 10.97910
Week.81.Sa 0.00000 0.00000
Week.81.Su 0.00000 0.00000
Week.82.M 0.00000 10.97910
Week.82.Tu 0.00000 10.97910
Week.82.W 0.00000 10.97910
Week.82.Th 0.00000 10.97910
Week.82.Fr 0.00000 10.97910
Week.82.Sa 0.00000 0.00000
Week.82.Su 0.00000 0.00000
Week.83.M 0.00000 10.97910
Week.83.Tu 0.00000 10.97910
Week.83.W 0.00000 10.97910
Week.83.Th 0.00000 10.97910
Week.83.Fr 0.00000 10.97910
Week.83.Sa 0.00000 0.00000
Week.83.Su 0.00000 0.00000
Week.84.M 0.00000 10.99890
Week.84.Tu 0.00000 10.99890
Week.84.W 0.00000 10.99890
Week.84.Th 0.00000 10.99890
Week.84.Fr 0.00000 10.99890
Week.84.Sa 0.00000 0.00000
Week.84.Su 0.00000 0.00000
Week.85.M 0.00000 10.87020
Week.85.Tu 0.00000 10.87020
Week.85.W 0.00000 10.87020
Week.85.Th 0.00000 10.87020
Week.85.Fr 0.00000 10.87020
Week.85.Sa 0.00000 0.00000
Week.85.Su 0.00000 0.00000
Week.86.M 0.00000 10.87020
Week.86.Tu 0.00000 10.87020
Week.86.W 0.00000 10.87020
Week.86.Th 0.00000 10.87020
Week.86.Fr 0.00000 10.87020
Week.86.Sa 0.00000 0.00000
Week.86.Su 0.00000 0.00000
Week.87.M 0.00000 10.87020
Week.87.Tu 0.00000 10.87020
Week.87.W 0.00000 10.87020
Week.87.Th 0.00000 10.87020
Week.87.Fr 0.00000 10.87020
Week.87.Sa 0.00000 0.00000
Week.87.Su 0.00000 0.00000
Week.88.M 0.00000 10.74150
Week.88.Tu 0.00000 10.74150
Week.88.W 0.00000 10.74150
Week.88.Th 0.00000 10.74150
Week.88.Fr 0.00000 10.74150
Week.88.Sa 0.00000 0.00000
Week.88.Su 0.00000 0.00000
Week.89.M 0.00000 10.80420
Week.89.Tu 0.00000 10.80420
Week.89.W 0.00000 10.80420
Week.89.Th 0.00000 10.80420
Week.89.Fr 0.00000 10.80420
Week.89.Sa 0.00000 0.00000
Week.89.Su 0.00000 0.00000
Week.90.M 0.00000 10.80420
Week.90.Tu 0.00000 10.80420
Week.90.W 0.00000 10.80420
Week.90.Th 0.00000 10.80420
Week.90.Fr 0.00000 10.80420
Week.90.Sa 0.00000 0.00000
Week.90.Su 0.00000 0.00000
Week.91.M 0.00000 10.80420
Week.91.Tu 0.00000 10.80420
Week.91.W 0.00000 10.80420
Week.91.Th 0.00000 10.80420
Week.91.Fr 0.00000 10.80420
Week.91.Sa 0.00000 0.00000
Week.91.Su 0.00000 0.00000
Week.92.M 0.00000 10.86690
Week.92.Tu 0.00000 10.86690
Week.92.W 0.00000 10.86690
Week.92.Th 0.00000 10.86690
Week.92.Fr 0.00000 10.86690
Week.92.Sa 0.00000 0.00000
Week.92.Su 0.00000 0.00000
Week.93.M 0.00000 10.89000
Week.93.Tu 0.00000 10.89000
Week.93.W 0.00000 10.89000
Week.93.Th 0.00000 10.89000
Week.93.Fr 0.00000 10.89000
Week.93.Sa 0.00000 0.00000
Week.93.Su 0.00000 0.00000
Week.94.M 0.00000 10.89000
Week.94.Tu 0.00000 10.89000
Week.94.W 0.00000 10.89000
Week.94.Th 0.00000 10.89000
Week.94.Fr 0.00000 10.89000
Week.94.Sa 0.00000 0.00000
Week.94.Su 0.00000 0.00000
Week.95.M 0.00000 10.89000
Week.95.Tu 0.00000 10.89000
Week.95.W 0.00000 10.89000
Week.95.Th 0.00000 10.89000
Week.95.Fr 0.00000 10.89000
Week.95.Sa 0.00000 0.00000
Week.95.Su 0.00000 0.00000
Week.96.M 0.00000 10.91310
Week.96.Tu 0.00000 10.91310
Week.96.W 0.00000 10.91310
Week.96.Th 0.00000 10.91310
Week.96.Fr 0.00000 10.91310
Week.96.Sa 0.00000 0.00000
Week.96.Su 0.00000 0.00000
Week.97.M 0.00000 10.83885
Week.97.Tu 0.00000 10.83885
Week.97.W 0.00000 10.83885
Week.97.Th 0.00000 10.83885
Week.97.Fr 0.00000 10.83885
Week.97.Sa 0.00000 0.00000
Week.97.Su 0.00000 0.00000
Week.98.M 0.00000 10.83885
Week.98.Tu 0.00000 10.83885
Week.98.W 0.00000 10.83885
Week.98.Th 0.00000 10.83885
Week.98.Fr 0.00000 10.83885
Week.98.Sa 0.00000 0.00000
Week.98.Su 0.00000 0.00000
Week.99.M 0.00000 10.83885
Week.99.Tu 0.00000 10.83885
Week.99.W 0.00000 10.83885
Week.99.Th 0.00000 10.83885
Week.99.Fr 0.00000 10.83885
Week.99.Sa 0.00000 0.00000
Week.99.Su 0.00000 0.00000
Week.100.M 0.00000 10.76460
Week.100.Tu 0.00000 10.76460
Week.100.W 0.00000 10.76460
Week.100.Th 0.00000 10.76460
Week.100.Fr 0.00000 10.76460
Week.100.Sa 0.00000 0.00000
Week.100.Su 0.00000 0.00000
Week.101.M 0.00000 10.01055
Week.101.Tu 0.00000 10.01055
Week.101.W 0.00000 10.01055
Week.101.Th 0.00000 10.01055
Week.101.Fr 0.00000 10.01055
Week.101.Sa 0.00000 0.00000
Week.101.Su 0.00000 0.00000
Week.102.M 0.00000 10.01055
Week.102.Tu 0.00000 10.01055
Week.102.W 0.00000 10.01055
Week.102.Th 0.00000 10.01055
Week.102.Fr 0.00000 10.01055
Week.102.Sa 0.00000 0.00000
Week.102.Su 0.00000 0.00000
Week.103.M 0.00000 10.01055
Week.103.Tu 0.00000 10.01055
Week.103.W 0.00000 10.01055
Week.103.Th 0.00000 10.01055
Week.103.Fr 0.00000 10.01055
Week.103.Sa 0.00000 0.00000
Week.103.Su 0.00000 0.00000
[R-sig-dyn-mod] parameter estimation with simecol FitOdeModel function when using lapply function with an odeModel?
2 messages · Thompson, Zachary, Thomas Petzoldt
Hi Zachary, thank you for opening the discussion on this new mailing list -- congratulations! On the other hand, however, your mail consists of several questions (some of them quite specific), so please don't expect comprehensive answers or a fully functional code. In general, it helps if you ask one question after another, together with *minimal* and *reproducible* examples that isolate the problem. The following short notes may help you to proceed step by step.
Thompson, Zachary wrote:
Hello, I am having a difficult time trying to understand what I need to do to include parameter estimation in my program. I am trying to use the fitOdeModel function from the simecol package. Currently my output is a list of data frames because I use an lapply function call on the data and the odemodel. Some advise I was given was to make my model and the lapply function together into an object with the class "simObj", without the out(sim()) call, is this possible? Then I could use that in the FitOdeModel function.
This is a rather specific idea, but yes, it is possible to create something like a compound model object that consists of a series of scenarios. However, I would not recommend this for your problem.
Are there any suggestions about how to link my model through the lapply function to the parameter estimation function FitOdeModel?
In principle yes, a "compound object", but I think it is much easier to use optim directly or the optimization routines from the FME package.
I know the observer slot "generally" does not work with Odemodels but is there a way to use it in my case please see code below.
No, the "observer" slot is intended for something totally different.
Can I hold all the results until all the lapply function uses all the input columns, and then return the data in a data frame? If I would try this I suppose I would have to put these statements into the function that my lapply function calls and not the odemodel???
In principle yes. Then use standard optimizers (or FME routines as described in the FME vignette) to fit the parameters. You can convert the list of lists returned by lapply: outsim <- lapply(x.all[c(2,17)], f2test) with: do.call(rbind, lapply(outsim, data.frame)) to a unique data frame.
Is it possible to put the apply function into the MAIN function of my odeModel and change the input to the complete dosing data set? This way I could simply insert the odeModel into the FitOdeModel function???
This is not appropriate here. The main function in class odeModel is the derivative of the ODE, and not intended to hold a series of different scenarios. My suggestion, make it simple: 1) put the "lapply" as it is in a function that returns a data frame, matrix or even a vector of data corresponding to the structure of your measured data (see above). 2) write a second function "cost" that returns a goodness of fit criterion, e.g. sum of squares between simulation and data (or use modCost from FME). 3) use optim or nlminb (or the FME package) to fit your parameters by using this cost function. Sometimes it may help to start with a toy example before working with your full model and data set. Thomas P.