Thread Subject: glmfit statistics

Subject: glmfit statistics

From: Daniel

Date: 10 Nov, 2009 21:59:04

Message: 1 of 4

I am trying to decipher the statistics returned by glmfit.

If I take the fit parameter returned and divide it by the sqrt of the covariance returned for that same parameter, I get a number that equals the t statistic returned. This leads to my first question, which is shouldn't I also have to normalize by the sqrt of n, which n is the number of samples? (Or is n somehow equal to 1 for this fit?)

My second question is that when I work with the t-value returned, I cannot figure out how the p-value is calculated. I am assuming that the hypothesis being tested is the fit parameters returned are equal to zero. But I cannot find a value for the degrees of freedom that will yield the p-values returned given the t-values returned.

Hope that this makes sense. I am probably just missing something simple.

Sincerely,
Dan

Subject: glmfit statistics

From: Tom Lane

Date: 11 Nov, 2009 15:21:56

Message: 2 of 4

> If I take the fit parameter returned and divide it by the sqrt of the
> covariance returned for that same parameter, I get a number that equals
> the t statistic returned. This leads to my first question, which is
> shouldn't I also have to normalize by the sqrt of n, which n is the number
> of samples? (Or is n somehow equal to 1 for this fit?)

Dan, the covariance matrix that you mentioned is an estimate of the
uncertainty in the coefficients, so it already takes the number of samples
into account.

> My second question is that when I work with the t-value returned, I cannot
> figure out how the p-value is calculated. I am assuming that the
> hypothesis being tested is the fit parameters returned are equal to zero.
> But I cannot find a value for the degrees of freedom that will yield the
> p-values returned given the t-values returned.

The d.f. is n-p, where n is the number of observations and p is the number
of estimated coefficients. The p-value is two-sided, so for example if you
have t=2.34 then the p-value is the probablity that the t distribution
assigns to values greater than 2.34 plus the probability of values less
than -2.34. Could that explain the difference you found?

-- Tom

Subject: glmfit statistics

From: Peter Perkins

Date: 11 Nov, 2009 15:43:54

Message: 3 of 4

Daniel wrote:
> I am trying to decipher the statistics returned by glmfit.
>
> If I take the fit parameter returned and divide it by the sqrt of the covariance returned for that same parameter, I get a number that equals the t statistic returned. This leads to my first question, which is shouldn't I also have to normalize by the sqrt of n, which n is the number of samples? (Or is n somehow equal to 1 for this fit?)

That cov matrix is an estimate of the covariance of the parameter estimates (estimators, technically), so the number of observations is already figured in. In a simpler context, where x is just a vector of data drawn from a normal dist'n, it's like the difference between std(x), which is an estimate of the population std dev sigma, and std(x)/sqrt(length(x)), which is the std error of muHat = mean(x), i.e. an estimate of the variance of muHat.

> My second question is that when I work with the t-value returned, I cannot figure out how the p-value is calculated. I am assuming that the hypothesis being tested is the fit parameters returned are equal to zero. But I cannot find a value for the degrees of freedom that will yield the p-values returned given the t-values returned.

It's a two-tailed p-value, and the degrees of freedom is given by the dfe field of that same structure. In this case, dfe is (number of observations) - (number of estimated regression coefs).

> Hope that this makes sense. I am probably just missing something simple.

Often the best way to sort this out is to just step through the code in the debugger.

Subject: glmfit statistics

From: Daniel

Date: 11 Nov, 2009 19:18:03

Message: 4 of 4

Thanks to both of you for your comments. I had considered the issue of two-sided versus one-sided and had tried it both ways. Hmm, maybe I was just having a bad hair day. I'll go try it again and see if I can figure out what I did wrong yesterday.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
glmfit statistics Daniel 10 Nov, 2009 17:04:08
rssFeed for this Thread

Contact us at files@mathworks.com