Get startedGet started for free

Long-form logistic regression input

As you learned in the video, a binomial regression can take inputs in three different formats. The first requires data to be in "long" format and directly models each observation (e.g. a response of numeric 0/1 or a factor of yes/no):

  x    y
1 a fail
2 a fail
3 b success
4 b fail
...

In this format, the formula response predicted by predictor (or response ~ predictor in R's formula syntax) is used. During this exercise, you'll fit a regression using this format.

This exercise is part of the course

Generalized Linear Models in R

View Course

Exercise instructions

  • Fit a logistic regression using the data.frame data_long with y being predicted by x.
  • Save the output as lr_1.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Fit a a long format logistic regression
lr_1 <- ___
print(lr_1)
Edit and Run Code