Logistic Regression not display all data like R

2 ビュー (過去 30 日間)
Leonardo Silva
Leonardo Silva 2016 年 7 月 26 日
コメント済み: Leonardo Silva 2016 年 7 月 26 日
Hello ! I'm using version 2016a and trying to code my previous code from R to Matlab. When I do a Logistic Regression on R, it shows me all coeficients for each variable, like this image:
But when I do it from Matlab (same Data Set, same 'formula'), the results are missing:
modelo = 'LSTATUS ~ METODO + URI + URL + USERAGENT + BROWSER + COOKIE';
mdl = fitglm(FiltroA, modelo, 'Distribution','binomial');
mdl
The Data Set (FiltroA) was imported as a Table
Each field in R represent a category. For example, USERAGENT1 = Windows, USERAGENT2= Linux, etc. Someone know how to use a logistic regression on Matlab to show all categories?

採用された回答

Brendan Hamm
Brendan Hamm 2016 年 7 月 26 日
Your issue is that in R these variables are interpreted as categorical whereas in MATLAB they are being interpreted as continuous predictor variables. You can either specify them as categorical variables in fitglm:
modelo = 'LSTATUS ~ METODO + URI + URL + USERAGENT + BROWSER + COOKIE';
mdl = fitglm(FiltroA, modelo, 'Distribution','binomial','CategoricalVars',1:6);
or convert each of them to a categorical variable ahead of time.
FiltroA.METODO = categorical(FiltroA.METODO);
% Repeat for other variables
This can all be accomplished with a call to varfun:
Filtro = varfun(@categorical,FiltroA(:,1:end-1)) % Assuming LSTATUS is the last variable in table
Filtro.Properties.VariableNames = FiltroA.Properties.VariableNames(1:end-1);
FiltroA(:,1:end-1) = Filtro;
  1 件のコメント
Leonardo Silva
Leonardo Silva 2016 年 7 月 26 日
Brendan, the 1st option, using 'CategoricalVars' saved my day. I'll try the other two options after and try to optimize it. TYVM ! :)

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by