MATLAB: Estimate main effects and interactions

pareto plotstandardised effects

Hi,
I'm trying to replicate Minitab functionality by creating a Pareto Chart of standardised effects.
I'm using data from the example linked here where a DOE was run with 4 inputs and the response was measured. In the link, a full effects table is calculated which has effects of each of the inputs A,B,C & D but also all of the interaction terms.
In Matlab I'm trying to use stepwiselm to fit a model to the table of data but I find that Matlab is removing terms based on their P-value. is there a way to use this function but ask for all linear and interaction terms to be retained?
Secondly, I'm looking at the functions plotEffects() and plotInteraction() to use on the model but is there a function or way to group all main & interaction effects together in a single table, as per table 2 in the link above?
Many thanks, Dan

Best Answer

I was able to replicate the effect estimates, but only via a rather odd normalization scheme of the variables:
data = [1 10 220 10 50 8 70
2 15 220 10 50 2 60
3 10 240 10 50 10 89
4 15 240 10 50 4 81
5 10 220 12 50 16 60
6 15 220 12 50 5 49
7 10 240 12 50 11 88
8 15 240 12 50 14 82
9 10 220 10 80 15 69
10 15 220 10 80 9 62
11 10 240 10 80 1 88
12 15 240 10 80 13 81
13 10 220 12 80 3 60
14 15 220 12 80 12 52
15 10 240 12 80 6 86
16 15 240 12 80 7 79];
A = data(:,2);
B = data(:,3);
C = data(:,4);
D = data(:,5);
Y = data(:,7);
A = normalize(A,'zscore','robust');
B = normalize(B,'zscore','robust');
C = normalize(C,'zscore','robust');
D = normalize(D,'zscore','robust');
Y = 2*Y;
tbl = table(A,B,C,D,Y);
mdl = fitlm(tbl,'Y ~ A + B + C + D + A:B + A:C + A:D + B:C + B:D + C:D + A:B:C + A:B:D + A:C:D + B:C:D + A:B:C:D')
The normalization of the explanatory variables is a standard one, but I have no idea the reason behind needing to multiply the response variable by 2.
A slightly simpler way to specify the model in this case would be
modelMatrix = fullfact([2 2 2 2])-1;
mdl = fitlm([A B C D],Y,modelMatrix)
That's more of a Design of Experiments approach, I guess, but it boils down to the same thing.