Computing Wald statistic
In the previous exercise you fitted a model with width
variable and assessed the relationship of the explanatory and response variable. In this exercise you will assess the significance of the width
variable by computing the Wald statistic.
Also note that in the model summary the Wald statistic is presented by the letter z
which means that the value of a statistic follows a standard normal distribution. Recall the formula for the Wald statistic:
$$ z=\frac{\hat\beta}{SE} $$
where \(\hat\beta\) is the estimated coefficient and \(SE\) its standard error.
The fitted model crab_GLM
and crab
dataset have been preloaded in the workspace.
Este exercício faz parte do curso
Generalized Linear Models in Python
Instruções do exercício
- Using
.params
extract and print model coefficients and save as intercept and slope. - Save and print covariance matrix as
crab_cov
. - Compute and print the standard error
std_error
by extracting the relevant element using the covariance matrix. - Compute and print the Wald statistic.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Extract coefficients
intercept, slope = ____.____
# Estimated covariance matrix: crab_cov
____ = crab_GLM.____
print(____)
# Compute standard error (SE): std_error
____ = np.____(____.loc['width', 'width'])
print('SE: ', round(____, 4))
# Compute Wald statistic
wald_stat = ____/____
print('Wald statistic: ', round(____,4))