Wolfram Function Repository
Instantuse addon functions for the Wolfram Language
Function Repository Resource:
Fit multiple datasets with multiple expressions that share parameters
ResourceFunction["MultiNonlinearModelFit"][{dat_{1},dat_{2},…},{form_{1},form_{2},…},{β_{1},…},{x_{1},…}] is a generalized form of NonlinearModelFit where each dataset dat_{i} is fitted with expression form_{i}. The expressions are allowed to share parameter values β_{i} with each other. 

ResourceFunction["MultiNonlinearModelFit"][{dat_{1},dat_{2}, …}, <"Expressions"→{form_{1},form_{2},…}, "Constraints"→cons >, {β_{1},…},{x_{1},…}] fits the model subject to parameter constraints cons. 
Fit some random data to simple linear models with shared slope parameter:
In[1]:= 

Out[3]= 

In[4]:= 

Out[4]= 

Fit two Gaussian peaks with a shared location parameter:
In[5]:= 

Out[6]= 

Fit with the models that were used to generate the data:
In[7]:= 

Out[7]= 

In[8]:= 

Out[8]= 

Extract the fits as a list of expressions:
In[9]:= 

Out[9]= 

Compare the fits to the data:
In[10]:= 

Out[10]= 

The Weights option can be specified in a number of ways:
First generate datasets with an unequal number of points and offset them slightly:
In[11]:= 

Out[16]= 

Fit the data normally. In this case, each individual data point has equal weights in the fit, so the first dataset gets more weight overall since it has more points:
In[17]:= 

Out[18]= 

In[19]:= 

Out[19]= 

Assign more weight to the second dataset:
In[20]:= 

Out[21]= 

In[22]:= 

Out[22]= 

Assign weights inversely proportional to the number of points in the dataset. This asserts that each dataset is equally important:
In[23]:= 

Out[24]= 

In[25]:= 

Out[25]= 

To assign weights for each individual data point, you can pass a list of vectors matching the input data:
In[26]:= 

Out[27]= 

In[28]:= 

Out[28]= 

Use a different symbol to index the datasets:
In[29]:= 

Out[30]= 

In[31]:= 

Out[31]= 

This work is licensed under a Creative Commons Attribution 4.0 International License