Announcement

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

  • Variance ratio

    Hi,

    How would I tell STATA I need the |VR -1| ? With VR being the variance ratio and the -1 would represent the day before.

    Thanks

  • #2
    It is not clear from your descriptions here and in your initial post at

    https://www.statalist.org/forums/for...tio-|vr-n-m-1|

    what you mean by
    Code:
    |VR -1|
    To me the surrounding vertical bars suggest this represents subtracting 1 from VR and taking the absolute value of the difference. If so, that would be
    Code:
    abs(VR-1)
    If you really mean VR from the previous day, I would have expected you to recognize the technique from your initial post where you successfully used the lag operator to get values of your LOGRET1 variable from the previous four days,
    Code:
    gen LOGRET1_L1 = l1.LOGRET1
    gen LOGRET1_L2 = l2.LOGRET1
    gen LOGRET1_L3 = l3.LOGRET1
    gen LOGRET1_L4 = l4.LOGRET1
    and so the code would be
    Code:
    abs(l1.VR)
    although I prefer to use the capital letter L
    Code:
    abs(L1.VR)
    for clarity.

    Comment


    • #3
      Hi William,
      Many Thanks for your answer! Yes that would be correct to use that code but the command for the absolute value is not recognized on my stata. I am using stata 16.0. Is there an equivalent or should I proceed in an other way?
      Code:
      abs(l1.VR)

      Comment


      • #4
        abs() is a function, not a command. It's in your Stata. You just need to use it within a command. In Stata it can't be used by itself.

        Code:
        . clear
        
        . set obs 1
        number of observations (_N) was 0, now 1
        
        . gen foo = -42
        
        . gen bar = abs(foo)
        
        . l
        
             +-----------+
             | foo   bar |
             |-----------|
          1. | -42    42 |
             +-----------+
        If abs() didn't exist than the square root of the square would get you there. So would the maximum of something and its negation.
        Last edited by Nick Cox; 21 Aug 2019, 03:39.

        Comment

        Working...
        X