Objective function, Jacobian matrix (definitions for logistic curve fitting problem)

f[t_]:=(x0/((1-x0/k)(E^(-r t))+x0/k));
values={0.04,0.35,1.05,1.9,1.98,1.97,1.99,1.999};
resid[p_]:=(f[Range[0,7,1]]-values)/.{r->p[[1]],x0->p[[2]],k->p[[3]]};
plot1=ListPlot[Transpose[{Range[0,7,1],values}],PlotMarkers->●]

J[p_]:=Transpose[ArrayFlatten[{D[f[Range[0,7,1]]-values,r],D[f[Range[0,7,1]]-values,x0],
D[f[Range[0,7,1]]-values,k]}]]/.{r->p[[1]],x0->p[[2]],k->p[[3]]}//N;

Levenberg--Marquardt

pOld={10,10,10};
pNew={1,1,1};
tol=(10^(-6));
iter=0;
maxIter=100;
μ=1;
lastStepAccepted=True;
residuals={};
While[(Norm[pOld-pNew]>tol||lastStepAccepted==False) && iter<maxIter,
pOld=pNew;
Δp=LeastSquares[Flatten[{J[pOld],(Sqrt[μ])IdentityMatrix[3]},1],Flatten[{-resid[pOld], Table[0,{3}]},1]];
If[Norm[resid[pOld+Δp],2]<Norm[resid[pOld],2],
pNew=pOld+ Δp;
μ/=3;
lastStepAccepted=True,
μ*=2;
lastStepAccepted=False
];
Print[lastStepAccepted];
AppendTo[residuals, Norm[resid[pNew[[1]],pNew[[2]],pNew[[3]]],2]];
iter++
]
pNew
iter

ListLogPlot[residuals,PlotRange->All]