Why is the design matrix different when using x2fx as opposed to the output of cordexch?

4 views (last 30 days)
Dear all,
I have a problem where I am using a D-optimal interaction design with some categorical variables. However, I found it impossible to reconstruct the design matrix "X" from the predictor matrix "dCe" using the "x2fx" function if the number of tries in the "cordexch" function is more than 1. In terms of code, with an example:
[dCe, X1] = cordexch(2, 40, 'interaction', 'categorical', 1:2, 'levels', [3,3], 'tries', 100);
X2 = x2fx(dCe, 'interaction', 1:2);
Why is X1 ~= X2 ? The predictor matrix dCe is the same in both cases, but both functions come up with different design matrices... I found that using only 1 try gets the same output for both cases, but as soon as 'tries' > 1, the matrices differ...

Answers (1)

Aditya
Aditya on 31 Jan 2025
Hi Lukas,
The issue you're encountering stems from the way the cordexch function handles multiple tries when generating a D-optimal design. When you set the 'tries' parameter to a value greater than 1, cordexch performs multiple attempts to find the best design, potentially leading to different internal configurations that might not be directly reconstructible using x2fx.
Possible Solutions:
  • Single Try: If you need X1 and X2 to match exactly, you may need to stick with a single try ('tries', 1). This ensures that the design matrix is generated in a straightforward manner without multiple optimizations.
  • Manual Check: Manually inspect the differences between X1 and X2 to understand how the encoding differs. This might give you insights into how cordexch optimizes designs with multiple tries.
  • Custom Encoding: If you require a specific encoding scheme, consider manually constructing the design matrix using the levels and interactions you need, rather than relying on cordexch to do so.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!