Announcement

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

  • order of operations

    I'm getting conformability errors when I go from :+ with rows to :- with columns:

    Code:
    t=1::10
    p=1..3
    
    // conformability error
    q = J(length(t),length(p),0) :+ 8 :+ (3..1)/10 :- .5*log(p) :- t/2
    
    // parentheses work 
    q = ( J(length(t),length(p),0) :+ 8 :+ (3..1)/10 :- .5*log(p) ) :- t/2
    
    // columns before rows works
    q = - t/2 :+ J(length(t),length(p),0) :+ 8 :+ (3..1)/10 :- .5*log(p)
    I'm surprised that parentheses are needed here. Doesn't Mata evaluate :+ and :- sequentially, left-to-right?
Working...
X