Fitting PVT data to an implicit equation

I'm trying to determine values of 3 parameters (named ts, ps, and rhos) by fitting some experimental data to an implicit non-linear equation. I have 10 experimental data in the form of {t,p,rho} which I define as:

data = {{350,20,1.95},{360,20,1.93},{370,40,1.94},{380,40,1.93},{390,60,1.95},{400,60,1.94},{410,80,1.95},{420,80,1.94},{430,100,1.95},{440,100,1.94}}

Then I insert my fit function as:

fitfunc[ts_?NumericQ, ps_?NumericQ, rhos_?NumericQ, t_?NumericQ, p_?NumericQ]:=rho/.FindRoot[(Log[1-(rho/rhos)])+(((rho/rhos)^2)/(t/ts))+((p/ps)/(t/ts))+(rho/rhos)==0,{rho, 1}]

In final step FindFit is used as:

FindFit[data, fitfunc[ts, ps, rhos, t, p], {ts, ps, rhos}, {t, p}]

when I execute this command I just get :

FindFit[{{350,20,1.95},{360,20,1.93},{370,40,1.94},{380,40,1.93}, {390, 60, 1.95}, {400, 60, 1.94}, {410, 80, 1.95}, {420, 80,1.94}, {430, 100, 1.95}, {440,100, 1.94}},fitfunc[ts, ps, rhos, t, p], {ts, ps, rhos}, {t, p}]

I can't figure out what I'm doing wrong. I'd really appreciate it if anyone could help me on the matter. thanks.

• The problem with your approach is the function fitfun[] , which only returns a value and isn't recognized by FindFit as a parametric model. I think it is much easier if you solve your model equation for t (analytical). What are the known constrictions concerning your parameter, for example rho?>?rhos ... Commented Jan 10, 2018 at 14:56

You can solve your problem in this way:

modelt = t /.Solve[ Log[1 - rho/rhos] + (rho/rhos)^2/(t/ts) + p/((ps t)/ts) +rho/rhos == 0, t][[1]]

modelt is "the model t==function[{ps, ts,rhos,t,rho] " you want to fit with your data.

J = Total@Map[(p = #[[2]]; rho = #[[3]]; (modelt - #[[1]])^2 ) &, data(*t,p,\[Rho]*)];

J is the functional you want to minimze.

NMinimize minimizes J and constraint rhos>=... :

NMinimize[{J, rhos >= Min[data[[All, 3]]] (* \[Rho]min*)}, {ps, ts,rhos}]
(* {51.49, {ps -> 408.607, ts -> 514.079, rhos -> 2.22915}} *)
• First of all, thank u very much for taking the time. I actually tried this problem as an excersise, knowing my variables, I wanted to repeat them again. my three varables have the values of ts=550, ps=400 and rhos=2.19 which your solution almost predicted them with good accuracy. My real problem has a set of 200 pvt data. Commented Jan 11, 2018 at 13:16
• and unfortunately I don't have any constrictions regarding my parameters. Since I'm new to mathematica, could you walk me through your solution? I'm not getting why your solution works. and do you have any suggestion to make the answers more accurate? thanks again Commented Jan 11, 2018 at 13:29
• I edited my answer a little bit. Feel free to ask! Commented Jan 11, 2018 at 13:49