# Re: st: convolution-lognormal

 From "Steichen" To Subject Re: st: convolution-lognormal Date Wed, 24 Mar 2004 09:08:37 -0500

```Your first time thru the loop you try to compute log(0), which is undefined.
logs are fine, you just need to do them over a legitimate range.

----- Original Message -----
From: "Andreas Aschbacher" <aa_surf@gmx.at>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, March 24, 2004 8:59 AM
Subject: RE: st: convolution-lognormal

> Dear fellows !
>
> If I build in logarithmusnaturalis in my algorithm ...
> /please see line ### /
>
> clear
> set obs 100
> gen d =.
> gen d1 =.
> forvalues i = 1(1)100 {
> local  j = `i' * 0.1
> local f = (`j' - .1)/.1
> di `j'
> range x .1 `j' ` f '
> di `f'
> gen double y=exp(-(log((`j')-x))^2/2)*exp(-(log(x )-10)^2/2)   ####
> *(0.1/(x + 0.1))
> integ y x,gen(Sy)
> replace d  = y  if  [_n] ==`i'
> replace d1 = Sy  if  [_n] ==`i'
>
> drop Sy y x
> }
> gen x = [_n]
> gen x1 = x*.1
> integ d1 x1,gen(Sy_1)
> twoway line d1 x1||line  Sy_1 x1
>
> ... it does not work - this is because of log(`j'),which does not work.
> which LOOPHOLE do I have,because I need logarithmus in my function.
> any advice will be appreciated very much.
> andreas aschbacher
>
>
>
>  Dear fellows !
> >
> >
> > the following is maybe useful for someone :
> >
> > clear
> > set obs 100
> > gen d =.
> > gen d1 =.
> > forvalues i = 1(1)100 {
> > local  j = `i' * 0.1
> > local f = (`j' - .1)/.1
> > di `j'
> > range x .1 `j' ` f '
> > di `f'
> > gen double y=exp(-(`j'-x)^2/2)*(0.1/(x + 0.1))
> > integ y x,gen(Sy)
> > replace d  = y  if  [_n] ==`i'
> > replace d1 = Sy  if  [_n] ==`i'
> >
> > drop Sy y x
> > }
> > gen x = [_n]
> > gen x1 = x*.1
> > line d1 x1
> >
> > please tell me any improvement for best computing of
> > convolution-integrals.
> >
> > andreas to all statalisters allover the world
> >
> >
> >
> > Thanks Nick !
> > >
> > > clear
> > > set obs 100
> > > gen d =.
> > > gen d1 =.
> > > forvalues i = 1(1)100 {
> > > local  j = `i' * 0.1
> > > local f = (`j' - .1)/.1
> > > range x .1 `j' ` f '
> > > gen double y=exp(-(`j'-x)^2/2)*0.1/(x + 0.1)
> > > integ y x,gen(Sy)
> > > *replace d = y
> > > *replace d1 = Sy
> > > drop Sy y x
> > > }
> > >
> > > now I am quite near to compute convolution-integrals with Stata.
> > > This is necessary because of comparing results with those of
> > > LevenbergMarquardt
> > > Decomposing with -denormix- was also very useful.
> > > andreas
> > >
> > >
> > > The syntax for -range- is accessible via -help range-.
> > > >
> > > > It's usually not a good idea to change the index
> > > > of a loop within the loop; thus
> > > >
> > > > local j = `i' * 1
> > > >
> > > > You might need to -drop x- as well.
> > > >
> > > > Don't put [_n] to the left of an = sign.
> > > >
> > > > Nick
> > > > n.j.cox@durham.ac.uk
> > > >
> > > > > -----Original Message-----
> > > > > From: owner-statalist@hsphsun2.harvard.edu
> > > > > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Andreas
> > > > > Aschbacher
> > > > > Sent: 24 March 2004 10:41
> > > > > To: statalist@hsphsun2.harvard.edu
> > > > > Subject: Re: st: convolution-trial/correction
> > > > >
> > > > >
> > > > > > Dear fellows !
> > > > > >
> > > > > > /first thanks to Neil from yesterday/
> > > > > >
> > > > > > please consider the following as "Pseudocode"
> > > > > >
> > > > > > clear
> > > > > > set obs 100
> > > > > > gen d =.
> > > > > > gen d1 =.
> > > > > > forvalues i = 1(1)100 {
> > > > > > local i = `i' * 0.1     <-  0.1 *1,2,3,4,.....
> > > > > *-multplikation-operator
> > > > > > range x .1(.1)i          <-   range until i-value
> > > > >
> > > > > > gen double y=exp(-(`i'-x)^2/2)*0.1/(x + 0.1)    <- y as function
> > of
> > > > > > i-value
> > > > > > integ y x,gen(Sy)    <- integrate until i-value
> > > > > > *save new y- and Sy- value in two columns :
> > > > > > replace d[_n] = y
> > > > > > replace d1[_n] = Sy
> > > > > > drop Sy y
> > > > > > }
> > > > > >
> > > > > > please any advice that it works correctly.
> > > >
> > > > *
> > > > *   For searches and help try:
> > > > *   http://www.stata.com/support/faqs/res/findit.html
> > > > *   http://www.stata.com/support/statalist/faq
> > > > *   http://www.ats.ucla.edu/stat/stata/
> > > >
> > >
> > > --
> > > +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter
Virenschutz
> > > +++
> > > 100% Virenerkennung nach Wildlist. Infos:
http://www.gmx.net/virenschutz
> > >
> > > *
> > > *   For searches and help try:
> > > *   http://www.stata.com/support/faqs/res/findit.html
> > > *   http://www.stata.com/support/statalist/faq
> > > *   http://www.ats.ucla.edu/stat/stata/
> > >
> >
> > --
> > +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz
> > +++
> > 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> >
>
> --
> +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz
+++
> 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```