Backfitting algorithm Created 2026-10-06 Updated 2026-10-14
The backfitting algorithm estimates each additive mean function by smoothing its partial residual, obtained after subtracting the current fits of all other terms, and cycling through terms until convergence. Centering each smooth separates its constant part from the intercept. For fixed quadratic smoothness penalties it is block coordinate minimization of a penalized least-squares objective; identifiability and positive definiteness of the constrained problem ensure a unique converged fit. Non-Gaussian generalized additive models can use weighted backfitting inside iteratively reweighted least squares.
For logistic regression, set and . Its Bernoulli log-likelihood, score function and Fisher information are
where . Solve by Fisher scoring or iteratively reweighted least squares. One scoring step is
Equivalently regress the working response on using weights . Iterate until the likelihood and coefficients stabilize, with rank and convergence checks. Separation in logistic regression can prevent a finite maximum: if a predictor direction strictly separates the zeros and ones, moving indefinitely along it improves the likelihood rather than producing a finite root.
Under the unrestricted model, each individual probability is estimated independently as . Every observed binary outcome then has probability one, so, using boundary limits,
The resulting residual deviance is . It is a legitimate likelihood contrast and can be used to compare fitted models. However, individual Bernoulli deviance need not have a chi-squared calibration: the saturated model has one boundary-valued parameter for each single observation, and its dimension grows with . The fixed-dimensional regularity behind Wilks theorem does not justify a reference here.
For a concrete demonstration, let the true model contain only an intercept and have success probability . Its fitted probability is , and
whereas a variable divided by converges to one. Thus treating the raw Bernoulli residual deviance as an ordinary absolute goodness-of-fit statistic can reject a correct model systematically. In contrast, deviance differences between fixed-dimensional nested logistic models have their usual asymptotic chi-squared reference under the relevant regularity assumptions. For absolute fit use meaningful replicated covariate groups and grouped-binomial logistic regression, or assess residual patterns and prediction on held-out data; a model-specific parametric bootstrap can calibrate a chosen statistic.
Use for the expected accident count, not for the accident rate. With a design row consisting of an intercept, seven non-reference site indicators and the after-treatment indicator,
Here is a known generalized linear model offset, with coefficient fixed at one. Differentiating the Poisson regression log-likelihood gives the score function equations
These nine equations estimate the intercept, seven site contrasts and one treatment contrast, with the stated reference-level constraints.
The Fisher information is , where . A Fisher scoring update adds to the current coefficient vector. In iteratively reweighted least squares, the working response is ; regress on the design with weights . Thus the reported four iterations solve the likelihood equations while accounting for unequal exposure periods.
The common adjusted rate ratio is obtained by exponentiating the after coefficient:
This estimates a lower accident rate after the intervention, conditional on the additive site model. The standard error gives normal Wald statistic , two-sided , and an approximate confidence interval for the rate ratio
The label t value is again a normal-reference Wald ratio under fixed Poisson dispersion, rather than an exact Student statistic.
The intercept gives the before rate at reference site one: accidents per year. The seven site coefficients are log baseline-rate ratios relative to that site. In site order two through eight, their exponentials are about . The third site has the largest estimated rate and a nominal Wald ratio about against the reference. These are adjusted baseline comparisons, not differences in absolute accident counts. The overall unadjusted before/after rate ratio is , and it differs from because site risks and their relative exposure weights differ.
An independent way to solve the fit is the profile likelihood for a common Poisson rate ratio with unequal exposures. Put and . For fixed , the site score gives . The remaining equation is
Its positive root reproduces the reported treatment estimate. Comparing the same site model with to the fitted model gives a deviance improvement about on one degree of freedom, with nominal likelihood-ratio .
There are count observations and fitted mean parameters, leaving residual degrees of freedom. The null deviance on degrees of freedom is for the intercept-only rate model, still including the exposure offset. The residual Poisson deviance is on degrees of freedom. A chi-squared comparison gives approximately , suggesting potential lack of fit of a single common treatment ratio; the extreme deviance residuals near and also deserve inspection. Several after-cell expected counts are below one or near two, so this absolute-fit calibration is only approximate. Site-specific treatment effects, overdispersion or temporal dependence are possible explanations to investigate, with a parametric bootstrap available to calibrate the sparse-count fit statistic. A before/after association alone does not isolate a causal effect from secular changes or regression to the mean at selected sites.
Let be the design matrix with row , let , and write . Independence gives the Poisson regression likelihood function
The score function and negative Hessian matrix are
Because , the score has mean zero; independence and the Poisson distribution variance give . Thus the observed and expected Fisher information matrices are the same here.
Assume has full column matrix rank . For a nonzero vector , . The concavity of the Poisson regression likelihood therefore makes any finite solution of the unique maximum-likelihood estimator. If the design is rank deficient, parameters differing by a vector in give the same distribution, so only identifiable combinations can be estimated. Full rank alone does not ensure a finite maximizer: for an intercept-only model with all observations zero, approaches its supremum as . More generally, directions that decrease only fitted means attached to zero counts can produce boundary fits. A useful sufficient case for a finite fit is full rank with every count positive: each summand tends to in either tail, and some diverges whenever diverges.
For an interior fit, Newton's method and Fisher scoring give the same update:
This is also iteratively reweighted least squares. Define the working response , with , and regress on using weights :
A numerical implementation solves these linear equations rather than explicitly forming the inverse, checks convergence of the score and likelihood, and can shorten a step when necessary.
Under the usual fixed-design regularity conditions, with growing information and no single observation dominating it, a score Taylor expansion about the true parameter gives
Estimate the covariance matrix by ; its diagonal square roots are the coefficient standard errors. This justifies large-sample Wald confidence intervals and Wald tests for specified coefficients or contrasts. Finite-sample unbiasedness is not being asserted. A likelihood-ratio test compares nested fits through twice their maximized log-likelihood difference. The Poisson deviance against the saturated fit is
with . Residual diagnostics and a check of overdispersion assess whether the assumed Poisson variance is adequate; the variance correction required when it is not is derived in the next part.
Use the logit link and independent counts . This gives a grouped-binomial logistic regression with 24 cells and 13 free coefficients: an intercept, 11 centre contrasts, and one period contrast. Reference treatment coding makes the intercept the log odds for Centre 1 in the earlier of the two included periods. The two factors are assumed to have been coded as specified in the question.
The binomial log-likelihood, apart from known constants, is
Maximize by Fisher scoring or iteratively reweighted least squares. Using response proportions with binomial trial weights is equivalent to using the count response ; omitting those weights would give the wrong likelihood and standard errors. The coefficient covariance matrix is approximately the inverse of .
The fitted reference log odds are , and the period change is , giving
These are fitted probabilities under a common period effect, so they need not equal the separate empirical proportions at Centre 1. The estimated period odds ratio is
Thus the later-period death odds are estimated to be about 35% lower at each centre, with strong evidence of a period effect: the normal Wald statistic is . The displayed “t value” is a coefficient divided by its standard error; with fixed binomial dispersion its usual large-sample calibration is standard normal, not a Student distribution with an estimated Gaussian-error variance. The odds ratio is not a mortality probability ratio.
Each centre coefficient is a log odds ratio relative to Centre 1, adjusted for period. All its point estimates are negative, so all other centres have lower fitted mortality probabilities in either period. For example, Centre 11's odds ratio is , or about times greater odds at Centre 1 than at Centre 11. Individual unadjusted two-sided Wald tests find significant differences at the 5% level for centres 2, 4, 6, 7, 8, 9, 11 and 12; the coefficients for 3, 5 and 10 do not individually reach that threshold. These separate tests are correlated comparisons against a common reference and should not be presented as 11 independent discoveries without considering multiple testing. They adjust only for time period, not for differing patient case mix.
For fit assessment, the residual binomial deviance is on statistical degrees of freedom. Its upper tail is approximately , so there is no appreciable evidence of lack of fit to these binomial cell counts. In particular, comparing with a saturated centre-by-period model gives this same deviance and 11 additional parameters; the data do not strongly require a centre-period interaction. The moderate deviance residuals are consistent with that assessment, although a residual plot by centre and period would be more informative than the five-number summary alone.
The reduction from null to fitted deviance is
It tests the 12 centre-and-period coefficients jointly against an intercept-only model, with reference and . It is not a centre-only test adjusted for period. For that test, fit the period-only model and compare its deviance with the full fit: the pooled binomial probabilities in each period give deviance , so
Thus centre heterogeneity persists after allowing for period. Dispersion one is the stipulated binomial variance, and the five scoring iterations describe numerical convergence rather than statistical evidence. The fitted associations alone do not establish a causal difference in surgical quality.
The command fits independent grouped binomial distributions , using the supplied totals as trial counts. The logistic regression has the additive linear predictor
The reference category is adult females. The age and gender coefficients are conditional log odds ratios: the fitted odds for a child are multiplied by , and those for a male by .
The coefficients are maximum-likelihood estimates, found by Newton's method or iteratively reweighted least squares. With design matrix and , the estimated covariance matrix is ; the printed standard errors are square roots of its diagonal entries. Each Wald test compares a coefficient with zero using its estimate divided by its standard error, approximately a standard normal distribution under the null. The age and gender effects are strongly significant. The intercept test instead tests whether the reference probability is .
The fitted probabilities are about for adult females, for adult males, for female children, and for male children. Adult females have the largest fitted probability, about 4.48%. The residual deviance is on degree of freedom; comparison with a chi-squared distribution gives . There is no evidence here that an age–gender interaction is needed, under the assumed independent binomial distribution model.
Write and . Differentiating gives , so
In the independent exponential dispersion family, only depends on . Its derivative therefore gives the score function
The residuals are independent, have mean zero and variance . Consequently their score covariance is the Fisher information matrix:
This also equals minus the expected likelihood Hessian under the usual regularity conditions.
For the canonical link function, and , so
To obtain the maximum-likelihood estimate, solve , for example with Fisher scoring iterations . Equivalently use iteratively reweighted least squares, with weights and working response . Since , the common dispersion scale cancels from this update for . A nonsingular information matrix and a finite interior likelihood maximum are needed; iteration does not assert those for every possible dataset.
Let be passenger count and use a Poisson regression with log mean, initially treating the response as a working daily count:
Center and scale the continuous predictors before fitting, and compare a small set of defensible reduced models rather than saturating twenty observations. Household counts should not be called household proportions without a household denominator; population-scaled counts are alternative intensity covariates. Bus miles can be an estimated elasticity term rather than an offset, since proportionality of passenger numbers to bus miles has not been established.
For actual counts, the log-likelihood score is , with . Fitting by iteratively reweighted least squares uses weights and working response . Compare nested means by a likelihood-ratio test only if the Poisson variance assumption is plausible; check the Poisson deviance, Pearson dispersion , residuals, leverage and sensitivity to influential providers. Consider Quasi-Poisson regression or negative binomial regression if variance exceeds the mean.
The recorded response is actually a daily average, so Poisson working models for averaged counts need special care. If a provider was observed for days and total passengers were , fit with offset . If only the average and no observation duration are available, a Poisson mean model can still be explored, but its likelihood and standard errors are not automatically justified by integer-looking averages.
A one-unit increase in an untransformed predictor has fitted multiplicative mean effect ; a bus-mile elasticity gives a doubling effect . No numerical coefficient estimates or selected twenty-provider model are identifiable from the printed excerpt. The full provider file and, ideally, the averaging periods are needed to execute these model comparisons.
For the Poisson regression, the log-likelihood is
Since , the score function and its derivative are
Consequently a finite maximum-likelihood estimator satisfies
These nonlinear equations are normally solved by iteratively reweighted least squares. If has full column rank, the Hessian is negative definite and any finite solution is the unique maximizer. Full rank does not by itself rule out a boundary solution at infinite coefficients for every conceivable data set. The Poisson generalized linear model has dispersion one, so there is no separate scale parameter in this likelihood.
Use the backfitting algorithm to alternate conditional updates of the two additive functions. Initialize and both centered function vectors at zero. With the smoothing matrices for the chosen experience and education spline penalties, one cycle is
followed by
The centering transfers any constant component to the intercept; update to the mean of if necessary, which is under the stated constraints. Repeat until changes in the functions or objective are negligible. Each function is estimated by smoothing its partial residual, namely the response after subtracting all other currently fitted terms.
For fixed penalties these updates are block minimizations of
subject to the centering constraints. Each step cannot increase the objective; with identifiable additive terms and a positive-definite constrained quadratic, backfitting converges to its unique minimizer. Highly dependent predictors can make the decomposition poorly identified or slow convergence. The Gaussian identity-link model needs these least-squares updates directly; non-Gaussian generalized additive models use weighted backfitting inside iteratively reweighted least squares. The package implementation also separates each spline's unpenalized linear component from its nonlinear component, giving the two ANOVA tables displayed in part (e).
For EM for zero-inflated negative binomial regression, at iteration apply Bayes' theorem to each zero in the zero-inflated negative binomial model. The E step computes the conditional expectation of its latent indicator:
Treating these values as fixed, the M step maximizes the expected complete-data log-likelihood. Its two parameter blocks separate:
The second block is a weighted negative binomial regression with fixed size . Writing and , its parameter-dependent objective is
Its score function and negative Hessian matrix are
The objective is concave, so a finite maximizer, when it exists, can be found by Newton method or iteratively reweighted least squares. The latter uses working response and weights . This is not an unweighted regression on only the positive counts: zeros retain fractional weight in the count component.
Start with and finite coefficients, alternate the two steps, and monitor the observed log-likelihood. Exact maximization makes the expectation-maximization algorithm nondecreasing in that likelihood, although the mixture may have multiple stationary points. All-zero data can lead to boundary fits and poor identification; multiple initializations and explicit checks for boundary parameters are useful.
The quasibinomial regression retains the logit link and mean function but uses the working variance function . Its quasi-score equation is
so multiplying by the common dispersion parameter does not change the coefficient estimates. Iteratively reweighted least squares therefore gives the same fitted means and coefficients as the binomial model. The usual Pearson dispersion estimator is
The estimated coefficient covariance matrix is , with . From the intercept standard errors, ; the rounded slope errors give approximately the same factor. The display uses approximate Student's t-tests with 118 residual degrees of freedom instead of fixed-dispersion normal tests.
For a genuinely individual binary response, the Bernoulli distribution identity forces . Thus is a working quasi-likelihood specification, not a different independent binary distribution with that mean. The mild estimated underdispersion does not establish an improved model, and the mean predictions are unchanged. In particular, a scalar rescaling does not model correlation among users, and usual likelihood-based Akaike information criterion comparisons are unavailable for a family without a specified probability likelihood. The output gives no convincing reason to prefer model3 to model2.
Write for the log-likelihood and for the score function. Newton method uses the observed Fisher information ; Fisher scoring uses the Fisher information .
For independent responses in an exponential family, with fixed dispersion parameter and fixed weights , a canonical link function gives and
The last matrix depends on but not on the responses, so taking its expectation leaves it unchanged. Hence the two updates are identical, wherever this Fisher information matrix is invertible. Equivalently both solve the same iteratively reweighted least squares problem. This statement concerns the regression coefficients at a fixed dispersion parameter; a joint update of an unknown dispersion parameter need not have identical observed and expected full Fisher information matrices.
At a current value , put
and define the working response
Then the displayed formulas in the question can be written compactly as
and
Indeed, the th component of the latter is
which is precisely the stated score.
Substitution into the Fisher-scoring update gives
By part (b), this is the weighted least squares fit of the working response on . Both and are recomputed from the current fitted means after every update. Fisher scoring for a generalized linear model is therefore the iteratively reweighted least squares algorithm.
The estimates maximize the grouped-binomial likelihood, numerically obtained by iteratively reweighted least squares. At the fitted probabilities, the estimated covariance matrix is the inverse observed information, approximately
The Std. Error column is the square root of its diagonal. Each z value is Estimate/Std. Error, and the two-sided Wald test p-value is
for the null hypothesis that the corresponding coefficient is zero.
Thus is the fitted log odds for a nonmalignant patient at site A. The site coefficients compare B and C with A, while compares malignant with nonmalignant tumours after adjustment for site. In odds-ratio form,
At level , the B-versus-A contrast is not significant (), the C-versus-A contrast is not significant (), and malignancy has a significant negative association with survival (). The intercept test merely compares the baseline survival probability with .
The null deviance compares the intercept-only fit with the saturated model and has residual degrees of freedom. The residual deviance compares the four-parameter fitted model with the saturated model and has degrees of freedom. Finally, the Akaike information criterion is
Logistic regression assumes independent with
For the binomial exponential family, , so the mean is and the canonical parameter is its logit. It may be fitted by iteratively reweighted least squares.
Under LDA, Bayes' rule gives
which is a logistic model with an intercept.