1. LON-CAPA Logo
  2. Help
  3. Log In
 

Browsing resource, all submissions are temporary.


glm() Practice: Text Ban

This question is essentially the same as one of Stat 200's HW problems.

A total of 618 students responded to a Stat 100 survey in Fall 2009. Three of the questions asked were:

  1. About how many times do you text per hour of driving on the average?
  2. Do you think there should be a law against texting while driving? (0=No, 1=Yes)
  3. Are you male or female? (0=Male, 1=Female)

Instead of using the whole data of 618 students, 520 students are chosen randomly from the survey data by the computer. Copy and paste the following code to your R console. These are the subset of data chosen by the computer.

# Text ban? 1=yes; 0=no
text_ban <- c(1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 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0, 6, 5, 5, 10, 2, 1, 5, 1, 0, 13, 60, 0, 8, 13, 3, 6, 0, 2, 10, 4, 1, 0, 3, 3, 5, 1, 10, 3, 5, 2, 1, 7, 0, 10, 0, 1, 1, 3, 10, 10, 0, 0, 30, 6, 4, 2, 1, 0, 30, 5, 2, 6, 1, 2, 1, 1, 1, 4, 2, 0, 5, 3, 5, 2, 3, 8, 2, 0, 3, 1, 0, 25, 0, 15, 0, 10, 2, 3, 6, 8, 3, 0, 0, 9, 1, 10, 0, 0, 10, 1, 1, 3, 0, 4, 26, 20, 18, 14, 7, 1, 1, 2, 4, 2, 2, 40, 3, 2, 24, 8, 0, 5, 3, 4, 4, 2, 15, 10, 0, 0, 1, 0, 10, 0, 1, 0, 0, 1, 20, 1, 4, 5, 3, 8, 3, 0, 1, 20, 10, 3, 8, 20, 2, 1, 0, 2, 0, 0, 0, 6, 0, 0, 2, 4, 20, 1, 0, 5, 1, 6, 3, 0, 3, 1, 4, 0, 2, 3, 3, 5, 2, 20, 5, 1, 20, 6, 5, 22, 27, 20, 1, 1, 0, 3, 1, 0, 1, 6, 3, 0, 4, 7, 10, 5, 7, 3, 0, 4, 0, 2, 1, 1, 5, 2, 0, 0, 0, 0, 2, 5, 10, 10, 0, 5, 9, 5, 10, 26, 4, 0, 2, 10, 1, 4, 1, 8, 1, 4, 3, 1, 4, 1, 10, 20, 10, 3, 3, 1, 2, 2, 5, 2, 4, 1, 3, 1, 0, 7, 3, 1, 10, 2, 1, 2, 5, 7, 0, 0, 50, 25, 6, 6, 2, 0, 1, 4, 10, 8, 5, 1, 1, 2, 2, 2, 3, 0, 3, 3, 5, 1, 6, 2, 10, 10, 4, 5, 1, 5, 5, 10, 3, 14, 1, 0, 1, 3, 10, 4, 45, 1, 0, 8)


a. Fit a logistic regression model predicting 'text ban' from Gender and number of texts per hours. Fill in the following table below and give your answers to 4 significant figures.

Coefficients Std. Error Z p-value
Intercept 1.52e-05
Gender 0.0002869
texts 2.067e-06
 Tries 0/5

b. Are females more or less likely to be for a text ban than males given the same texting frequency?




 Tries 0/2

c. The more texts per hour the ___________ the probability of being for a text ban given the same sex.




 Tries 0/2

d. Use the predict() function to calculate probability of being for a text ban for the individuals in the table below:

Round all answers to 3 decimal places.
Gender (0=Male; 1=Female) Texts/hr p
Male 0
Female 2
Male 8
Female 7
 Tries 0/5