I wish to fit a dynamical model in R and I am running in a problem that 
requires some of your wisdom to solve. For SAS users I am searching for 
the equivalent of the retain statement.

For people that want to read complicated explanations to help me:

I have a system of two equations written as difference equations here.

To boil it down. I have a dataframe with three variables y, X1, X2 which 
are measured. Now, I want to estimate a model which says y= 
yhat+epsillon as in standard nonlinear regression. Where yhat is the 
predicted value of y.

yhat can be calculated as follows:

# This code illustrates how I could simulate the expected values of y if 
I knew the values of the parameters tau and b.
# but in reality I would like to estimate them.
# code is for illustration of the principles and is not meant to be 
functional!!
yaux[1]<-0
b<- a_number # b would have to become estimated by nls or nlme
tau<- another_number # tau would also be estimated in nls or nlme
for (t in 2:1000)
{
yaux[t+1] <- yaux[t] + (X1-yaux[t])/tau
yhat[t+1] <- yaux[t+1]*X2[t+1]/(X2[t+1]+b)
}

Now, my problem is that I do not know the values of /tau/ and /b/ and I 
would like to estimated them by non-linear regression. This is easy in 
the case of /b/ but for /tau /nls (or nlme etc) would have to remember 
the value of /yaux /for the previous observation and I did not find any 
syntactical mean to do that.



	[[alternative HTML version deleted]]

