I am pretty new to R - and I can't find a good answer to this via googling, so I appreciate your help. I have data that, when plotted, shows a logarithmic curve. I modeled it as lm(y~log(x)):
logEstimate <- lm(d$MaxHt~log(d$StemDens))
coef(logEstimate)
(Intercept) log(Pycnan$TS)
51.37911 12.63334
I'd like to fit a curve from this model onto a plot of my original variables (x, y). I tried several different ways using curve(), but I kept getting error messages:
plot(d$MaxHt~d$StemDens)
curve(logEstimate, from=0, to=45, n=101, add=TRUE)
Error in logEstimate(x) : could not find function "logEstimate"
curve(51.37911+12.63334*log(d$StemDens), from=0, to=45, n=101, add=TRUE)
Error in curve(51.37911 + 12.63334 * log(Pycnan$TS), add = TRUE, col = 2) : 'expr' must be a function, or a call or an expression containing 'x'
I'm not sure how to make logEstimate a function. I'm also not sure if I am missing a step to back transform my coefficients before I try to fit them to a plot of the original data. Any advice would be greatly appreciated!