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');