I'm learning to do nonlinear square fit with R, and I followed this tutorial:
p = function(x) x^3+2*x^2+5
x = seq(-0.99, 1, by = .01)
y = p(x) + runif(200)
df = data.frame(x = x, y = y)
head(df)
x y
1 -0.99 6.183018
2 -0.98 6.611669
3 -0.97 6.762615
4 -0.96 6.594278
5 -0.95 5.990637
6 -0.94 6.048369
# Then the author conducted a nonlinear regression fit.
fit = nls(y~a*x^2+b*x, data = df, start(a=0, b=0))
But when I try to run the code, it always says "Error in hasTsp(x) : argument "x" is missing, with no default"
Does anyone know where the problem is?
Thank you so much!