[R] Estimating model parameters for system of equations

Arne Henningsen arne.henningsen at googlemail.com
Tue Nov 15 20:17:20 CET 2011

Dear Louise

On 15 November 2011 19:03, lstevenson <louise.stevenson at lifesci.ucsb.edu> wrote:
> Hi all,
> I'm trying to estimate model parameters in R for a pretty simple system of
> equations, but I'm having trouble.  Here is the system of equations (all
> derivatives):
> eqAlgae <- (u_Amax * C_A) * (1 - (Q_Amin / Q_A))
> eqQuota <- (p_max * R_V) / (K_p + R_V) - ((Q_A-Q_Amin)*u_Amax)
> eqResource <- -C_A * (p_max * R_V) / (K_p + R_V)
> eqSystem <- list(C_A = eqAlgae, Q_A = eqQuota, R_V = eqResource)
> I want to estimate u_Amax, Q_Amin, p_max and Q_Amin with the data I've
> collected using least squares. I've tried using systemfit but I'm not sure
> how to write out the equations (my attempt is above but that doesn't work
> since I haven't given values to the parameters I'm trying to estimate -
> should I give those parameters initial values?). I've looked into the other
> functions to get least squares estimates (e.g. lm() ) but I'm not sure how
> to use that for a system of equations. I have some experience with R but I'm
> a novice when it comes to parameter estimation, so any help would be much
> appreciated! Thank you!

Your system of equations is non-linear in parameters. As lm() and
systemfit() can only estimate models that are linear in parameters,
you cannot use these commands to estimate your model. The "systemfit"
package includes the function nlsystemfit() that is intended to
estimate systems of non-linear equations. However, nlsystemfit() is
still under development and often has convergence problems. Therefore,
I wouldn't use it for "serious" applications. You can estimate your
non-linear equations separately with nls(). If you want to estimate
your equations jointly, I am afraid that you either have to switch to
another software or have to implement the estimation yourself. You
could, e.g., minimize the determinant of the residual covariance
matrix with optim(), nlm(), nlminb(), or another optimizer or you
could maximize the likelihood function of the FIML model using
maxLik(). Sorry that I (and R) cannot present you a simple solution!

Best wishes from Copenhagen,

Arne Henningsen

More information about the R-help mailing list