I use glmfit function to find the deviation of logistic regression model. Now I would like to calculate the standardized regression coefficients (beta coefficients) for logistic regression. Is it possible with glmfit function, if it is , could you expain the usage of it ?
Best wishes,
cyd
Cyd, if you mean "beta coefficients" the way I understand the term, that
just indicates you want to standardize the predictors before passing them
into glmfit. Try "help zscore" for a utility that might be useful.
-- Tom
thanks in advance ,
cyd
"Tom Lane" <tl...@mathworks.com> wrote in message <h6u998$bab$1...@fred.mathworks.com>...
"cyd " <ceyd...@su.sabanciuniv.edu> wrote in message <h6udel$j8m$1...@fred.mathworks.com>...
Sure:
>> x = 100*rand(100,1);
>> y = 1000 + x + 20*randn(size(x));
>> b = glmfit(x,y)
b =
999.232694590709
1.02616142726692
>> beta = glmfit(zscore(x),y)
beta =
1050.88079622223
29.1599370794729
>> b(2) * std(x)
ans =
29.1599370794729
To compute the intercept you'd have to adjust for the mean of x. And models
with multiple predictors can be handled in a similar way.
> Is there a way to automacially calculate standardized coefficients. ?
No, not if you are asking about an option of the glmfit function to compute
them. In another post you mentioned the beta field in the stats structure,
but that's just the name used for the regular coefficients in that
structure.
-- Tom
again thank you very very much for your interest.
"Tom Lane" <tl...@mathworks.com> wrote in message <h6uh6j$m52$1...@fred.mathworks.com>...
Cyd, you won't need to adjust y, if I understand the concept of beta
coefficients correctly.
There are two things you could do if you have missing (NaN) data. One is to
compute the mean and standard deviation with nanmean and nanstd, then
standardize yourself. You might find it simplest to loop over the columns,
though if you're familiar with bsxfun that allows you to do it without
looping. The other idea, if you're comfortable with editing toolbox files,
is to change zscore to use nanmean and nanstd.
-- Tom