I am currently estimating a linear regression, where I am regressing my outcome variable on a full set of dummy variables. More specifically, I have transactions data, and buyer and seller dummies. Thus, I am regressing loans on dummy variables corresponding to buyers and sellers. As a result, transaction(i,j) is a function of I buyer dummies and J seller dummies, which take on a value of 1 when the buyer is i and the seller is j. Of course, I cannot estimate all the dummies because the sum of buyer dummies=sum of seller dummies=1 (even after removing the constant). Alternatively, what I can do is to include a constant and 2 constraints: the first constraint is that the sum of buyer dummies=0 and the second constraint is that the sum of seller dummies=0.
To create the dummy variables, I have used the tabulate buyer, gen(buyerdummy) command for the buyers, and the symmetrical version for the sellers (STATA 13.0).
I understand I have to use a constrained regression. First, I specified the constraints:
constraint 1 sum(buyerdummy1-buyerdummy200)=0
constraint 2 sum(sellerdummy1-sellerdummy150)=0
and I ran the regression
cnsreg y buyerdummy1-buyerdummy200 sellerdummy1-sellerdummy150, c(1-2)
For some reason, Stata returns an error message r(131) for constraint 1 and 2 respectively. Mathematically, I am certain that my design matrix is correct. The problem originates in my syntax. Any help is much appreciated.
To create the dummy variables, I have used the tabulate buyer, gen(buyerdummy) command for the buyers, and the symmetrical version for the sellers (STATA 13.0).
I understand I have to use a constrained regression. First, I specified the constraints:
constraint 1 sum(buyerdummy1-buyerdummy200)=0
constraint 2 sum(sellerdummy1-sellerdummy150)=0
and I ran the regression
cnsreg y buyerdummy1-buyerdummy200 sellerdummy1-sellerdummy150, c(1-2)
For some reason, Stata returns an error message r(131) for constraint 1 and 2 respectively. Mathematically, I am certain that my design matrix is correct. The problem originates in my syntax. Any help is much appreciated.
Comment