Trouble with glmfit using custom link function

3 Ansichten (letzte 30 Tage)
Martin
Martin am 9 Dez. 2013
I'm fitting binomial data where chance performance is 50%. For that reason I use a modified logit link function like this:
fl = inline('log(((x-0.5)./(1-x)))');
fd = inline('0.5./((x-0.5).*(1-x))');
fi = inline('0.5+0.5*(exp(x))./(1+exp(x))');
lfun = {fl fd fi};
Unfortunately, betas estimated in this way contain a small imaginary component that causes gmlfit to crash when the stats are calculated. Here is an illustration of the problem (without asking for the stats):
cl = [0:0.05:1];
sc = [0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1];
[B,D] = glmfit(cl',sc','binomial','link',lfun,'const','on')
X = 0.0:0.01:1;
Y = glmval(B,X,lfun,'size',20,'constant','on');
plot(X,Y/20,'-'), hold on
plot(-B(1)/B(2)*[1 1],[0 1],'--')
plot([0 1],0.75*[1 1],'--'), hold off
The parameter estimates are not bad (save the imaginary part), but it is not possible to run:
[B,D,S] = glmfit(cl',sc','binomial','link',lfun,'const','on')
This appears to happen because of the restricted range of meaningful mu values with the custom link, leading to complex eta values in glmfit. It is not difficult to modify glmfit to avoid this problem by changing the starting values for mu, but I wonder if there is a better and more general way to avoid this kind of problem with custom link functions that change the boundary values for the desired distribution.
Many thanks, Martin
  1 Kommentar
Fernando del Solar Dorrego
Fernando del Solar Dorrego am 27 Nov. 2020
I have the same problem. I posted a question recently:
Hi,
I am trying to find the coefficients for a scaled logistic regression which is normally used in psychophysics for the 2-Alternative Forced Choice, constant stimuli method.
The scaled logistic regression is the following:
p(X) = 0.5+0.5*(1/(1+e^-(a+bX)))
I am trying to use the fitglm function, defining the link function, derivative and inverse as:
S.Link = @(mu) log((1-2*mu)./(2*mu-2));
S.Derivative = @(mu) 1./(-2*mu.^2+3*mu-1);
S.Inverse = @(Xb) 0.5+0.5./(1+exp(-Xb));
I am using this command:
mdl = fitglm(Holland(:,1),Holland(:,2),'Distribution','binomial','Link',S);
The function gives an error and can't compute the fitted coefficients.
Any ideas of what might be happening?
------
Did you find a solution for this problem? Thanks

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by