Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 1.) Negative values after log transformation of positive values 2.) log transformation of negative values

    Dear Members, I am using stata 13.1.and am studying the impact of finacial development on economic Performance(GDP per capita) for Panel data consisting of 64 countries and 11 years. For that, i am using various Independent variables like 1.)private credit to gdp, 2.)broadmoney to gdp, 3.)life and non life insurance to gdp, 4.)stock market capitalization to gdp, 5.)stock traded to gdp, 6.)net interest margin, 7.)non interest income to total income, 8.)Overhead costs to total assets, 9.)return on assets, 11.)return on equity,12.) stock market turnover Ratio. and control variables like 1.)Initial real gdp per capita, 2.)life expectancy, 3.)Inflation rate, 4.)Population growth rate, 4.)trade openess to gdp, 6.)government spending to gdp and 7.)gross caiptal Formation.
    I have following two questions reagarding log transformation:
    1.) I transformed all possible positive variables into log for static model with fixed effects. But after transformation, except private credit and broad money,all other log variables have negative value. Will it change interpretation of my results?
    2.) Is it good idea to convert return on assets and return on equity( most of the negative values) into log by adding a constant?

    Regrads,
    Geeta.





  • #2
    I'm not sure I understand; however, note that log(1)=0 and thus log of anything smaller than 1 (say, .5) will be negative - I see no problem with that;

    re: your second question, if I understand, some of these returns are negative, correct? if yes, do not add a constant - start by using glm with a log link or, possibly better (I'm not an economist however) use "fam(gamma)"

    it is easier to respond to such questions if you show a sample of your data - use "dataex" which can be downloaded from SSC - please see the FAQ

    Comment


    • #3
      Geeta:
      as Rich warned you about, your idea in 2.) is not a good one (all in all, who can say if the value of your constant is small enough to avoid biasing your data?).
      Besides, as it is always the case with transformations, the main problem is back-transforming on the original scale (although most depends on the statistical smattering of your audience).
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        @Rich Goldstein...Thanks for your reply.

        here is sample dataset. could you please explain the steps to transform negative into logs. Since in previous literature authors have take log of inflation rate and population.

        ----------------------- copy starting from the next line -----------------------
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input byte id str1 country int year double(ROA ROE inflationrate populationrate)
        1 "C" 1999  .16018429398536682  1.8137199878692627  -1.836558378215102 -1.47722298197717
        1 "C" 2000  .19002896547317505  2.2286438941955566   1.037287090498424 -1.66638264306554
        1 "C" 2001   .1804995983839035  1.5562517642974854 -1.0957677045019523 -.833088754778975
        1 "C" 2002 -14.716073036193848  -27.01810073852539  30.555204028840933 -.593959183588628
        1 "C" 2003 -1.9163775444030762 -17.658493041992188  10.495703041955665 -.491866212866043
        1 "C" 2004 -2.9964332580566406 -26.352067947387695   30.73686417001491 -.445177936198383
        1 "C" 2005  1.5472546815872192  13.241133689880371  10.620155545216562 -.309476734460824
        1 "C" 2006  1.9688327312469482    14.9375638961792  15.242433413901253 -.420566975310993
        1 "C" 2007   1.090379238128662   7.853237628936768   17.67892097117452 -.424151028076189
        end
        ------------------ copy up to and including the previous line ------------------


        .

        Comment


        • #5
          @Carlo Lazzaro...thanks for your reply. Actually in provided literature authors have used log transformation so i wanted to give it a try. otherwise i will only proceed with log of positive variables.

          Regards,
          Geeta.

          Comment


          • #6
            as I said, you cannot take the log of a negative number - instead use the glm command with family(gaussian) and link(log) or with family(gamma) and link(log); this is not my area of substantive work so I am not familiar with your literature

            Comment


            • #7
              Some people use

              Code:
              cond(x < 0, -ln(1 + abs(x)), ln(1 + abs(x)))
              See also e.g. http://www.statalist.org/forums/foru...asonalize-data

              http://www.statalist.org/forums/foru...contains-zeros

              Comment


              • #8
                @Rich Goldstein....thanks a lot for your help. I am thinking to keep negative values at level. Is it accurate to consider log and few level variables in single regression?
                Last edited by geeta dangwal; 18 Feb 2016, 15:04.

                Comment


                • #9
                  Nick Cox .......Thanks for your help. I lost 49 observation when tried to transform inflation rate into log. ln(1+inflationrate). And when tried to use "cond" option, got the following result:


                  . cond inflationrate< 0, -ln(1 + abs(inflationrate)), ln(1 + abs(inflationrate)
                  unrecognized command: cond
                  r(199);


                  Comment


                  • #10
                    cond() is not a command; nor is it an option. If it was an option, the syntax you tried of calling it by itself would indeed have proved illegal. It's a function. search cond points to various false positives but also to the help for functions and

                    SJ-5-3 pr0016 . . Depending on conditions: a tutorial on the cond() function
                    . . . . . . . . . . . . . . . . . . . . . . . D. Kantor and N. J. Cox
                    Q3/05 SJ 5(3):413--420 (no commands)
                    tutorial on the cond() function

                    Manifestly, ln(1+inflationrate) can do nothing to fix arguments less than or equal to -1. That's why the cond() call branched. Also the threads I linked to spelled out the term neglog transformation.

                    So you need the full definition

                    Code:
                    gen neglog =  cond(inflationrate< 0, -ln(1 + abs(inflationrate)), ln(1 + abs(inflationrate)))

                    Comment


                    • #11
                      No, it is not reasonable to take the logs of some values and leave the negative values as is - I mentioned some alternative above - did you try any of them?

                      Comment


                      • #12
                        @Rich Goldstein.....i meant to say all variables in log except four variables inflation rate, population rate, return on asset and return on equity. Being quite new to stata i am very slow. so need time to grasp the glm command
                        Last edited by geeta dangwal; 18 Feb 2016, 19:21.

                        Comment


                        • #13
                          @Nick Cox......thank you very much for your help.

                          Comment


                          • #14
                            sorry for the misinterpretation; yes, you can log some variables and leave others unlogged

                            Comment

                            Working...
                            X