Have been working on some out of sample prediction code for a specific case of the mixed command(It will only do in sample predictions for reffects). We have it working but am trying to speed it up.
So far we have been using predict for getting the fixed effect predictions. However, this is actually several times slower than our reffects mata code so I would like to replace it with specific mata code.
The problem I am having is getting the matrix X into the mata function. I am extracting the list of variables required from e(b) using colnames and have a string of variable names that can be parsed by the tokens function. The problem I am having is that it is unable to cope with interactions. The only solution I can come up with currently is to parse the string of variable names in stata code and create tempvars for each interaction term. That could get messy very quickly.
Is there a better way of manually calculating XB for the mixed command using mata faster than the predict function?
So far we have been using predict for getting the fixed effect predictions. However, this is actually several times slower than our reffects mata code so I would like to replace it with specific mata code.
The problem I am having is getting the matrix X into the mata function. I am extracting the list of variables required from e(b) using colnames and have a string of variable names that can be parsed by the tokens function. The problem I am having is that it is unable to cope with interactions. The only solution I can come up with currently is to parse the string of variable names in stata code and create tempvars for each interaction term. That could get messy very quickly.
Is there a better way of manually calculating XB for the mixed command using mata faster than the predict function?
Comment