stata logit (logistic regression)

qim

New Member
Can you use the following command

logit con gender agegrps

if agegrps has 3 values? Does the resulting table make any sense if the variable agegrps is not binary and coded 0 and 1?

Thank you

qim

AtlasFrysmith

New Member
I'm guessing from your variable names you're regressing consumption on gender and age group?

First of all, in a logit regression the dependent variable must be binary.

As for age group, see my answer to your question about dummy variables. You'll want to decompose this into dummies for each group.

owenpediatrica

New Member
I guess con is the dependent variable? if so, you might declare a categorical (dummy) variable by using i or xi or so... you might want to check the command book of stata. I am not sure.

qim

New Member
Yes, I could do

xi: logit con *** i.agegrps

The problem is that I am supposed to calculate predicted possibilities and while I can read the normal regression I CANNOT read (I am ashamed to say) the regression when you have the agegrps split up into 3. I can't relate the coefficients to 'con' and especially how to read the Iagegrps_2 which is omitted.

. xi: logit con *** i.agegrps [pw=weight]
i.agegrps _Iagegrps_1-3 (naturally coded; _Iagegrps_2 omitted)

(sum of wgt is 2.2190e+03)
Iteration 0: log pseudolikelihood = -1651.5837
Iteration 1: log pseudolikelihood = -1642.1845
Iteration 2: log pseudolikelihood = -1642.1614
Iteration 3: log pseudolikelihood = -1642.1614

Logistic regression Number of obs = 2756
Wald chi2(3) = 14.33
Prob > chi2 = 0.0025
Log pseudolikelihood = -1642.1614 Pseudo R2 = 0.0057

------------------------------------------------------------------------------
| Robust
con | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
*** | .1102079 .0998779 1.10 0.270 -.0855492 .305965
_Iagegrps_1 | -.1929194 .1292349 -1.49 0.135 -.4462152 .0603765
_Iagegrps_3 | .2774401 .1120542 2.48 0.013 .0578179 .4970622
_cons | -1.103701 .1715891 -6.43 0.000 -1.440009 -.7673924
------------------------------------------------------------------------------

The first independent variable is xes (the other way roun which the forum does not allow!)

Can you help there?

qim

Last edited:

AtlasFrysmith

New Member
Ok the coefficient on agegrp_1, for example, is the effect of being in agegrp_1 relative to being in the omitted group, in this case _2. (It has to be omitted to avoid multicollinearity. Alternately you could omit the constant by adding noconstant in the command. If you do this the interpretation of the coefficients will be slightly different) So in your example, age grp 1 is insignificant, while agegrp3 is significant at about 2%.

To predict expected values of the dependent variable you should just be able to use the predict command with appropriate options--check the manual for this.

qim

New Member
Thank ou veru much. But now I have another proble. The next step was to do something like this:

generate prob = exp(-1.652666+0.01183*agegrps)/ (1 + exp(-1.652666+0.01183*agegrps))

If I have several (3) agegrps which coefficient am I going to use to generate the rob? Or do I need to generate more than one? if I do that it does not make sense (to me).

Or do I keep adding the various agegroups before dividing by the denominator?

Help...
qim

AtlasFrysmith

New Member
I really think you want to split agegrps into 3 separate variables. You can do this by:

gen agegrp1=0
replace agegrp1=1 if agegrps==1 (I forget the proper syntax for "else" in STATA but you get the point)

gen agegrp2=0
replace agegrp2=1 if agegrps==2

gen agegrp3=0
replace agegrp3=1 if agegrps==3

Then you run:
logit con sx agegrp1 agegrp3

Then predict. The predict command would do this but if you want to do it manually you can just take the data for one observation and put it in the estimated equation--you'll include both agegrp1 and agegrp3 since it'll just zero out if eith value is 0, and if both are the effect is captured in the constant.

I'm happy to keep this up, but it seems like you're unclear on what exactly a logit regression will tell you, why you put certain variables in, etc. I'd suggest you read up on the basics of linear regression before worrying too much about logit--the principles of multicollinearity, dummy variables, predicted values, etc will translate well.

qim

New Member
Thanks AtlasFrysmith

I'm sorry, you're right. I haven't got a clue. I am not a statistics student, but somehow I was lumped with this and have to finish it tonight. I have read as much as I could but 1 week is not enough.

Somehow I need to get from xi: command ... i.agegrp to generate prob (manually). from the notes there was no splitting into 3 variables, although I am sure tha is the right, best way to do it.

Anyway, I'm now editing this message to say thank you very much for your help, and that the assignment has now been delivered by e-mail. So, that will be the end of staistics for the rest of my life!

Many thanks

qim

Last edited: