I suggest to include a curve_fit function working with DataFrame objects. It could lead to more readable and less error prone model definitions.
Best regards
Andreas
# curve fit using DataFrame
# ycol: column Symbol for y-values in df
# model uses df and p as parameters e.g. "@. modLd(x,p) = p[3] + p[1]*x.cons_gas + p[2]*x.cons_oil"
function curve_fit(model,df::DataFrames.DataFrame,ycol::Symbol,p0;kwargs...)
# construct the cost function
T = eltype(df[!,ycol])
f = (p) -> model(df, p) - df[!,ycol]
lmfit(f, p0, T[]; kwargs...)
end
Hello,
I suggest to include a curve_fit function working with DataFrame objects. It could lead to more readable and less error prone model definitions.
Best regards Andreas