<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639</link>
    <title>MATLAB Central Newsreader - glmfit binomial-probit with natural mortality</title>
    <description>Feed for thread: glmfit binomial-probit with natural mortality</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 01 Aug 2008 17:55:04 -0400</pubDate>
      <title>glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#446821</link>
      <author>Joe Ercolino</author>
      <description>Hi&lt;br&gt;
&lt;br&gt;
I'm trying to fit a generalized linear model (GLM) with the&lt;br&gt;
glmfit function. My problem deals with the&lt;br&gt;
dose-response(Mortality)of a population of animals exposed&lt;br&gt;
to a toxic agent. The most common models for this type of&lt;br&gt;
regression use the binomial distribution and probit or logit&lt;br&gt;
as link functions with the log(Dose) as predictors. The data&lt;br&gt;
I'm working with shows a non zero response for the controls&lt;br&gt;
(dose equal to zero). I think that the logit or probit&lt;br&gt;
functions can not accommodate for this type type behavior&lt;br&gt;
since they go from zero to one. Is there a way to make&lt;br&gt;
glmfit to take into account the controls correction (natural&lt;br&gt;
mortality) or there is any other feasible way to do it in&lt;br&gt;
MATLAB?&lt;br&gt;
&lt;br&gt;
Thanks in advance.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Sep 2008 15:28:01 -0400</pubDate>
      <title>Re: glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#602784</link>
      <author>Villamide Bego</author>
      <description>Hi Joe, &lt;br&gt;
&lt;br&gt;
I have the same problem as you. Have you any solution to this question?&lt;br&gt;
&lt;br&gt;
Thanks in advance.&lt;br&gt;
&lt;br&gt;
Bego.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Joe Ercolino&quot; &amp;lt;joe_ercolino@hotmail.com&amp;gt; wrote in message &amp;lt;g6vilo$h12$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm trying to fit a generalized linear model (GLM) with the&lt;br&gt;
&amp;gt; glmfit function. My problem deals with the&lt;br&gt;
&amp;gt; dose-response(Mortality)of a population of animals exposed&lt;br&gt;
&amp;gt; to a toxic agent. The most common models for this type of&lt;br&gt;
&amp;gt; regression use the binomial distribution and probit or logit&lt;br&gt;
&amp;gt; as link functions with the log(Dose) as predictors. The data&lt;br&gt;
&amp;gt; I'm working with shows a non zero response for the controls&lt;br&gt;
&amp;gt; (dose equal to zero). I think that the logit or probit&lt;br&gt;
&amp;gt; functions can not accommodate for this type type behavior&lt;br&gt;
&amp;gt; since they go from zero to one. Is there a way to make&lt;br&gt;
&amp;gt; glmfit to take into account the controls correction (natural&lt;br&gt;
&amp;gt; mortality) or there is any other feasible way to do it in&lt;br&gt;
&amp;gt; MATLAB?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Sep 2008 18:36:25 -0400</pubDate>
      <title>Re: glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#602834</link>
      <author>Tom Lane</author>
      <description>Joe or Bego, I'm not aware of what standard mathematical/statistical &lt;br&gt;
