Solution (source code)

= Solution

Average the covariate over its possible event subjects using the conditional <probabilities> from part (a). Define the risk-weighted sums
$$
S_r(t,\beta)=\sum_{i\in R(t)}z_i^r e^{\beta z_i},\qquad r=0,1,2,
$$
with $z_i^0=1$. Then
$$
\boxed{\overline z(t^*,\beta)=\frac{S_1(t^*,\beta)}{S_0(t^*,\beta)}
=\frac{\sum_{i\in R(t^*)}z_i e^{\beta z_i}}{\sum_{i\in R(t^*)}e^{\beta z_i}}.}
$$
This is the mean covariate of the next event subject, conditional on the current <risk set> and an event. It is generally not the unweighted average over the original sample. For $\beta=0$ it reduces to the unweighted current risk-set mean.