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.
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.
Comment