approach that is generally used here.  I could guess that it might involve &lt;br&gt;
estimating a non-zero baseline probability of response, with the link &lt;br&gt;
function describing how the probability increases.  But I really don't know.&lt;br&gt;
&lt;br&gt;
I guess what I'm asking is this.  Are you looking for the right approach, or &lt;br&gt;
do you know the approach and you're looking for advice on how to do it in &lt;br&gt;
MATLAB?&lt;br&gt;
&lt;br&gt;
-- Tom&lt;br&gt;
&lt;br&gt;
&quot;Villamide Bego&quot; &amp;lt;bvillamide@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:gbqs61$9ts$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Joe,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have the same problem as you. Have you any solution to this question?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Bego.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;Joe Ercolino&quot; &amp;lt;joe_ercolino@hotmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;g6vilo$h12$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; Hi&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; I'm trying to fit a generalized linear model (GLM) with the&lt;br&gt;
&amp;gt;&amp;gt; glmfit function. My problem deals with the&lt;br&gt;
&amp;gt;&amp;gt; dose-response(Mortality)of a population of animals exposed&lt;br&gt;
&amp;gt;&amp;gt; to a toxic agent. The most common models for this type of&lt;br&gt;
&amp;gt;&amp;gt; regression use the binomial distribution and probit or logit&lt;br&gt;
&amp;gt;&amp;gt; as link functions with the log(Dose) as predictors. The data&lt;br&gt;
&amp;gt;&amp;gt; I'm working with shows a non zero response for the controls&lt;br&gt;
&amp;gt;&amp;gt; (dose equal to zero). I think that the logit or probit&lt;br&gt;
&amp;gt;&amp;gt; functions can not accommodate for this type type behavior&lt;br&gt;
&amp;gt;&amp;gt; since they go from zero to one. Is there a way to make&lt;br&gt;
&amp;gt;&amp;gt; glmfit to take into account the controls correction (natural&lt;br&gt;
&amp;gt;&amp;gt; mortality) or there is any other feasible way to do it in&lt;br&gt;
&amp;gt;&amp;gt; MATLAB?&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Mon, 29 Sep 2008 23:26:02 -0400</pubDate>
      <title>Re: glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#602893</link>
      <author>Joe Ercolino</author>
      <description>Hi Bego&lt;br&gt;
&lt;br&gt;
So far I haven't found a suitable solution using glmfit. I even suspect that this function can't handle this type of fit (control mortality).&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Joe&lt;br&gt;
&lt;br&gt;
&quot;Villamide Bego&quot; &amp;lt;bvillamide@gmail.com&amp;gt; wrote in message &amp;lt;gbqs61$9ts$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Joe, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have the same problem as you. Have you any solution to this question?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bego.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Joe Ercolino&quot; &amp;lt;joe_ercolino@hotmail.com&amp;gt; wrote in message &amp;lt;g6vilo$h12$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I'm trying to fit a generalized linear model (GLM) with the&lt;br&gt;
&amp;gt; &amp;gt; glmfit function. My problem deals with the&lt;br&gt;
&amp;gt; &amp;gt; dose-response(Mortality)of a population of animals exposed&lt;br&gt;
&amp;gt; &amp;gt; to a toxic agent. The most common models for this type of&lt;br&gt;
&amp;gt; &amp;gt; regression use the binomial distribution and probit or logit&lt;br&gt;
&amp;gt; &amp;gt; as link functions with the log(Dose) as predictors. The data&lt;br&gt;
&amp;gt; &amp;gt; I'm working with shows a non zero response for the controls&lt;br&gt;
&amp;gt; &amp;gt; (dose equal to zero). I think that the logit or probit&lt;br&gt;
&amp;gt; &amp;gt; functions can not accommodate for this type type behavior&lt;br&gt;
&amp;gt; &amp;gt; since they go from zero to one. Is there a way to make&lt;br&gt;
&amp;gt; &amp;gt; glmfit to take into account the controls correction (natural&lt;br&gt;
&amp;gt; &amp;gt; mortality) or there is any other feasible way to do it in&lt;br&gt;
&amp;gt; &amp;gt; MATLAB?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks in advance.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Sep 2008 23:48:02 -0400</pubDate>
      <title>Re: glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#602900</link>
      <author>Joe Ercolino</author>
      <description>Hi Tom&lt;br&gt;
