Announcement

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

  • Matrix of matrices

    Dears

    I would like to create a matrix containing the results of other matrices generated after the command wtp. This command estimates confidence intervals for willingness to pay (WTP). It provides 3 rows: the first row in contains the WTP estimates and the second and third rows contain the lower and upper confidence limits of the WTP estimates. The results are stored in r(wtp).

    I was able to create a matrix after each wtp command, but how do i combine all these matrices in one overall matrix (i.e. mat T = J(24,4,.))

    Code:
    
    
    qui clogit choice ASC_one ASC_two ASC_three price rating if prod==1, group( choice_set )
    
    wtp price ASC_one ASC_two ASC_three rating
    
             ASC_one      AASC_two   ASC_three      rating
    wtp   .62778502   .47087121   3.9053258   .60460404
     ll  -.12971996  -.26359909   .58315108   .24282412
     ul     1.38529   1.2053415   7.2275005   .96638396
    
    
    matrix A = r(wtp)
    
    matrix list A
    
    A[3,4]
              ASC_one      AASC_two   ASC_three      rating
    wtp   .62778502   .47087121   3.9053258   .60460404
     ll  -.12971996  -.26359909   .58315108   .24282412
     ul     1.38529   1.2053415   7.2275005   .96638396
    
     qui clogit choice ASC_one ASC_two ASC_three price rating if prod==2 , group( choice_set )
    
    
    . wtp price ASC_one ASC_two ASC_three rating
    
             ASC_one ASC_two ASC_three      rating
    wtp   .73891389   .08470098    2.296691    .4404317
     ll   .22942171  -.40518689   .62363411   .24854907
     ul   1.2484061   .57458886    3.969748   .63231432
    
    matrix B = r(wtp)
    matrix list B
    
    B[3,4]
             ASC_one ASC_two ASC_three     rating
    wtp   .73891389   .08470098    2.296691    .4404317
     ll   .22942171  -.40518689   .62363411   .24854907
     ul   1.2484061   .57458886    3.969748   .63231432
    Thanks


    Federica

  • #2
    Code:
    help matrix operators
    explains row join \ and column join , as matrix operators. Your problem seems to be one of joining by rows.

    Comment


    • #3
      If I understand you correctly: create your J matrix and then fill the elements in. Or append the relevant matrices to each other. help matrix

      Example of latter approach:

      Code:
      . matrix A = (1, 2 \ 3, 4)
      
      . matrix B = (5, 6 \ 7, 8)
      
      . mat li A
      
      A[2,2]
          c1  c2
      r1   1   2
      r2   3   4
      
      . mat li B
      
      B[2,2]
          c1  c2
      r1   5   6
      r2   7   8
      
      . mat C = A \ B
      
      . mat li C
      
      C[4,2]
          c1  c2
      r1   1   2
      r2   3   4
      r1   5   6
      r2   7   8


      Comment


      • #4
        Thanks a lot!

        Comment

        Working...
        X