The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Re: Binary Logistic Regression
Replies: 1   Last Post: Apr 8, 2013 9:47 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Tom Lane

Posts: 858
Registered: 12/7/04
Re: Binary Logistic Regression
Posted: Apr 8, 2013 9:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

The glmfit function wants to operate on columns. Make sure x1,x2,x3,y are
all column vectors, and then xfull will be a three-column matrix.

The second argument to chi2cdf in this example is a 3 because there are
three columns of the X matrix.

-- Tom

"jacksparrow " <> wrote in message
> Hey Phoebe!
> I am getting the same problem. Did you get the correct solution now?
> Please share.
> "Phoebe " <> wrote in message
> <k1ij0v$5gt$>...

>> Trying to perform binary logistic regression with one y and 3 x's. Code
>> is as follows so far;
>> clear
>> x1=[....];
>> x2=[....];
>> x3=[....];
>> xfull=[x1 x2 x3];
>> y=[0 1 0 ...etc];
>> [bfull,devfull]=glmfit(xfull,y,'binomial','link','logit');
>> n1=sum(y);
>> n=size(y,1);
>> n0=n-n1;
>> G=-2*(n1*log(n1)+n0*log(n0)-n*log(n) - dev);
>> pval=1 - chi2cdf(G,3)
>> bfull
>> devfull
>> n1
>> n
>> n0
>> G
>> pval
>> I have a few queries;
>> 1. Matlab says my y must be a 2 column matrix or a vector which it is
>> inputted as so i dont know why it doesnt recognise this?
>> 2. Within the pval equation it refers to (G,3) although in some cases
>> this number is a 1 not a 3?

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.