How to use linear regression modeling for x-vector of dimension m and y-vector of dimension m
8 views (last 30 days)
Show older comments
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
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.
If it's multiple-response model, see https://www.mathworks.com/help/stats/multivariate-regression-1.html and/or
Answers (1)
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!