Integral in likelihood

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
jonasdovern
Posts: 97
Joined: Sat Apr 11, 2009 10:30 am

Integral in likelihood

Unread post by jonasdovern »

Hallo RATS-users,
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?

Regards, JD
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Integral in likelihood

Unread post by TomDoan »

As you have that written, S and D are independent Normals. Is that what you want? If it is, it's fairly simple because

P(min(S,D)<=x)=P(S<=x)P(D<=x)

Each of the RHS expressions can be computed with %CDF, and the derivative (to get the likelihood) is also straightforward.
Post Reply