I am trying to implement state-space models in a large time series data set. This time series incudes six species across 21 sites over 25+ years. I am looking for code examples to implement state-space models for stock-recruitment models. The only examples that I have found use time as the independent variable. However, recruitment is the independent variable in S-R models. Any help on implementing state-space models where density, not time, is the independent variable would be greatly appreciated. Please provide annotated code if possible.