Date: Thu, 5 Apr 2001 09:46:31 -0700
Reply-To: Dale McLerran <dmclerra@MY-DEJA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <dmclerra@MY-DEJA.COM>
Subject: Re: How to form expectation of double truncated normal?
Content-Type: text/plain
Larry,
If you have IML licensed, then you can use the QUAD function to
perform this integration. The QUAD function has been available
since version 6.11. Chances are that you have access to a version
of SAS at least that new. The more limiting factor will be
whether you have IML licensed. To use the QUAD function, you
must first define an IML function which expresses the integrand.
For your normal distribution truncated mean problem, a function
for the integrand x*f(x) would be
start trncnorm(x) global(mu,sigma);
integrnd = x * (1/(sqrt(2*3.1415926) * sigma))
* exp(-.5*(((x - mu)/sigma)**2));
return(integrnd);
finish;
The QUAD function call would then be invoked
mu=<unrestricted mean>;
sigma=<square root of unrestricted variance>;
call quad(trncmean, "trncnorm", {lowlim highlim}, , mu, sigma);
The variable trncmean will hold the results of the integration
upon return. One does not necessarily have to specify mu and
sigma in the QUAD call above. However, specification of these
parameters should improve the performance of the integration.
There are a couple of options which I have not employed above.
You should read the documentation on the QUAD function before
you actually go ahead with its use.
Dale
>Date: Thu, 5 Apr 2001 04:24:45 GMT
>Reply-To: vanhorn@simon.rochester.edu
>From: vanhorn@simon.rochester.edu
>Subject: How to form expectation of double truncated normal?
>To: SAS-L@LISTSERV.UGA.EDU
>
>Folks,
>I need to calculate the expectation of a double truncated normal. For
>example the integral of x f(x) dx given upper and lower limits. Is
>there an easy way to do this in SAS?
>TIA,
>Larry
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/