[R-sig-dyn-mod] Model fitting in FME

Andras Farkas motyocska at yahoo.com
Tue Jul 8 22:40:34 CEST 2014


Dear All,

allow me to refer to the work by Soetaert and Laine from here: http://cran.r-project.org/web/packages/FME/vignettes/FMEmcmc.pdf, section 7. I have a data set I would like to establish the model for with equal model variance (similar scenario as 7.2 in the paper) and based on reading the article the methods in the paper seem to be reasonable to get the job done. My question is:

In the paper a model is fitted onto 2 sets of data, Obs, and Obs2, whereas I have data including 30 sets of Obs1, Obs2,...., Obs30. In the paper the function "Residuals" is set up as follows for the 2 sets:

Residuals <- function(p) {
cost <- modCost(model = Model(p, Obs$x), obs = Obs, x = "x")
modCost(model = Model(p, Obs2$x), obs = Obs2, cost = cost, x = "x")
 }


in order to accomodate my 30 sets, would it be reasobnable to set up the function as follows:

Residuals <- function(p) {
cost1 <- modCost(model = Model(p, Obs1$x), obs = Obs1, x = "x")
cost2 <-modCost(model = Model(p, Obs2$x), obs = Obs2, cost = cost1, x = "x")
cost3 <-modCost(model = Model(p, Obs3$x), obs = Obs3, cost = cost2, x = "x")
...
cost29 <-modCost(model = Model(p, Obs29$x), obs = Obs29, cost = cost28, x = "x")
modCost(model = Model(p, Obs30$x), obs = Obs30, cost = cost29, x = "x")
 }


this way the cost function is updated for each  of Obs2, Obs3,..., Obs30? This seems to be a bit of a complicated solution but will get it done if needed. Or are you aware of another published example perhaps I could use as the template to establish the model for the best fit line for the 30 sets of data?

your input is appreciated,

Andras



More information about the R-sig-dynamic-models mailing list