The authors consider the expected residual (ER) method which makes use of a residual function for the affine variational inequality problem (AVIP): Find $x \in S$ such that $\langle Mx+q,y-x\rangle \geq 0$ $\forall y \in S$, where $S=\{y \in \Bbb R^n |Ay=b, y\geq0\}$ with $A \in \Bbb R^{m \times n}$ and $b \in \Bbb R^m$, and $M \subset \Bbb R^{n \times n}, q\in \Bbb R^n$. The AVIP is a wide class of problems which includes the quadratic programming problem and the linear complementarity problem. The ER method solves the optimization problem: $\min E([r(x,\omega)]$ s.t. $x\in X$, where $r( \cdot, \omega): \Bbb R^n \rightarrow \Bbb R_+$ is a residual function for the variational inequality problem, $E$ denotes the expectation. The ER model for the stochastic affine variational problem (SAVIP) based on the regularized gap function and the D-gap function for the AVIP is considered. Main result: The authors establish convexity of both the regularized gap function and the D-gap function and show that the resulting ER models with the proposed residual functions are convex. One of the ER models proposed here, the ER-D model, is then applied to the traffic equilibrium problem under uncertainty. In the numerical experiment, the ER-D model is compared with the MCP formulation-based ER model with the Fischer-Burmeister function. The numerical results show that when the demand $D(\omega)$ is fixed (200) for all $\omega \in \Omega$ (the sample space of factors contributing to the uncertainty in the traffic network, such as weather and accidents, $D(\omega):$ vector with components $D_W(\omega)$ -- travel demand under uncertainty for OD-pair $w \in W$ -- the set of origin-destination pairs in a network $\mathcal{G}$), the proposed ER-D model with large $\alpha$ (the regularized gap function $f_\alpha$) can obtain more reasonable solutions since the obtained route flows tend to satisfy the demand condition. Moreover, the demand condition is not greatly affected by the increase in the variance of $\omega$, that is, in the change in $\delta$, as compared to the ER-FB model (the effect of $\delta$, which defines the interval $\Omega = [\frac{1}{2}-\delta , \frac{1}{2}+\delta]$, on the feasibility of the solutions obtained by the two ER methods).