linear discriminant analysis: how to generate a simulation example with an outcome variable of 3 groups

7 次查看(过去 30 天)
Dear Community, I've been trying to simulate data to use for a linear discriminant classification later. below, you find the code for simulated data with the dependent variable "G" that has 2 classes (0 and 1). The N observations are assigned to G using the Sigmoid function. Now, I would like to generate an example where the dependent variable "G" has 3 groups. Could anyone help me how to proceed? Can I do it with the Sigmoid function as well?
Many thanks!!
N=3000;
C=20;
x=randn(N,C);
beta=zeros(C,1);
param_true = [1 3 5 7 9];
beta(param_true)=[+10 -10 +5 -1 +1];
z=x*beta;
L=1./(1+exp(-z));
G=rand(N,1)<L;

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by