Docsity

Logistic Rgression - Sociology - Lecture Notes, Study notes of Sociology

Toggle sidebar
bg1
Sociology 362
Data Exercise 5
Logistic Regression 1
The purpose of this problem set is to help you gain a feel for modelling a binary dependent variable and
for moving between the different scales (log-odds, odds, and probability).
The form of the data below is “grouped” because we do not have observations on individuals, but rather
on sets of individuals who have been grouped by their age. For each group, we know how many
individuals are in it, and how many had y= 1 (and, by subtraction, how many had y= 0). In fact, the
data have the same form as the data for the handout entitled real simple logit analysis, except instead of 2
categories of the independent variable “sex,” we have here 8 categories of the independent variable “age.”
age njrj
20 704 21
25 628 32
30 775 70
35 338 43
40 784 46
45 789 89
50 1016 169
55 434 98
where njis the number of people in the sample from the jth age category and rjis the number who have
consumed psychotropic drugs in the last week. These data will have to be entered into Stata e.g., input
age n r, which you will use to do the following problems.
1. For each age group, compute the proportion rj/njwho are on drugs and the odds rj/(nj−rj) of
being on drugs. How do these proportions and odds vary with age? Use the list command to view them.
2. For each age group, compute the ln(odds), i.e., ln(rj/(nj−rj)), of being on drugs. What appears to
be the effect of age on the ln(odds) (otherwise know as the logit(πj), where πis the probability of being
on drugs)?
3. Using Stata, fit by least-squares the linear probability model by regressing the proportion who used
drugs on age, i.e, regress prop age. (I named my proportion variable prop; your’s may have a different
name.) Interpret the age coefficient.
4. Fit by least-squares the logit model for the ln(odds) as a function of age, i.e., regress lgodds age. (I
named my ln(odds) variable lgodds). Interpret the age coefficient.
5. Using Stata, fit by maximum likelihood the logit model for the effect of age on drug use. The
command will take the form blogit r n age. How does the age coefficient you obtained compare to the
least-squares estimate from problem 4? Do these coefficients have the same interpretation even though
they were generated by different estimators?
6. Based on the MLE results:
a) Interpret the coefficient of age in terms of the effect of age on 1) the ln(odds); 2) the plain odds of
being on drugs; and 3) the probability πjof being on drugs.
b)Find the fitted odds that someone age 35 is on drugs and compare it to the fitted odds that someone
who is 34 is on drugs. Does the ratio of the first to the second fitted odds equal e
ˆ
β?
c) What is the expected difference in πfor people who are 20 compared to 30 years old? What is the
expected difference in πfor people who are 35 compared to 40 years old? Are these two differences the
same? Why or why not?
1
docsity.com
pf2

Partial preview of the text

Download Logistic Rgression - Sociology - Lecture Notes and more Study notes Sociology in PDF only on Docsity!

Sociology 362 Data Exercise 5 Logistic Regression 1

The purpose of this problem set is to help you gain a feel for modelling a binary dependent variable and for moving between the different scales (log-odds, odds, and probability).

The form of the data below is “grouped” because we do not have observations on individuals, but rather on sets of individuals who have been grouped by their age. For each group, we know how many individuals are in it, and how many had y = 1 (and, by subtraction, how many had y = 0). In fact, the data have the same form as the data for the handout entitled real simple logit analysis, except instead of 2 categories of the independent variable “sex,” we have here 8 categories of the independent variable “age.”

age nj rj 20 704 21 25 628 32 30 775 70 35 338 43 40 784 46 45 789 89 50 1016 169 55 434 98

where nj is the number of people in the sample from the jth age category and rj is the number who have consumed psychotropic drugs in the last week. These data will have to be entered into Stata e.g., input age n r, which you will use to do the following problems.

  1. For each age group, compute the proportion rj /nj who are on drugs and the odds rj /(nj − rj ) of being on drugs. How do these proportions and odds vary with age? Use the list command to view them.
  2. For each age group, compute the ln(odds), i.e., ln(rj /(nj − rj )), of being on drugs. What appears to be the effect of age on the ln(odds) (otherwise know as the logit(πj ), where π is the probability of being on drugs)?
  3. Using Stata, fit by least-squares the linear probability model by regressing the proportion who used drugs on age, i.e, regress prop age. (I named my proportion variable prop; your’s may have a different name.) Interpret the age coefficient.
  4. Fit by least-squares the logit model for the ln(odds) as a function of age, i.e., regress lgodds age. (I named my ln(odds) variable lgodds). Interpret the age coefficient.
  5. Using Stata, fit by maximum likelihood the logit model for the effect of age on drug use. The command will take the form blogit r n age. How does the age coefficient you obtained compare to the least-squares estimate from problem 4? Do these coefficients have the same interpretation even though they were generated by different estimators?
  6. Based on the MLE results:

a) Interpret the coefficient of age in terms of the effect of age on 1) the ln(odds); 2) the plain odds of being on drugs; and 3) the probability πj of being on drugs.

b)Find the fitted odds that someone age 35 is on drugs and compare it to the fitted odds that someone

who is 34 is on drugs. Does the ratio of the first to the second fitted odds equal e βˆ^?

c) What is the expected difference in π for people who are 20 compared to 30 years old? What is the expected difference in π for people who are 35 compared to 40 years old? Are these two differences the same? Why or why not?

docsity.com

d) Compute the rest of the fitted probabilities ˆπj by hand (that is how you will need to do it on a test) and compare them to the observed proportions. (As a check on your computations, after the blogit command issue the command predict prob,p, where prob is the name you made up for the fitted probabilities.) Are the model probabilities a perfect fit to the observed proportions as they were on the handout real simple logit analysis? Why or why not?

docsity.com