Hello there !

I just have started programming and Julia these days, and I am trying fitting curve (dose response) by Optim.jl

But I can’t obtain better parameters and predictions (the all predictions have same value eventhough I use parameters that are calculated by optimize()) .

So, I would like you to tell me which is/are wrong and how to fix it.

I just have started programming and Julia

Here is my codes;

```
xdata = [0.1, 0.3, 1.0, 3.0, 10.0]
ydata = [138.48, 150.23, 192.14, 199.78, 233.76]
xbase = collect(range(minimum(xdata), maximum(xdata), 100))
@. DoseRes(x, p) = p[1] + ((p[2] - p[1]) / (1 + 10 ^ ((p[3] - x) * p[4])))
function cost(x, y, p)
err = 0.0
for i in 1:length(x)
err = sum(abs2(y[i] - DoseRes(x[i], p...))) / (2 * length(x))
end
return err
end
result = optimize(p -> cost(xdata, ydata, p), [0.0, 0.0, 0.0, 0.0])
pbest = Optim.minimizer(result)
DoseRes(xbase, pbest)
```

result is like this;

```
100-element Vector{Float64}:
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
233.75995328637563
⋮
```