Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: How to find the best transformation for each variable in 120 periods

 From Xixi Lin To statalist@hsphsun2.harvard.edu Subject Re: st: How to find the best transformation for each variable in 120 periods Date Fri, 22 Feb 2013 10:34:09 -0500

```Hi Nick,

You are right. It does not seem to be reasonable to log or square root
the Return since it has negative values. And some other variables are
not able to be transformed at all. But I wanna use T statistics to
choose independent variables from many, however, the residuals are not
normal which may cause the t statistics to be invalid. That is why I
wanna to transform.

And I do have time series data, but before I do time series analysis,
I wanna to do the cross sectional analysis first, that is how the 120
periods come up.

Thanks for the help.

Best,
Xixi Lin

On Fri, Feb 22, 2013 at 10:04 AM, Nick Cox <njcoxstata@gmail.com> wrote:
>
> Your variable is called -Return- and, at a wild guess, it is a return
> calculated from time series. I am aware of various related
> definitions, but if it is true that your flavour of returns may be
> zero and may be negative, in that case the most commonly used
> statistically transformations, including logarithmic and square root,
> are at worst not even defined and best not useful.
>
> Putting it another way, why did -ladder- yield a pattern of missing
> values over most of the display you cite?
>
> Independently of that,
>
> 1. To find out how to write loops, search for -foreach- and -forval-
> documentation using -search-.
>
> 2. 120 models for 120 periods with possibly different scales for the
> response [I guess you don't actually mean "each variable"] does not
> sound a good idea.
>
> Nick
>
> On Fri, Feb 22, 2013 at 2:44 PM, Xixi Lin <winnielxx@gmail.com> wrote:
>
>> I am trying to find the best transformation for each variable in 120
>> periods. I know that command ladder gives the following result:
>> Transformation          formula         chi2(2)         P(chi2)
>> cubic                           Return^3                .               .
>> square                   Return^2               .               0.000
>> identity                         Return         64.81           0.000
>> square root             sqrt(Return)            .               .
>> log                              log(Return)            .               .
>> 1/(square root)         1/sqrt(Return)          .               .
>> inverse                  1/Return               .               .
>> 1/square                        1/(Return^2)            .               .
>> 1/cubic                 1/(Return^3)            .               .
>>         .
>>  How can I write a loop to find the best transformation fit for each
>> variable in 120 periods if available?
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```