New answers tagged

0

One actually doesn't need fancy packages to fit complex data, as simple least-squares, with a small modification, will suffice. In this case we can define a $\chi^2$ as $$ \chi^2=V^\dagger V,$$ where the $\dagger$ is the conjugate transpose and the vector $V^i$ is given by $$V^i=y^i-model(x^i).$$ This can be translated to Mathematica as follows: model[fr_, ...


1

With pfun from @domen's answer , NonlinearModelFit allows to implement several constraints and evaluates an answer (Method -> "NMinimize" doesn't need starting values) NonlinearModelFit[data, {pfun[alpha, R0, gamma,r][x], alpha > 0, 0 < gamma < 1, R0 > 0, r > 0}, {alpha , R0, gamma, r}, x, Method -> "NMinimize"] ...


1

Apart from @Michael's solution, you can also provide an extra algebraic equation in your system of ODEs: pfun = ParametricNDSolveValue[{ Ii[1.] + S[1.] + R[1.] + F[1.] == 1411780000, S'[x] == -R0*F[x]/alpha, R'[x] == gamma*Ii[x], Ii'[x] == F[x]/alpha + r*F[x] - gamma*Ii[x], F'[x] == -F[x]/alpha + R0*F[x]/alpha - r*F[x], Ii[1.] == 1900, ...


0

The error seems to arise from the fact that you're using ParametricNDSolve to return a result for the anonymous function R + Ii + F, rather than a single anonymous function. This means that when you provide this object with a set of parameters, it returns something of the form (InterpolatingFunction[data] + InterpolatingFunction[data] +InterpolatingFunction[...


1

Just for fun, I devoted 30 seconds to modeling the data set ... Each dot represents a model and the ones in red define the ParetoFront exploring the trade-off of model complexity vs accuracy. Somewhat arbitrarily, I decided to focus on those models having a complexity less than 100 and an R2 better than 0.98. The models along the ParetoFront in this region ...


3

I have been a user of DataModeler from Evolved Analytics for more than 10 years that is mentioned just above. It will be one of products that match your need. It has a function called SymbolicRegression that creates approximate functions with genetic programming for optimization. I have been using it for the analysis in the medical field. I compared its ...


4

If you want to see how Symbolic Regression can be used from within Mathematica (Wolfram Language), you can check out my video here: https://www.youtube.com/watch?v=eMcBMvy_tlk. It's an EXTREMELY powerful product.


8

There is a commercial solution from www.evolved-analytics.com which also includes all of the surrounding functionality to actually extract the value from the data. The next version will be released in the next few days. Free trials are available as are academic versions. DataModeler is 100% Mathematica and one of the versions is an add-on package so all of ...


4

It's not necessary to give "good" starting values, you only need constraint a<0 together with NonlinearModelFitand option Method -> "NMinimize": modeln = 1/(x/T - a); fit = NonlinearModelFit[datan, {modeln, a < 0}, {a, T}, x, Method -> "NMinimize"] Show[{Plot[fit[x], {x, -2, 2}], ListPlot[datan]}] The second case ...


3

You need better starting values. Fortunately with your model one can make reasonable guesses from the scatter plot. ListPlot[datan, Frame -> True] (* When x=0, then a0 = -1/y *) a0 = -1/1.3 (* When x=2, then plug in a0 and solve for T *) T0 = T /. Solve[0.8 == 1/(2/T - a0), T][[1]] (* Define model and fit *) modeln = 1/(x/T - a); fit = FindFit[datan, ...


9

One needs to have a model (a predictive part and an error structure) to know what to do with the weights. If the weights are appropriate for the model, then one will tend to get better estimates of the parameters in the sense that the precision of the estimates will improve from not using weights. But one cannot judge the improvement just by looking at the ...


2

The usage of BSpline is simple: Just mix your points into the joint array ar1=SortBy[ Flatten[{ lengthscale1SB, lengthscale2SB, lengthscalemix1SB, lengthscalemix2SB, lengthscalemix3SB, lengthscalemix4SB, lengthscalemix5SB,1], First]; Draw it by BSplineCurve of desired order ListPlot[ar1, Frame -> True, PlotStyle -> Blue,...


Top 50 recent answers are included