logistic regression

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:02 AM on 4/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

8 Terms

1
New cards

when to use

  • outcome (y) is a category, not a number

  • Binary: 0 or 1, Yes/No, Buy/Not Buy.

  • The model predicts probability of the event (y=1) occurring.

2
New cards

fitting

  • fit <- glm(y ~ x1 + x2, data=df,

  • family=binomial(link="logit"))

  • summary(fit)

  • Uses glm() not lm(). The family=binomial argument is what makes it logistic.

3
New cards

predictions

  • predict.glm(fit, newdata=new_df, type="response") # probability (0-1)

  • predict.glm(fit, newdata=new_df, type="link") # log-odds

4
New cards

using to classify

  • probs <- predict.glm(fit, newdata=df, type="response")

  • predicted <- ifelse(probs >= 0.5, "Yes", "No")

5
New cards

evaluating model

  • library(caret)

  • confusionMatrix(predicted_factor, actual_factor)

  • Gives accuracy, sensitivity (true positive rate), specificity (true negative rate), precision. A model can have high accuracy but be bad at one class.

6
New cards

interpreting coeff.

  • exp(coef(fit)) # convert log-odds to odds ratios

  • Coefficients are in log-odds (hard to interpret directly). After exp(): a value of 1.5 means the odds of y=1 are 1.5× higher per unit increase in x. Sign tells direction: positive = increases probability, negative = decreases it.

7
New cards

multinomial

  • library(nnet)

  • fit <- multinom(y ~ x1 + x2, data=df)

  • summary(fit)

  • Same idea as binary logistic but for 3+ outcome categories. One category is the baseline; all others are compared to it.

8
New cards

model selection

  • null <- glm(y ~ 1, data=df, family=binomial)

  • full <- glm(y ~ ., data=df, family=binomial)

  • step(full, direction="backward") # same stepwise process as lm()