&lt;br&gt;
Thanks for your reply. There exists a &quot;standard&quot; statistical model for this type of fit. It is called generalized linear models. This kind of statistical models can deal with a great variety of different problems and parameters. Our particular problem has a non-zero parameter (wich you correctly discribe as a baseline probability). In the biostatistics field (dose-response analysis) is called control mortality or mortality in the control group. I know that programs such SPSS or SAS can handle this type of problems directly. I would like to be able to do it in MATLAB, but I don't know how.&lt;br&gt;
&lt;br&gt;
Thanks in advance&lt;br&gt;
&lt;br&gt;
&quot;Tom Lane&quot; &amp;lt;tlane@mathworks.com&amp;gt; wrote in message &amp;lt;gbr779$n6e$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Joe or Bego, I'm not aware of what standard mathematical/statistical &lt;br&gt;
&amp;gt; approach that is generally used here.  I could guess that it might involve &lt;br&gt;
&amp;gt; estimating a non-zero baseline probability of response, with the link &lt;br&gt;
&amp;gt; function describing how the probability increases.  But I really don't know.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I guess what I'm asking is this.  Are you looking for the right approach, or &lt;br&gt;
&amp;gt; do you know the approach and you're looking for advice on how to do it in &lt;br&gt;
&amp;gt; MATLAB?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- Tom&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Villamide Bego&quot; &amp;lt;bvillamide@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:gbqs61$9ts$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; Hi Joe,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have the same problem as you. Have you any solution to this question?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Bego.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &quot;Joe Ercolino&quot; &amp;lt;joe_ercolino@hotmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; &amp;lt;g6vilo$h12$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hi&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; I'm trying to fit a generalized linear model (GLM) with the&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; glmfit function. My problem deals with the&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; dose-response(Mortality)of a population of animals exposed&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; to a toxic agent. The most common models for this type of&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; regression use the binomial distribution and probit or logit&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; as link functions with the log(Dose) as predictors. The data&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; I'm working with shows a non zero response for the controls&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; (dose equal to zero). I think that the logit or probit&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; functions can not accommodate for this type type behavior&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; since they go from zero to one. Is there a way to make&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; glmfit to take into account the controls correction (natural&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; mortality) or there is any other feasible way to do it in&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; MATLAB?&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Wed, 08 Oct 2008 18:07:30 -0400</pubDate>
      <title>Re: glmfit binomial-probit with natural mortality</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173639#604286</link>
      <author>Tom Lane</author>
      <description>&amp;gt; Thanks for your reply. There exists a &quot;standard&quot; statistical model for &lt;br&gt;
