Announcement

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

  • matrix recursive element

    Hi, I want to run this code

    Code:
    local filas = 300
    local columnas = 1
    matrix A = J(`filas',`columnas',0)
    matrix A[1,1] = 1
    forvalues i = 2/`filas' {
    matrix A[`i',1] = matrix A[`i'-1,1] + rnormal()
    }
    matrix list A
    but, when

    Code:
    matrix A[`i',1] = matrix A[`i'-1,1] + rnormal()
    is excuted stata shows "matrix not found".

  • #2
    Try
    Code:
    matrix define A[`i', 1] = A[`i'-1, 1] + rnormal()

    Comment


    • #3
      Hi, it does not work

      Code:
      . local filas = 300
      
      . local columnas = 1
      
      . matrix A = J(`filas',`columnas',0)
      
      . matrix A[1,1] = 1
      
      . forvalues i = 2/`filas' {
        2.   matrix define A[`i',1] = matrix A[`i'-1,1] + rnormal()
        3. }
      matrix not found
      r(111);

      Comment


      • #4
        Originally posted by Daniel Morales View Post
        Hi, it does not work
        You missed it. Copy and paste my code in place of yours, paying particular attention to the expression on the right-hand side of the assignment.

        Comment


        • #5
          I'm sorry Joseph, I didnt catch that, could you be more explicit?

          Comment


          • #6
            I already did, thank you mr. Coveney.

            Comment

            Working...
            X