How to compare nested logit models using ANOVA in R?

I have two models binomial logit:

modelo_logit_viv <- glm( SAP ~sexo + edad + peso + niv_est + enf_cron +  sit_lab +
                           frec_act_fis   + GHQ_12 + ingreso_eq +
                           n_dormitorios + cont_indus +    delincuencia, # variables de estudio
                         data = datos_modelo, family = binomial(link = "logit"),na.action = "na.omit")
  • Model B (nested model A):
modelo_logit <- glm(SAP ~ sexo + edad + peso + niv_est + enf_cron  +  sit_lab + 
                       frec_act_fis   + ingreso_eq + GHQ_12, 
                       data = modelo_logit_viv$model, family = binomial(link = "logit"))

c(edad, peso, ingreso_eq, GHQ_12) These are continuous variables, the others are categorical (factor) variables.

I want to analyze whether the characteristics of housing (study variables) have an influence on self-rated health status (SAP). All variables are significant in both models. However, I would like to perform an analysis of variance (ANOVA) between these two models to check that model B is better than model B. I therefore execute:

anova(modelo_logit,modelo_logit_viv)

And I get the following table:

  Resid. Df Resid. Dev Df Deviance
1     16805      15439            
2     16802      15420  3   18.644

Can the interpretation of this table tell me if there is an influence between the characteristics of the accommodation and the state of health?

Another way to ask this question is: 18.644 the F test statistic that I need to compare with the Snedecor F table to determine whether or not to accept the null hypothesis that there are mean differences between the two models?

How else to compare these two models with an ANOVA in R?

probability or statistic – Trust bands around the Logit model

I would like to generate and plot the 95% confidence intervals for the logistic model code adjusted below, with a filling between the mean curve and its upper and lower bands. Appreciate the suggestions !!

Clear[data, se, a, b]
data = {{1, 1}, {2, 0.75}, {3, 0.611111111}, {4, 0.611111111}, {5, 
    0.611111111}, {6, 0.416666667}, {7, 0.416666667}, {8, 
    0.666666667}, {9, 0.535353535}, {10, 0.45508658}, {11, 
    0.387598676}, {12, 0.340230255}, {13, 0.215230255}, {14, 
    0.188271007}, {15, 0.187838107}, {16, 0.224308695}, {17, 
    0.229369424}, {18, 0.235463951}, {19, 0.2488416}, {20, 
    0.248417357}, {21, 0.206599175}, {22, 0.174664443}, {23, 
    0.171198551}, {24, 0.163201729}, {25, 0.150447012}, {26, 
    0.164363959}, {27, 0.166265958}, {28, 0.140662245}, {29, 
    0.128777833}, {30, 0.129944921}, {31, 0.123349511}, {32, 
    0.111959778}, {33, 0.111616813}, {34, 0.102635032}, {35, 
    0.086485736}, {36, 0.075479421}, {37, 0.07383027}, {38, 
    0.081188587}, {39, 0.090044466}, {40, 0.084028814}, {41, 
    0.096462466}, {42, 0.087077379}};
Length[data]
lm = LogitModelFit[data, x, x];
Normal[lm]
lm["ParameterTable"]
lm["ParameterConfidenceIntervalTable", ConfidenceLevel -> 0.95]
Plot[lm[x], {x, 1, 60}, Epilog :> Point[data], 
 PlotStyle -> {Red, Thin}]

logistic regression – Derive the conditional distribution $ P (X | Y) $ from a logit model

Let's say we have two random variables $ X_1 sim N ( mu, sigma ^ 2) $ and $ X_2 sim Bern (0.5) $. The binary result variable $ Y $ is generated from
begin {align}
P (Y = 1 | X_1, X_2) = frac {e ^ { beta_0 + beta_1X_1 + beta_2 X_2}} {1 + e ^ { beta_0 + beta_1X_1 + beta_2 X_2}}
end {align}

$ Y sim Bern (P (Y = 1 | X_1, X_2)) $

Is there a simple way to calculate the conditional distributions of $ P (X_1 | Y = 1) $,$ P (X_1 | Y = 0) $,$ P (X_2 | Y = 1) $,$ P (X_2 | Y = 0) $? I think both $ X_1 $ and $ X_2 $ will keep the original distributions (Normal is still normal, Bernoulli is still Bernoulli).

We can make the conditional independence assumption if necessary. that is to say., $ P (X_1, X_2 | Y) = P (X_1 | Y) P (X_2 | Y) $.

The composition of the logit function and its inverse is not numerically invariant with respect to the decimal place

I have defined the following two functions:

logit[x_] : = Module[{},
   Log[x/(1 - x)]
   ];
invLogit[x_] : = Module[{},
   E^x/(1 + E^x)
   ];

One is the reverse of the other. however,

In[37]: = logit[invLogit[34.55555]]Outside[37]= 34.6574

Is it possible to increase the accuracy of calculations?