[R] nls model definition help

S Ellison S.Ellison at lgcgroup.com
Thu Oct 24 14:54:26 CEST 2013

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Wayne.W.Jones at shell.com
> Sent: 22 October 2013 18:52
> To: R-help at r-project.org
> Subject: [R] nls model definition help
> Hi fellow R users,
> I'm trying to fit a model using nls with the following model
> definition:
> y(t+1)=(th1*x1 + R1*x2) * exp(a1*x3) + (1-th1*x1 + R1*x2)*y(t)
> ...
> Any ideas if this is achievable and if not any ideas on how to fit this
> model?
I'm thinking not, as you have that (t+1) back-reference in there which makes the calculated y(t) part of the expression. Pretty sure nlm won't handle that in the formula interface. 

However, you could use nlm or optim if you write a function to predict y and then wrap that in a function to calculate the residual sum of squares (taking the parameter vector and y[obs] as parameters), then minimise the residual SS. The hessian from either can then be used to estimate standard errors using the usual least-squares formulae.

S Ellison

This email and any attachments are confidential. Any use...{{dropped:8}}

More information about the R-help mailing list