How to do multiple linear regression in different combination of numbers?

5 views (last 30 days)
Good day everyone! This is what I'm trying to code: I have to analyze several mobility profiles from ion mobility spectrometry experiments. I do that by fitting gaussian curves to several data files I obtained. After the fitting, I get the position of the peaks (in the X-axis) in arrays like this:
a = [a1,a2,a3,...,an]
b = [b1,b2,b3,...,bn] and so on.
What I need is a way to do a linear regression on all the combinations of the numbers in the matrices:
e.g.
reg1 = [a1,b2,c3,...]
reg2 = [a2,b1,c1,...] to obtain the intercept of each one and select only one with the highest R^2 value.
I thought about nesting for loops, but the problem that I encounter is that I can have multiple arrays of data (from 5 to 20) with an unknown number of positions on each array. The linear regressions can have only one number from each array.
Currently I'm not using any toolbox.
Thanks in advance for you help!
  5 Comments
Star Strider
Star Strider on 18 May 2014
Please describe in detail, ideally with data (real or simulated), and what you want to do with it.
It’s quite likely you can do what you want in MATLAB. We can’t help you if you don’t tell us what your data are and what you want to do with them.
I still don’t understand the permutations involved in getting reg1, reg2, and the rest. What’s the pattern? Why?
Camilo
Camilo on 19 May 2014
ok, I have the following (simulated) values that correspond to peak positions. Each array corresponds to a gaussian fit of data obtained experimentally:
a = [12,25,36,75]
b = [6,36,81]
c = [14,23,38,79]
d = [7,20,31,74,92]
I need the best linear regression between values of different gaussian fits.
12,6,14,7
12,36,14,7
12,81,14,7
12,6,23,7
and so on...
In each linear regression I can have only one value from each experiment. So, I can't have something like
12,25,6,36,14,23
The problem is that the number of experiments can vary. In this case I have 4, but sometimes I need to run 5 or 20.
finally, what I really need is the intercept of the best linear regression.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!