I try to understand the forest test in logistic regression, but when I use the formula, I get something else.

The formula I use is the following:

S = (X^{t}VX)^{-1}

Where X is the matrix *r x k + 1* of the independent variable (with the constant first) and V is the diagonal matrix whose elements are v_{ii} = p_{I}(1-p_{I}), his *p* the calculated probability for each element. The square roots of the diagonal elements would be the standard deviations of the parameters.

I've gotten it from http://www.real-statistics.com/logistic-regression/significance-testing-logistic-regression-coefficients/, but basically it's basically the same thing I saw.

Now I am trying to work through this formula, and it gives me something other than what a model would bring me.

Use R to create a random data record:

```
set.seed (5674)
test <- cbind.data.frame (a = sample (seq (0,3, length.out = 5000), size = 1000,
replace = TRUE),
b = sample (seq (0.3, length.out = 5000), size = 1000,
replace = TRUE),
c = sample (seq (0.3, length.out = 5000), size = 1000,
replace = TRUE),
d = sample (seq (0.3, length.out = 5000), size = 1000,
replace = TRUE),
e = sample (seq (0.3, length.out = 5000), size = 1000,
Replace = TRUE))
test $ y <- sapply (1: 1000, function (x) {
ex <- exp (0.3 * test $ a[x] + 0.25 * test $ b[x] - 0.4 * test $ c[x] -
0.15 * test $ d[x] - 0.05 * test $ e[x])
x1 <- ex / (ex + 1)
x2 <- 1 / (ex + 1)
t <- sample (0: 1, size = 1, prob = c (x2, x1))
Return (t[1])
})
```

Now I create the model and get the predicted probability:

```
Model <- glm (y ~ a + b + c + d + e, data = test)
w <model $ adjusted.values
w1 <- w * (1-w)
```

Then I use the formula I gave earlier to get the variances matrix covariances:

```
Matrix <- cbind (cons = rep (1,1000), as.matrix (test[,1:5]))
matrix1 <- apply (array, 2, function (x) {x * w1})
Variance <- t (Matrix1)% *% Matrix
Variance1 <- solve (variance)
sqrt (varance1[1,1])
```

The last line displays the standard deviation of the variable a. It gives me that:

```
[1] 0.07855672
```

What is different from what the model says to me:

```
Summary (model)[[12]]
```

```
Estimated standard error t value Pr (> | t |)
(Section) 0.46125485 0.06153214 7.6261742 5.641569e-14
to 0.08539726 0.01776354 4.8074451 1.764783e-06
b 0.06246717 0.01793220 3.4835200 5.164320e-04
c -0.09870667 0.01752367 -5.6327620 2.307966e-08
d -0.04879819 0.01752240 -2.7849038 5.456082e-03
e -0.01540819 0.01715283 -0.8982882 3.692495e-01
```

Is there an error in the formula?