  A defect correction formula for quadratic matrix equations of the kind
$A_1X^2+A_0X+A_{-1}=0$ is presented. This formula, expressed by means of an
invariant subspace of a suitable pencil, allows us to introduce a modification
of the Structure-preserving Doubling Algorithm (SDA), that enables refining an
initial approximation to the sought solution. This modification provides
substantial advantages, in terms of convergence acceleration, in the solution
of equations coming from stochastic models, by choosing a stochastic matrix as
the initial approximation. An application to solving random walks in the
quarter plane is shown, where the coefficients $A_{-1},A_0,A_1$ are
quasi-Toeplitz matrices of infinite size.
