Suppose we have a 5% (paid-annually) coupon bond with 1-year to maturity. We also have a 1-year CDS with a single payment paid annually (running spread with zero upfront). Assume that the underlying credit can only default at maturity ($t=1$). In case of default, the bond recovers $R = 0.40$ $\times$ (principal + pre-petition interest = \$105). The 1-year risk-free rate is 3%. The 5% risky bond is trading at \$90.
The YTM of the risky-bond is 16.67% $\implies$ z-spread = 13.67%. The implied probability of default is $P(\tau\leq1)=\frac{N * DF(1) - P}{N * DF(1) * (1-R)}$ where $N=105, DF(1) = \frac{1}{1+r} = 0.971$, and $P = 90$. We calculate $P(\tau\leq1)=19.52\%$. The CDS spread $S=(1-R)*P(\tau\leq1)=11.7\%$.
Why does CDS spread not equal the z-spread of the bond? The basis here is ~2%. I think this comes from the bond price being below par. For the bond, loss in default is only $P-R*(F)$ not $1-R$, but am trying to better quantify and understand this basis. I was reading about adjusted z-spread, but not sure if that applies here.