[R] Fitting a System of Difference Equations

From: Mark Orr <mo2259_at_columbia.edu>
Date: Tue, 17 Jun 2008 00:46:35 -0400


Hi R friends,

Iím interested in fitting data to the following system of difference equations:

Change in M = k*(1-M.prev)*(1-F.prev) + R*(1-M.prev)*F.pref Change in F = k*(1-F.prev)*(1-M.prev) + S*(1-F.prev)*M.pref

Parameters:
k, R, S, are transition rates

Variables:

M = Proportion of Males Sexually Active
F = Proportion of Females Sexually Active

M.prev and F.prev are the t-1 values of M and F.

The modeling of this in R is straightforward. However, Iíd like to fit the simulation to actual prevalence data such that Iím iteratively honing in on the three parameters, given my starting prevalence values, via some loss function. Iím thinking of using <nls> for this but in some way replacing the right side of the formula specification with a function that calls the system of equations. But, Iím not sure this will work and I donít know how to do this (Iíve done a thorough search on R and Google, without luck).

Any help or direction would be much appreciated.

Thanks.

Mark



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 17 Jun 2008 - 05:02:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Jun 2008 - 08:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive