Let's say I have the following regression setup, which I am using for portfolio return attribution:
$R = 1*\beta(1) + A*\beta(2) + B*\beta(3) + C*\beta(4) + \epsilon $
where A is dummy matrix of country , B is a dummy matrix of Industries, C is a matrix of factor exposures, 1 is a vector of ones
As you can see in this setup, there is multicollinearity between A and B. The rank of (AB) < rank of (A) + rank of (B). In Matlab code:
rank([dummyvar(ceil(abs(rand(20,1))*5)'),dummyvar(ceil(abs(rand(20,1))*4)')])
How can I go about computing all these betas without dropping one of the Columns from A or B matrix, as is typically done to address this issue. I know there is a trick to solve this, but I can't remember how it's done.