&amp;gt; this type of fit. It is called generalized linear models. This kind of &lt;br&gt;
&amp;gt; statistical models can deal with a great variety of different problems and &lt;br&gt;
&amp;gt; parameters. Our particular problem has a non-zero parameter (wich you &lt;br&gt;
&amp;gt; correctly discribe as a baseline probability). In the biostatistics field &lt;br&gt;
&amp;gt; (dose-response analysis) is called control mortality or mortality in the &lt;br&gt;
&amp;gt; control group. I know that programs such SPSS or SAS can handle this type &lt;br&gt;
&amp;gt; of problems directly. I would like to be able to do it in MATLAB, but I &lt;br&gt;
&amp;gt; don't know how.&lt;br&gt;
&lt;br&gt;
Joe (and Bego), the glmfit function does generalized linear models.  For a &lt;br&gt;
binomial distribution it has several built-in &quot;link&quot; functions that describe &lt;br&gt;
how the fitted probability depends on a linear combination of the &lt;br&gt;
predictors.  These are the logit, probit, log-log, and complementary log-log &lt;br&gt;
functions.  All have the property that they produce fitted probabilities &lt;br&gt;
throughout the range from 0 to 1.&lt;br&gt;
&lt;br&gt;
You want a probability ranging upward from some lower limit L to 1. &lt;br&gt;
Fortunately, there's a capability to provide your own link function.  You &lt;br&gt;
would write your own functions to compute the link, its derivative, and its &lt;br&gt;
inverse, and invoke glmfit something like this:&lt;br&gt;
&lt;br&gt;
b = glmfit(log(dose),y,'binomial','link',{@mylink @mydlink @myilink});&lt;br&gt;
&lt;br&gt;
If you want to estimate the lower limit, you can try a range of lower limit &lt;br&gt;
values and pick the one that works best.  A problem is that, internally, &lt;br&gt;
glmfit produces some starting values that may not satisfy your lower limit &lt;br&gt;
requirement (because glmfit doesn't know about that lower limit).  Below is &lt;br&gt;
some code using an idea suggested by Peter Perkins for dealing with that &lt;br&gt;
issue.  Sorry it's so long.&lt;br&gt;
&lt;br&gt;
Thanks for this question.  You've given us some ideas for improving glmfit &lt;br&gt;
in the future:  allowing specification of starting values, supporting link &lt;br&gt;
functions with lower or upper bounds, and maybe estimating link functions &lt;br&gt;
with parameters in them.&lt;br&gt;
&lt;br&gt;
I should add that this is going to enable you to compute standard errors for &lt;br&gt;
the coefficients given that the L value is fixed at the value you choose. &lt;br&gt;
That's similar to what's often done in Box-Cox models, where the estimation &lt;br&gt;
is done conditional on the Box-Cox parameter.  That may not be what you &lt;br&gt;
want -- you may prefer to measure the uncertainty in L and take that into &lt;br&gt;
account when measuring the uncertainty on the coefficients.  I don't have a &lt;br&gt;
way to do the latter right now.&lt;br&gt;
&lt;br&gt;
-- Tom&lt;br&gt;
-----------------&lt;br&gt;
&lt;br&gt;
function mortality2&lt;br&gt;
&lt;br&gt;
% Generate random data&lt;br&gt;
rand('twister',10);&lt;br&gt;
dose = sort(floor(exprnd(10,200,1)));&lt;br&gt;
ilogit = @(L) 1./(1+exp(-L));&lt;br&gt;
p = 0.15 + 0.85 * ilogit(-6 + 2*log(dose));&lt;br&gt;
y = binornd(1,p);&lt;br&gt;
ax1 = subplot(2,1,1);&lt;br&gt;
plot(dose,p,'b-', dose,y,'ro')&lt;br&gt;
&lt;br&gt;
% Nested functions defining the link&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function eta = mylink(mu) % link function&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if init % adjust starting values first time through&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mu = min(max(mu,L+(1-L)*.5/2),1-(1-L)*.5/2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eta = log((mu-L) ./ (1-mu));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function deta = mydlink(mu) % derivative of link function&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if init % adjust starting values first time through&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mu = min(max(mu,L+(1-L)*.5/2),1-(1-L)*.5/2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;init = false;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;deta = (1-L) ./ ((mu-L) .* (1-mu));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function mu = myilink(eta,lowerBnd,upperBnd) % inverse of link function&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if nargin&amp;lt;2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lowerBnd = log(eps);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;upperBnd = -lowerBnd;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% keep mu = ilink(eta) in (approx) [L+eps, (1-eps)];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mu = L + (1-L) ./ (1 + exp(-min(max(eta,lowerBnd),upperBnd)));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
% Negative log likelihood&lt;br&gt;
nll = @(y,p) -(sum(log(p(y==1))) + sum(log(1-p(y==0))));&lt;br&gt;
&lt;br&gt;
% Fit using a range of lower limit values using points with dose&amp;gt;0, but&lt;br&gt;
% compute the negative log likelihood for all points&lt;br&gt;
Lvec = (0:30)/100;&lt;br&gt;
bmat = zeros(2,length(Lvec));&lt;br&gt;
nlogl = zeros(size(Lvec));&lt;br&gt;
t = dose&amp;gt;0;&lt;br&gt;
for j=1:length(Lvec)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;init = true;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L = Lvec(j);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b = glmfit(log(dose(t)),y(t),'binomial','link',{@mylink @mydlink &lt;br&gt;
@myilink});&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nlogl(j) = nll(y,myilink(b(1)+b(2)*log(dose)));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bmat(:,j) = b;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% Show the best one&lt;br&gt;
[bestn,bestloc] = min(nlogl);&lt;br&gt;
b = bmat(:,bestloc);&lt;br&gt;
L = Lvec(bestloc);&lt;br&gt;
axes(ax1);&lt;br&gt;
line(dose,myilink(b(1)+b(2)*log(dose),-Inf,Inf),'color','g');&lt;br&gt;
legend('True','Data','Fit','location','SE')&lt;br&gt;
&lt;br&gt;
ax2 = subplot(2,1,2);&lt;br&gt;
plot(Lvec,nlogl)&lt;br&gt;
line(Lvec(bestloc),bestn,'marker','o','color','g');&lt;br&gt;
legend('Neg log likelihood','Best','location','SE')&lt;br&gt;
end </description>
    </item>
  </channel>
</rss>

