www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CreateaGeneralizedLinearModelStepwiseExample.m
%% Create a Generalized Linear Model Stepwise % Create response data using just three of 20 predictors, and create a generalized % linear model stepwise to see if it uses just the correct predictors. %% % Create data with 20 predictors, and Poisson response using just three % of the predictors, plus a constant. rng default % for reproducibility X = randn(100,20); mu = exp(X(:,[5 10 15])*[.4;.2;.3] + 1); y = poissrnd(mu); %% % Fit a generalized linear model using the Poisson distribution. mdl = stepwiseglm(X,y,... 'constant','upper','linear','Distribution','poisson')