Announcement

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

  • Orthogonalize 2 variables

    Hi,

    I would like to create a variable "oprice" that would be "price" orthogonalized to price2. Is there an easy way to do that in Stata? Is the command "orthog" appropriate?

    Code:
    sysuse auto, clear
    
    gen price2 = price + uniform()

  • #2
    If you use -orthog price price2, gen(oprice1 oprice2)-, you will get two new variables, call them oprice1 and oprice2 which are orthogonal to each other. The variable oprice1 will be a standardized (mean 0, variance 1) version of price; oprice2 will be another standardized variable that is orthogonal to oprice1; and oprice1 and oprice2 will the same vector space as price and price2. (i.e. if you regress each of price and price2 on oprice1 and oprice2, R2 will be 1, at least to within rounding error.) If that is what you want, go ahead.

    If you don't want the results to be standardized and you are just looking for a single variable oprice that would represent the information in price that is orthogonal to the information in price2, you can just run:

    Code:
    regress price price2
    predict oprice, resid
    
    corr price price2 oprice

    Comment


    • #3
      I feel like mentioning pca. But I don't see how the question arises. Why add uniform noise to a variable?

      Comment


      • #4
        Hello stata list members,
        i would like to know how can i orthogonalized a variable in stata?.
        example if i have a variable interaction Z , between X 1 and x2, .As such construct capture different aspect of a phenomenona ,how these interact is key.X1 exacerbate x2 effect and vice versa.in regression model Z is orthogonalized to minimize multicollinearity.Essentialy ,this entails regressing an interaction variable on its determinants and using the residuals, rather than the interaction , in subsequent analysis)
        Could you please guide me how can i do it in stata(actually they regress y x1 x2 z ( but i think this z is not simple interaction of x1 and x2, but it is residual).
        looking forward for your kind reply.

        Comment


        • #5
          Clyde Schechter hello sir,
          sir could you please guide me about my previous post#4 , that how can i do it in stata.
          best regards.

          Comment

          Working...
          X