I figured how to fix the interaction mapping by transposing the sparse matrix but it only works for single observation data.
To be more specific, sp:site works because the sparse matrix for a single observation dataset is a identity/diagonal matrix. Take the transpose of I doesn't really do anything, that is why the order is preserved and multiple observation works as well.
The site:sp sparse matrix for a single observation dataset is not a diagonal. The trick is to take the transpose to get it to the "correct" mapping such that the estimate is the same as sp:site interaction (we know they are suppose to be the same). Because the transpose is "required" to get the correct order, it will mess up the dimensions when we have multiple observations because it is no longer a square matrix.
I figured how to fix the interaction mapping by transposing the sparse matrix but it only works for single observation data.
To be more specific, sp:site works because the sparse matrix for a single observation dataset is a identity/diagonal matrix. Take the transpose of I doesn't really do anything, that is why the order is preserved and multiple observation works as well.
The site:sp sparse matrix for a single observation dataset is not a diagonal. The trick is to take the transpose to get it to the "correct" mapping such that the estimate is the same as sp:site interaction (we know they are suppose to be the same). Because the transpose is "required" to get the correct order, it will mess up the dimensions when we have multiple observations because it is no longer a square matrix.