2.7 Compare Linear Fit Parameters/Datasets


This app, Compare Linear Fit Parameters/Datasets is used to compare linear fit parameters for multiple datasets, i.e. slope and intercept, and determine whether they are different. The logic of parameter comparison in this tool is: if one wants to compare intercepts, slopes are compared first. If slopes are found different according to the criteria, intercept comparison will not be done. In other words, the precondition of intercept comparison is that slopes are considered to be same for all datasets. This app can also be used to compare datasets using a linear model.

Examples

  1. Install the app if you haven't, an icon "Compare Linear Fit Parameters and Datasets" will show in Apps panel.
  2. Import Linear Fit.dat in \Samples\Curve Fitting folder to a prepared worksheet.
  3. Highlight Col(A) to Col(C) in that worksheet, click the icon "Compare Linear Fit Parameters and Datasets" from the Apps panel to bring up the fitlrcmpara X-Function dialog. Select Parameters for Compare, check Akaike Information Criteria(AIC), F-test and General Linear Model for Method, make sure the Intercept checkbox is checked. The complete setting can be seen from the graph below:
    Compare Linear Fits Parameters Dialog Setting.png
  4. Click OK, the report should look like:
    Compare Linear Fits Parameters Report 28Ftest 29.png
    It can be seen that for this example, both slope and intercept are same in both methods.

Dialog Settings

Input Data

Specify datasets for linear fit comparison of parameters/datasets.

Fit Control

Fix Intercept Specify whether to fix the intercept in linear fit. If intercept is fixed, Intercept in Parameters to Compare branch will be hidden.
Fix Intercept At Specify the value of the fixed intercept.
Fix Slope Specify whether to fix the slope in linear fit. If slope is fixed, Slope in Parameters to Compare branch will be hidden.
Fix Slope At Specify the value of the fixed slope.

Settings

Compare Specify what to compare.
  • Datasets
    Compare datasets using a linear model
  • Parameters
    Compare linear fit parameters
Method Specify the comparison algorithm.
  • Akaike Information Criteria(AIC)
    Comparison conclusion is made according to Akaike's weight.
  • F-test
    Comparison conclusion is made according to P-value.
  • General Linear Model
    Option will show for Compare Parameters if there are 2 datasets. It compare slope or both slope and intercept.
Compare Pairwise Option Compare Pairwise will show if there are more than 2 datasets. If checked, and the result between datasets is different, then pairwise comparison will be analyzed and output the Pairwise Comparison table:
Compare Pairwise Report.png

Parameters to Compare

This branch is only available when Parameters is selected for Compare in Settings branch.

Slope Specify whether to compare slope.
Intercept Specify whether to compare intercept. If this is checked and Fix Slope is not checked, Slope will be checked and disabled.

Additional Outputs

Specify whether to output fitting tables.

Fit Parameters Decide whether to output Fit Parameters table for each dataset.
Fit Statistics Decide whether to output Fit Statistics table for each dataset.

Results

Specify the output report worksheet for the comparison result.

Algorithm

When comparing one specific parameter (or datasets), we are actually comparing two models. For one model, the parameter values can vary among different datasets, this is the more complicated model. For the other, the parameter values are assumed to be same for all datasets, this is the simpler model. When comparing slopes, the more complicated model corresponds to independent fit for each dataset and the simpler model corresponds to global fit with slope shared. When comparing intercepts, the situation is a little different. As stated at the beginning of this document, we compare intercepts only when we have compared slopes and concluded that they are same. So the more complicated model for comparing intercept corresponds to the simpler model for comparing slope. The simpler model for comparing intercept corresponds to a line function with all parameters shared in all datasets, i.e. concatenate fit.

When comparing datasets using a linear fit model, the more complicated model corresponds to independent linear fit for each dataset while the simpler model corresponds to a line function with all parameters shared in all datasets.

Akaike Information Criteria(AIC)

For each model, Origin calculates the AIC value by:
AIC=\left\{\begin{matrix}
N\ln(\frac{RSS}{N})+2K & \mbox{when} \ \frac{N}{K}\geq 40\\ 
N\ln(\frac{RSS}{N})+2K+ \frac{2K(K+1)}{N-K-1} & \mbox{when} \ \frac{N}{K}< 40
\end{matrix}\right.

where RSS is residual sum of squares for that model, N is the number of data points, K is the number of parameters.

For two fitting models, the one with the smaller AIC value is suggested to be a better model for the datasets, and then we can determine whether parameter values to be compared are same.

We can also make decisions based on the Akaike's weight value, which can be computed as:
w_{i}=\frac{e^{-0.5AIC_{i}}}{e^{-0.5AIC_{1}}+e^{-0.5AIC_{2}}} \ i=1,2
w_{1}+w_{2}=1 \qquad 0<w_{1},w_{2}<1
Here i=1 represents the simpler model and i=2 represents the more complicated model. AIC_{1} and AIC_{2} are the AIC values of the two fitting models, respectively.
If w_{1} is larger than w_{2}, we can conclude that parameter values to be compared are same, otherwise parameter values are different.

F-test

Suppose the sum of RSS and the sum of df (degrees of freedom) of the simpler model fit are RSS_{1}, df_{1} and those of the more complicated model fit are RSS_{2}, df_{2}.

We can compute the F value by:
F=\frac{(RSS_{1}-RSS_{2})/(df_{1}-df_{2})}{RSS_{2}/df_{2}}

Once the F value is computed, Origin calculates the P-value by:

P=1-fcdf(F,df_{1}-df_{2},df_{2})

This P-value can be used to determine whether parameter values to be compared are different. If the P-value is greater than 0.05, we can conclude that parameter values to be compared are not significantly different.

General Linear Model test

The General Linear Model method fits a general linear model to the concatenated dataset and checks the fitted parameters to determine the significance of the differences in slopes and intercepts. The method concatenates the two groups of xy datasets (x_{c}, y) and includes a categorical variable (x_{f}) that identifies each group.

A general linear model with the interaction term x_{c}*x_{f} is fitted to the dataset:

y = \beta_{0} + \beta_{1}x_{c} + \beta_{2}x_{f} + \beta_{3}x_{c}*x_{f}  + \epsilon

The significance of the slope difference is determined by the T-test of the x_{c}*x_{f} term in the model.

If the slope difference is not significant, the test of the difference in intercepts can be performed. A general linear regression model without the interaction term xc*xf is fitted to the dataset:

y = \beta_{0} + \beta_{1}x_{c} + \beta_{2}x_{f} + \epsilon

The significance of the intercept difference is determined by the T-test of x_{f} in the model.