GLM with a custom link function

3 次查看(过去 30 天)
Tal
Tal 2012-7-25
Dear all,
I would like to use a custom link function in glmfit. The function is a special case of Cohen's (1973) model, and is written as:
v(t) = (1-exp(-(l-mu).*t))./(1-(0.2./l).*exp(-(l-mu).*t))
the above equation is technically the inverse link function. The link function is:
log(((mu.*t)-l)./(l.*(t-1)))./(l-mu);
My code specifying the input data and link functions is below. I am holding the parameter mu constant (mu = 0.2) and want to estimate the parameter l. I know I have not coded this properly, and the error message I receive "Input argument "l" is undefined"
How do I estimate my parameter "l"?
Thank you
%% Format data for glmfit
in = load('age_prev.txt');
a_prev = zeros(432,2);
a_prev(1:144,1:2) = in(:,1:2);
a_prev(145:288,1:2) = in(:,3:4);
a_prev(289:432,1:2) = in(:,5:6);
a_prev=delnanrows(a_prev);clear in
x = a_prev(:,1);y = [a_prev(:,2) ones(length(a_prev),1)];
%% Write link functions
clink = @(t,l) log(((0.2.*t)-l)./(l.*(t-1)))./(l-0.2);
cder = @(t,l) 1./((t-1).*((0.2.*t)-l));
cinv = @(t,l) (1-exp(-1.*(l-0.2).*t))./(1-(0.2./l).*exp(-1.*(l-0.2).*t));
mylinks = {clink cder cinv};
%% GLMfit
% x is an Nx1 array of the independent variable (time)
% y is an Nx2 array: column 1 is # of successes, column 2 is # of trials
[b,dev,stats] = glmfit(x,y,'binomial','link',mylinks,'constant','off');

回答(1 个)

Peter Perkins
Peter Perkins 2012-7-25
Tal, the link function in a GLM maps the expected value to the linear predictor X*beta, and the inverse link does the opposite. Your function
v(t) = (1-exp(-(l-mu).*t))./(1-(0.2./l).*exp(-(l-mu).*t))
involves l, mu, and t, so you're gonna have to explain what's what. It has to be of the form
linearPredictor = g(expectedValue)
If, as it appears, your link function has other unknown parameters, those have to be estimated separately from the regression coefficients. McCullagh&Nelder's Generalized Linear Models goes into this kind of thing, or perhaps the paper you cite has a method tailored to your model.

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by