I have a growth rate model:
model <- nls(Length~a*exp(-b*exp(-c*Age)), data=df, start=list(a=160,b=0.5, c=0.1))
> summary(model)
Formula: Length ~ a * exp(-b * exp(-c * Age))
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 173.03146 12.68100 13.645 < 2e-16 ***
b 0.54255 0.06118 8.868 9.94e-15 ***
c 0.13961 0.04195 3.328 0.00117 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 13.73 on 117 degrees of freedom
Number of iterations to convergence: 12
Achieved convergence tolerance: 7.693e-06
(4 observations deleted due to missingness)
and I now want to apply this to a separate dataset, for which I have LENGTH data but not AGE. i.e. I want to predict age (my independent variable in the model) from length (dependent variable). Is this possible?
I would like predicted age to appear as a new column in my dataset so I have a corresponding predicted age for each measured length. I feel like this will be something like:
df2$age.predict <- predict(model, newdata=data.frame(Length=df2$Length))
but I know this isn't right and I don't want to create a new dataframe/list I want it to appear as a column in my df2.
TIA
