Announcement

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

  • st_store():3200 conformability error when writing variable from mata to stata

    I am writing a mata code to multiply two matirx, the code is as follow

    M=st_view(.,.,"s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s41 s42 s43 s44 s45 s46 s47 s48 s49 s50 s51 s52 s53 s54 s55 s56 s57 s58 s59 s60 s61 s62 s63 s64 s65")
    O=(1::65)
    O=st_view(.,.,"s_omega")
    T=(1::249796)
    T=M*O
    st_store(.,st_addvar("float","ea"),T)
    end



    s1 represents a column vector, s1: 249796 x 1
    and (s1 s2 ...s65): 249796 x 65
    s_omega also represents a column vector, s_omega: 65 x 1
    and I want to get the column vector T, T: 249796 x 1
    Though I have read several mata manuals, but I'm confusing about what is causing the error.

    Thank you!
    Alice

  • #2
    The syntax for st_view() is not correct, so I am surprised that you ge as far as st_store. Besides you are asked by the FAQ to state which version of Stata you are using (and on which OS).

    I would change the code as

    Code:
    st_view(M=.,.,"s":+strofreal(1..65))
    st_view(O=.,(1::65),"s_omega") // you pick up the first 65 observation of s_omega
    // or better st_view(O=.,(1::cols(M)),"s_omega")
    
    T=M*O // M is of dimension 249796 x 65 and O if dimension 65 x 1 -> T is 249796 x 1
    st_store(.,st_addvar("float","ea"),T)
    end
    Code:
    O=(1::65)
    and
    Code:
    T=(1::249796)
    are not necessary. They just create column vectors with numbers ranging from 1 to 65 and 1 to 249796 respectively and you assign different values right after.

    Hope this helps

    Comment

    Working...
    X