For independent patients, the Bernoulli logistic-regression model is
where with nonfrail patients as the reference level in a regression factor. The fitted linear predictor is
The null model fits one intercept, so its 99 residual degrees of freedom imply 100 patients; the full model's confirms this. Unit weights correspond to individual binary responses, not grouped binomial counts.
The Akaike information criterion estimates expected relative out-of-sample discrepancy, using the maximized log-likelihood plus a complexity penalty:
Here , since the Bernoulli dispersion is fixed at one. The saturated model puts probability one on each observed binary outcome and has log likelihood zero, so the binomial deviance is . Consequently
There is no estimated error-variance parameter to count. The printed name “Aikake” should be read as Akaike.
For word-count vector , the fitted logistic model is
Holding other counts fixed, one additional occurrence of "dollar" multiplies the fitted spam odds by .
The logistic classifier is
The coefficients maximize the Bernoulli logistic-regression model likelihood over the training emails.
The code fits a Bernoulli logistic-regression model. Conditionally on the covariates, the responses are independent with
where the design includes the displayed numerical predictors and indicator columns for factor levels. It maximizes
Akaike information criterion is
where is the number of fitted parameters. Backward stepwise selection starts from the full model, tentatively removes each eligible term, chooses the removal producing the lowest AIC, and repeats while AIC decreases. It balances fit against model size rather than testing every coefficient at a fixed significance threshold.
The commands choose observations and predictors; generate a matrix of independent standard-normal values; generate independent binary random variables with success probability ; and report the observed number of successes, . The first glm call then fits the Bernoulli logistic-regression model
The prediction command returns the fitted response probabilities and sums them.
The likelihood is
At the maximum-likelihood estimator, the intercept component of the score function is
Therefore
exactly, by the fitted-mean balance for logistic regression with an intercept.
The second fit uses probit regression,
where is the standard normal distribution function. Its intercept score is
a weighted residual equation. It does not imply , so exact equality is not expected. The output should nevertheless be close to : the data were generated with constant success probability independently of , so the fitted slopes should be small, the linear predictors should cluster near a common intercept, and the score weights should be nearly constant.