How can I fit a curve of the type $$Y = aX^b$$ using R?
I'm able to fit a linear model (Y = aX + b) using
fit <- lm(y~x)
but my data requires Y = aX^b
nls(y ~ a*x^b, start = list(a = 1, b = 1), data = your_data)
, or lm(log(y) ~ log(x), data = your_data)
(these are different models but either might serve you; the parameters of the second model are log(a)
and b
). You might need to adjust the starting values to work with your data.