How to use linear regression modeling for x-vector of dimension m and y-vector of dimension m

8 views (last 30 days)
I have a set of data where x is a vector of m x 1 and corresponding y vector is m x 1. I'd like to use fitrlinear but when I try out the code on wiki, i see that x is 10000 x 1000, so 10k samples of vectors with 1k features. The y matrix is 10000 x 1 so it only accepts 1 value y for each x vector?
What's a good library to use create linear regression for my specific case if fitrlinear doesn't work.
Thanks
  3 Comments
Akira Kato
Akira Kato on 9 Aug 2020
It gives me error when I try fitrlinear(x,y) where x is n x m and y is k x m. I just worked around this by doing fitrlinear k times with the same x and the set of k models is my model. I'd appreciate it if you could show me how to use fitrlinear directly with these x and y dimension, im not sure from looking at the wiki for it.
Thanks
dpb
dpb on 9 Aug 2020
It's not clear what you are trying to use as a model -- are you triyng to fit a mulitple outputs model of all the inputs or a single output for the number of outputs with a full (or subset of) the inputs?
fitrlinear is not able to do more than the single-output case so it isn't an option unless it is the second of the two options above you wish.
It sounds from the above complaint that isn't what you want or you just want the convenience of not writing an explicit loop; not sure which.

Sign in to comment.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 9 Aug 2020
Hi,
If your given data for x and y are 1-by-1000 or 1-by-10000000 ... . Briefly speaking your data is 1D. Then you'd need to use polyfit() of 1st order (linear regression fit model type), e.g.:
P = polyfit(x, y, 1); % p is a linear fit model coefficients for a*x+b => p(1)=a, p(2)=b.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!