Message Boards Message Boards


[Solved] Strategy to fit parameters to dataset?

Posted 2 months ago
3 Replies
1 Total Likes

The Issue: I am currently trying to fit 2 parameters to a set of data, but am struggling to set up the code. I will show the code here and explain issues below.

Code: ( I can paste a text version)enter image description here

My end goal is to fit the equation 'int' to a set of data 'data4' in order to fit values for k1 and k2. In equation int, ExpGrowth is a constant and rate is an equation that depends on functions a[t] and b[t], which I am trying to solve using a system of equations.
I do not understand how to fit int to data4 since int depends on the functions a[t] and b[t], which can only be solved with k1 and k2 entered using NDSolve, which then makes fitting impossible. I can use ParametricNDSolveValue to extract estimates for k1 and k2 from data4, but the fit coming from ParametricNDSolveValue is not for int and a[t] and b[t] are no longer solved in the way that NDSolve was, so fitting is again impossible. I tried entering int into the system of equations along with int[0]=ExpGrowth as the boundary conditions, but this threw errors. I am not sure which of (Parametric)NDSolve(Value) commands I should be using to fit int, so any help with setting this up would be great.

Thanks in advance for anyone who is able to help. I can give more information if needed.

3 Replies
Posted 2 months ago

I searched and didn't find a question or answer like what you are looking for.

But I did a broader search and think I might have found something that may help you.

Look at the first answer to this question

FindFit error when fitting a parametric function to data

You can scrape and paste the code from that into your notebook and should be able to verify, as I just did, that that code still works. It is fitting three parameters in two DE to some data points.

If you are very careful and you translate your problem into exactly the same form then I think this might give you the solution that you are looking for and you can get your work done.

Posted 2 months ago

Hi Bill, Thanks for the comment. This was able to get me to a point where I could actually fit the data and from there I was able to fine-tune the rest and get what I needed.

Welcome to Wolfram Community! Please make sure you know the rules:

For your future posts. The rules explain how to format your code properly. Images don't help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

enter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract