Announcement

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

  • command real is unrecognized

    I am using a written code which utilizes the cohort-component method to conduct population projection. When I ran the following section of that code, I got an error: "command real is unrecognized".

    real matrix Leslie(real vector L, real vector m) {
    n = length(L)
    M = J(n,n,0)

    // lower diagonal has survivorship ratios
    for (i=1; i < n; i++) {
    M[i+1,i] = L[i+1]/L[i]
    }
    M[n,n-1] = M[n,n] = L[n]/(L[n-1]+L[n])

    // first row has net maternity contributions
    for(i=1; i < n; i++) {
    if(m[i]==0 & m[i+1]==0) continue
    M[1,i] = L[1]*(m[i] + m[i+1]*L[i+1]/L[i])/2
    }
    if (m[n] > 0) M[1,n] = L[1]*m[n]
    return(M)
    }

  • #2
    You need a declaration mata first

    Comment


    • #3
      This is Mata code that needs to be compiled first. My advice: check back with the person (source) who gave you that code and ask for guidance on how to run it. That is likely the quickest way to solve your problem.

      Best
      Daniel

      Comment

      Working...
      X