Coëfficiënten interpreteren

Generalized Linear Models in Python

Ita Cirovic Donev

Data Science Consultant

Modelcoëfficiënten

Statistische samenvatting van het fitte model, met de kolom coef gemarkeerd.

Generalized Linear Models in Python

Coëfficiënt beta

  • $\beta > 0 \rightarrow$ stijgende curve

Logistische model-fit van arsenic en switch.

  • $\beta < 0 \rightarrow$ dalende curve

Logistische model-fit van distance100 en switch.

Generalized Linear Models in Python

Lineair vs. logistisch

LINEAIR MODEL

glm('y ~ weight', 
    data = crab, 
    family = sm.families.Gaussian())

$\mu = -0.14 + \color{#B21AB4}{0.32}*weight$

Voor elke toename van weight met 1

  • $\text{\color{#B21AB4}{geschatte kans}}$ stijgt met 0.32

LOGITMODEL

glm('y ~ weight', 
    data = crab, 
    family = sm.families.Binomial())

$log(odds) = -3.69 + \color{#228FF5}{1.8}*weight$

Voor elke toename van weight met 1

  • $\text{\color{#228FF5}{log(odds)}}$ neemt toe met 1.8
Generalized Linear Models in Python

Interpretatie van log-odds

  • Logistisch model $$ log(\frac{\mu}{1-\mu}) = \beta_0 + \beta_1x_1 $$

  • Verhoog $x$ met één eenheid $$ log(\frac{\mu}{1-\mu}) = \beta_0 + \beta_1\color{blue}{(x_1+1)} $$

Generalized Linear Models in Python

Interpretatie van log-odds

  • Logistisch model $$ log(\frac{\mu}{1-\mu}) = \beta_0 + \beta_1x_1 $$

  • Verhoog $x$ met één eenheid $$ log(\frac{\mu}{1-\mu}) = \beta_0 + \beta_1\color{blue}{(x_1+1)} = \beta_0 + \color{blue}{\beta_1x_1+\beta_1} $$

  • Neem de exponent $$ (\frac{\mu}{1-\mu}) = \color{red}{\exp(\beta_0 + \beta_1x_1)}\color{blue}{\exp(\beta_1)} $$

Conclusie $\rightarrow$ de $\color{red}{\text{odds}}$ worden vermenigvuldigd met $\color{blue}{\exp(\beta_1)}$

Generalized Linear Models in Python

Interpretatie van log-odds

  • Krabmodel y ~ weight $$ log(\frac{\mu}{1-\mu}) = -3.6947 + \color{blue}{1.815}*weight $$

  • De odds op een satellietkrab worden $\color{blue}{\exp(1.815) = 6.14}$ keer zo groot bij een toename van weight met 1

Generalized Linear Models in Python

Interpretatie van log-odds

  • Krabmodel y ~ weight $$ log(\frac{\mu}{1-\mu}) = \color{blue}{-3.6947} + 1.8151*weight $$

  • De odds op een satellietkrab worden $\exp(1.8151) = 6.14$ keer zo groot bij +1 in weight

  • De intercept $\color{blue}{-3.6947}$ is de baseline log-odds
    • $\color{blue}{\exp(-3.6947)=0.0248}$ zijn de odds bij $weight = 0$.
Generalized Linear Models in Python

Kans vs. logistische fit

Logistische fit op de spreiding van studeertijd vs. geslaagd/gezakt.

Generalized Linear Models in Python

Kans vs. logistische fit

Kleine verandering in kans t.o.v. de logistische fit en de waarde van de verklarende variabele.

Generalized Linear Models in Python

Kans vs. logistische fit

Grote verandering in kans t.o.v. de logistische fit en de waarde van de verklarende variabele.

  • helling $\rightarrow \beta \times \mu(1-\mu)$
Generalized Linear Models in Python

Kans vs. logistische fit

Grootste verandering in kans t.o.v. de logistische fit en de waarde van de verklarende variabele.

  • helling $\rightarrow \beta \times \mu(1-\mu)$
Generalized Linear Models in Python

Verandering in geschatte kans berekenen

# Choose x (weight) and extract model coefficients
x = 1.5
intercept, slope = model_GLM.params
# Compute estimated probability
est_prob = np.exp(intercept + slope * x)/(1 + np.exp(intercept + slope * x))
0.2744
# Compute incremental change in estimated probability given x
ic_prob = slope * est_prob * (1 - est_prob)
0.3614
Generalized Linear Models in Python

Veranderingssnelheid van kans per x

$logit = -3.6947 + 1.8151*weight$

Generalized Linear Models in Python

Laten we oefenen!

Generalized Linear Models in Python

Preparing Video For Download...