Thread Subject: glmfit

Subject: glmfit

From: Luca Di Simone

Date: 4 Nov, 2009 15:46:03

Message: 1 of 6

I am working with glmfit to perform probit regressions. I want to regress my y on just a costant but the glmfit points out that the limit is reached.

My syntax is;
[beta dev stat]=glmfit(x,[y n],'binomial','probit')

if x has not regressors, what's the function's input in place of x? and if the regression contains already a (default) constant, in such a case, how can I exclude the constant?

thanks for your help

Luca

Subject: glmfit

From: Peter Perkins

Date: 4 Nov, 2009 15:57:14

Message: 2 of 6

Luca Di Simone wrote:
> I am working with glmfit to perform probit regressions. I want to regress my y on just a costant but the glmfit points out that the limit is reached.
>
> My syntax is;
> [beta dev stat]=glmfit(x,[y n],'binomial','probit')
>
> if x has not regressors, what's the function's input in place of x? and if the regression contains already a (default) constant, in such a case, how can I exclude the constant?

As the help says,

>> help glmfit
 GLMFIT Fit a generalized linear model.
[snip]
       'constant' - specify as 'on' (the default) to include a constant
          term in the model, or 'off' to omit it. The coefficient of the
          constant term is the first element of B.

Or you can do this:

   x = zeros(size(y,1),0)
   glmfit(x,[y n],'binomial','link','probit')

But why are you using GLMFIT if you don't have any predictor variables? The only reason I can think of would be to compute some version of r-squared.

Subject: glmfit

From: Luca Di Simone

Date: 4 Nov, 2009 16:26:02

Message: 3 of 6

I am computing the mcfadden r^2 and I have to calculate the log likelihood of a model with only intercept. Now I used the vector of zeros as only regressor but the output of the function is that the matrix is singular to working precision.
While if I perform the regression on an specific regressor the results have not this problem.
How can I do?
thanks
Luca






Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <hcs88q$qgf$1@fred.mathworks.com>...
> Luca Di Simone wrote:
> > I am working with glmfit to perform probit regressions. I want to regress my y on just a costant but the glmfit points out that the limit is reached.
> >
> > My syntax is;
> > [beta dev stat]=glmfit(x,[y n],'binomial','probit')
> >
> > if x has not regressors, what's the function's input in place of x? and if the regression contains already a (default) constant, in such a case, how can I exclude the constant?
>
> As the help says,
>
> >> help glmfit
> GLMFIT Fit a generalized linear model.
> [snip]
> 'constant' - specify as 'on' (the default) to include a constant
> term in the model, or 'off' to omit it. The coefficient of the
> constant term is the first element of B.
>
> Or you can do this:
>
> x = zeros(size(y,1),0)
> glmfit(x,[y n],'binomial','link','probit')
>
> But why are you using GLMFIT if you don't have any predictor variables? The only reason I can think of would be to compute some version of r-squared.

Subject: glmfit

From: Tom Lane

Date: 4 Nov, 2009 17:51:49

Message: 4 of 6

> Now I used the vector of zeros as only regressor but the output of the
> function is that the matrix is singular to working precision.
...
> Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message
>> x = zeros(size(y,1),0)
>> glmfit(x,[y n],'binomial','link','probit')

Did you do it the way Peter suggested? He has created not a vector of zeros,
but an array with the right number of rows and zero columns.

-- Tom

Subject: glmfit

From: Luca Di Simone

Date: 4 Nov, 2009 18:54:02

Message: 5 of 6

Yes, I used the way suggusted by peter and the output is the matrix is singular. Can you help?
Luca

"Tom Lane" <tlane@mathworks.com> wrote in message <hcsevl$2o4$1@fred.mathworks.com>...
> > Now I used the vector of zeros as only regressor but the output of the
> > function is that the matrix is singular to working precision.
> ...
> > Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message
> >> x = zeros(size(y,1),0)
> >> glmfit(x,[y n],'binomial','link','probit')
>
> Did you do it the way Peter suggested? He has created not a vector of zeros,
> but an array with the right number of rows and zero columns.
>
> -- Tom
>

Subject: glmfit

From: Peter Perkins

Date: 4 Nov, 2009 22:01:08

Message: 6 of 6

Luca Di Simone wrote:
> Yes, I used the way suggusted by peter and the output is the matrix is singular. Can you help?

It may be that you are using an old version of this function. It definitely does work in the current version.

If that's the case, you might try passing in a column of ones for x, and turning off the constant, as I suggested in an earlier post.

Tags for this Thread

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com