Announcement

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

  • Temporary Matrix Consisting of Indicator Variables

    I'm trying to create a temporary matrix that consists entirely of indicator variables. Originally, one of my variables consisted of string values such as "Kongo", "Lindu", "Bantu", etc. I've performed the encode() command to convert the string variable into a temporary numeric variable:

    tempvar numericCluster
    encode cluster, gen(`numericCluster')

    I'm now trying to create a matrix that consists entirely of indicator variables, so that the columns are the number of different string values (excluding the base level string value), and there is a single 1 value in each row (correlating to that row's string value) with all other values being 0.

    I've then tried to perform:

    local dummies i.cluster
    tempname Cluster_murdock
    mkmat `dummies', matrix(`Cluster_murdock')

    But it continues to give me a "factor-variable and time-series operators not allowed" error.

  • #2
    The error message tells you exactly what the problem is. The mkmat-command takes variables as inputs and does not understand the factor-notation.
    You need to run instead:
    Code:
     xi: mkmat i.`numericCluster', matrix(`Cluster_murdock')

    Comment

    Working...
    X