Announcement

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

  • How to write Stata Command corre

    Dear Stataliters,
    I'd want to obtain a weight vector by writing a stata command to realize its compute process. I have carried out these by a Stata .do profile, but I want to convert it to a Stata command. To run these code, we should read dataset first, but I think it doesn't be a barrier to convert it. The Stata code are listed as follows:

    mata
    w=st_data(.,.)
    cols(w)
    w=st_data(.,3..32)
    cols(w)
    ei=st_data(.,33)
    rows(ei)
    T=14
    N=30
    w1=J(1,1,.)
    for (i=1;i<=T;i++) {
    t1=(i-1)*N+1;
    t2=i*N;
    w2=st_data(t1::t2,3..32)*st_data(t1::t2,33);
    w1=(w1\ w2);
    }
    J=J(421,1,1)
    I=I(421,1)
    w1=select(w1,J-I)
    w1
    end

    I would feel very appriciate that anyone who can help me to fix this problem. Thx.
    Best wishes!

  • #2
    Consider installing dataex from ssc

    Code:
    ssc inst dataex
    And providing example data to more explicitly show what you are hoping to accomplish. One thing that will likely cause issues turning this into a command is that all of the references to variables are hardcoded instead of being parameterized.

    Comment


    • #3
      OK, I will try in this way. wbuchanan, thanks for your help.

      Comment

      Working...
      X