I can't figure out how to find the best fit for an inverse equation. I recorded data and the relationship of y and x should be y=a/x were a is the value I want.
I have tried lm() but can't figure out how it works. I also tried nls, but can't figure out how that works either.
data <- read.csv("./data.csv")
y <- data[["meanacceleration"]]
x <- data[["massadded"]]
u <- data[["uncertainty"]]
exponential.model <- nls(y ~ a/x, start = (a = 1))
print(cor(y, predict(exponential.model)))
print(summary(exponential.model))
xx <- seq(240,1000, length=1000)
# massadded.exponential2 <- exp(predict(exponential.model, list(x = xx)))
plot(x, y, xlab = "Total mass", ylab="Mean Acceleration",ylim = range(c(y-u,y+u)) , pch=16)
arrows(x, y-u, x, y+u, length=0.1, angle=90, code=3)
lines(xx, predict(exponential.model), lty=2,col="red",lwd=3)
The error I got was Error in mget(names(ind), env) : invalid first argument