Announcement

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

  • Stata not storing my matrix in Mata

    Hi all,

    I am running the code of DLW (2012) with using Stata 15. The command is meant to generate a matrix. But Stata gives an error message when I call the matrix. Please find the code below:


    mata:
    void GMM_DLW(todo,betas,crit,g,H)
    {
    PHI=st_data(.,("phi"))
    PHI_LAG=st_data(.,("phi_lag"))
    Z=st_data(.,("const","l_lag","k"))
    X=st_data(.,("const","l","k"))
    X_lag=st_data(.,("const","l_lag","k_lag"))
    Y=st_data(.,("y"))
    C=st_data(.,("const"))

    OMEGA=PHI-X*betas'
    OMEGA_lag=PHI_LAG-X_lag*betas'
    OMEGA_lag_pol=(C,OMEGA_lag)
    g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol' OMEGA
    XI=OMEGA-OMEGA_lag_pol*g_b
    crit=(Z'XI)'(Z'XI)
    crit
    }

    void DLW()
    {
    initialvalue=st_data(1,("blols","bkols"))
    S=optimize_init()
    optimize_init_evaluator(S,&GMM_DLW())
    optimize_init_evaluatortype(S,"d0")
    optimize_init_technique(S, "nm")
    optimize_init_nmsimplexdeltas(S, 0.1)
    optimize_init_which(S,"min")
    optimize_init_params(S,("OLS"))
    p=optimize(S)
    p
    st_matrix("beta_dlw",p)
    }
    end

    cap program drop dlw
    program dlw, rclass
    preserve
    sort fid year
    mata DLW()
    end

    dlw
    gen beta_c1=beta_dlw[1,1]



    when I call dlw, Stata gives an error message :
    beta_ ambiguous abbreviation
    st_data(): 3598 Stata returned error
    DLW(): - function returned error
    <istmt>: - function returned error


    when I tried to generate variables from the matrix, Stata gives an error:
    beta_dlw not found

    Does anyone has an idea of why Stata does not generate or store the matrix?

  • #2
    Hi! I have a similar problem. Were you able to solve this? Thanks

    Comment


    • #3
      The problem was not with the matrix, but the fact that there is an error in the way Olu loaded the data into Mata.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Hi Maarten,

        The problem was not with the matrix, but the fact that there is an error in the way Olu loaded the data into Mata.
        I faced the same issue. Please could you explain a bit more what do you mean by loading the data into Mata? how do we probably solve this issue?

        Thank you
        Jl

        Comment

        Working...
        X