I am struggeling with putting a likelihood function into RATS that involves an integral, which I do not know how to code. The function is that of a dis-equilibirum supply-demand-model that includes a function for demand (D) and supply (S). The realized quantity (C) is always determined by the minimum of D and S.
The joint density of S and D is given by the product of two normal densities: g1(D)*g2(S)=(1/2*pi*sig1*sig2)*exp(-1/2*(D-X1a)^2/sig1^2)*exp(-1/2*(S-X2b)^2/sig2^2).
Now, the conditional probability density for C if it is determined by demand is: h(C|C=D<S) = g1(C)*Integral(from C to infinity) [g2(S) dS].
Likewise, we have: h(C|C=S<D) = g2(C)*Integral(from C to infinity) [g1(D) dD].
Finally the density h(C) is given by h(C) = h(C|C=D<S) + h(C|C=S<D).
My question is know how to code the involved integrals. %cdf will give me the cdf of a standard normal. Can I somehow use that function? Or is there another function that makes it possible setting up the density function h(C) which I need to set up the likelihood?