From: Ivan Vogelius on
I am using glmfit for a pass/fail type data. In other words data very similar to the example in the glmfit documentation.
I cannot see from the documentation weather the data is automatically weighted, or weather I have to 'manually' enter the weights as a 'weights' parameter to glmfit.
Anyone knows?
From: Peter Perkins on
On 7/26/2010 7:05 AM, Ivan Vogelius wrote:
> I am using glmfit for a pass/fail type data. In other words data very
> similar to the example in the glmfit documentation.
> I cannot see from the documentation weather the data is automatically
> weighted, or weather I have to 'manually' enter the weights as a
> 'weights' parameter to glmfit.

GLMFIT uses the standard iterated reweighted least squares (IRLS)
algorithm for fitting a GLM. Those weights are not something you as the
caller of GLMFIT need to worry about. GLMFIT also accepts a weight
vector as an input. If your response variable is binomially
distributed, it would be a little unusual to need to pass in those
weights. For a binomial response, GLMFIT also allows you to specify the
number of trials for each observation. That's shown in the doc example.

All of those are in some sense "weights". What kind of weights are you
asking about?
From: Ivan Vogelius on
Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <i2k2r5$e9r$1(a)fred.mathworks.com>...
> On 7/26/2010 7:05 AM, Ivan Vogelius wrote:
> > I am using glmfit for a pass/fail type data. In other words data very
> > similar to the example in the glmfit documentation.
> > I cannot see from the documentation weather the data is automatically
> > weighted, or weather I have to 'manually' enter the weights as a
> > 'weights' parameter to glmfit.
>
> GLMFIT uses the standard iterated reweighted least squares (IRLS)
> algorithm for fitting a GLM. Those weights are not something you as the
> caller of GLMFIT need to worry about. GLMFIT also accepts a weight
> vector as an input. If your response variable is binomially
> distributed, it would be a little unusual to need to pass in those
> weights. For a binomial response, GLMFIT also allows you to specify the
> number of trials for each observation. That's shown in the doc example.
>
> All of those are in some sense "weights". What kind of weights are you
> asking about?


Thanks.
I have different number of events and subjects at each datapoint. Therefore I wanted to weigh the data according to inverse variance, which for binomial data means I should weigh by np(1-p)^-1. In this way, my 1/1 point is not weighted as high as a 39/75 point, owing to the large errorbars of the former. However, I was wondering if the algorithm already did something like that. It appears from your post that it does?
From: Peter Perkins on
On 7/27/2010 7:54 AM, Ivan Vogelius wrote:
> Thanks. I have different number of events and subjects at each
> datapoint. Therefore I wanted to weigh the data according to inverse
> variance, which for binomial data means I should weigh by np(1-p)^-1. In
> this way, my 1/1 point is not weighted as high as a 39/75 point, owing
> to the large errorbars of the former. However, I was wondering if the
> algorithm already did something like that. It appears from your post
> that it does?

Yes, you want this:

>> help glmfit
GLMFIT Fit a generalized linear model.
[snip]
If DISTR is 'binomial' Y may a binary vector indicating success/failure,
and the total number of trials is taken to be 1 for all observations.
If DISTR is 'binomial', Y may also be a two column matrix, the first
column containing the number of successes for each observation, and the
second containing the total number of trials.