\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{alltt}
\hlstd{ps.quint.fit.c}\hlkwb{<-}\hlkwd{quantile}\hlstd{(ps.fit.c,}\hlkwc{probs}\hlstd{=}\hlkwd{seq}\hlstd{(}\hlnum{0}\hlstd{,}\hlnum{1}\hlstd{,}\hlkwc{by}\hlstd{=}\hlnum{1}\hlopt{/}\hlstd{nstrata))}
\hlstd{ps.quint.fit.c}
\end{alltt}
\begin{verbatim}
+        0%       20%       40%       60%       80%      100% 
+ 0.1718558 0.4995522 0.5948874 0.6877045 0.7888924 0.9928991
\end{verbatim}
\begin{alltt}
\hlstd{ps.strat.fit.c}\hlkwb{<-}\hlkwd{as.numeric}\hlstd{(}\hlkwd{cut}\hlstd{(ps.fit.c,ps.quint.fit.c,}\hlkwc{include.lowest}\hlstd{=}\hlnum{TRUE}\hlstd{))}
\hlkwd{table}\hlstd{(Z,ps.strat.fit.c)}
\end{alltt}
\begin{verbatim}
+    ps.strat.fit.c
+ Z     1   2   3   4   5
+   0 120  96  71  49  27
+   1  80 104 129 151 173
\end{verbatim}
\begin{alltt}
\hlstd{mu.strat.fit.c}\hlkwb{<-}\hlkwd{matrix}\hlstd{(}\hlnum{0}\hlstd{,}\hlkwc{ncol}\hlstd{=nstrata,}\hlkwc{nrow}\hlstd{=}\hlnum{3}\hlstd{)}
\hlkwa{for}\hlstd{(j} \hlkwa{in} \hlnum{1}\hlopt{:}\hlstd{nstrata)\{}
    \hlstd{mu.strat.fit.c[}\hlnum{1}\hlstd{,j]}\hlkwb{<-}\hlkwd{mean}\hlstd{(Y[Z}\hlopt{==}\hlnum{0} \hlopt{&} \hlstd{ps.strat.fit.c} \hlopt{==} \hlstd{j])}
    \hlstd{mu.strat.fit.c[}\hlnum{2}\hlstd{,j]}\hlkwb{<-}\hlkwd{mean}\hlstd{(Y[Z}\hlopt{==}\hlnum{1} \hlopt{&} \hlstd{ps.strat.fit.c} \hlopt{==} \hlstd{j])}
    \hlstd{mu.strat.fit.c[}\hlnum{3}\hlstd{,j]}\hlkwb{<-}\hlstd{mu.strat.fit.c[}\hlnum{2}\hlstd{,j]}\hlopt{-}\hlstd{mu.strat.fit.c[}\hlnum{1}\hlstd{,j]}
\hlstd{\}}
\hlstd{mu.strat.fit.c}
\end{alltt}
\begin{verbatim}
+           [,1]      [,2]      [,3]      [,4]      [,5]
+ [1,]  3.924982  4.239986  4.438529  4.685589  4.960768
+ [2,]  1.328789  1.929324  2.533836  2.970253  3.946459
+ [3,] -2.596193 -2.310662 -1.904693 -1.715336 -1.014310
\end{verbatim}
\begin{alltt}
\hlkwd{apply}\hlstd{(mu.strat.fit.c,}\hlnum{1}\hlstd{,mean)}
\end{alltt}
\begin{verbatim}
+ [1]  4.449971  2.541732 -1.908239
\end{verbatim}
\end{kframe}
\end{knitrout}