generate random sample for linear regression
Show older comments
Hi guys
can anyone help me how to generate random sample for y, x1 and x2 in the following model (multiple linear regression):
yi= a + bx1 + cx2 + e
where a, b and c are parameters and e is random error.
Accepted Answer
More Answers (1)
Abhishek Gangwar
on 16 Jul 2020
0 votes
You can generate random values for x1, x2 using "randperm()" function and then find out corresponding 'y' values,
x1 = randperm(100);
x2 = randperm(100);
and put these values into your equation to find out corresponding 'y' values.
Note: 'randperm()' function gives you the random permutation of number from 1....n.
other functions, for example 'rand()', 'randn()' generates decimal numbers.
1 Comment
Abas Arkawazi
on 20 Jul 2020
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!