2^k factorial design ANOVA Table

18 Ansichten (letzte 30 Tage)
Josiah Kleven am 25 Nov. 2023
Beantwortet: Shivansh am 5 Dez. 2023
I have a very simple factorial design experiment that I need to make an anova table for, but hours of banging my head against the wall has got me this:
factorA = [1 1 -1 -1 1 1 -1 -1]; %factor A level upper or lower
factorB = [1 1 1 1 -1 -1 -1 -1]; %Factor B levels
Response = [19.3 20.2 8.1 9.7 20.3 24.5 10.4 11.8]; %Responses, 2 for each comibination of Factor levels
Table = table(factorA', factorB', Response', 'VariableNames', {'FactorA', 'FactorB', 'Response'})
rm = fitrm(Table,'FactorA-FactorB~Response') %As far as I can tell this is the correct setup for the rm function
Anova_table = ranova(rm)
This code gives me an output, but I'm pretty sure it's wrong, so I need to know if what I have is giving me the right output or if I'm on the wrong track. I also need an equation that models the data given a certain set of selected factors and factor levels but I can't understand how to do this either.
Any input is greatly appreciated.
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shivansh am 5 Dez. 2023
Hi Josiah,
I understand that you want to make an ANOVA table for your factorial design experiment. The “fitrm” and “ranova” might not be the ideal approach in your case.
I am assuming that you do not have repeated measures or blocking factors. In that case, you can try using “anovan” for n-way ANOVA.
Here is a modified code which uses two-way ANOVA for data analysis.
factorA = [1 1 -1 -1 1 1 -1 -1]; %factor A level upper or lower
factorB = [1 1 1 1 -1 -1 -1 -1]; %Factor B levels
Response = [19.3 20.2 8.1 9.7 20.3 24.5 10.4 11.8]; %Responses, 2 for each combination of Factor levels
% Create a table for ANOVA
Table = table(factorA', factorB', Response', 'VariableNames', {'FactorA', 'FactorB', 'Response'});
% Perform two-way ANOVA
[p, tbl, stats] = anovan(Table.Response, {Table.FactorA, Table.FactorB}, 'model', 'interaction', 'varnames', {'FactorA', 'FactorB'});
% Display the ANOVA table
disp(tbl);
In the above code, the 'model' argument in “anovan” specifies the type of model you want to fit. The value 'interaction' includes both main effects and the interaction effect between the factors. If you want to exclude the interaction, you can use 'linear' instead.
For the second part of question, you can use fitlm for a linear regression model that includes both factors and their interaction to model the data.
% Fit a linear model with interaction
lm = fitlm(Table, 'Response~FactorA*FactorB');
% Display the linear model summary
disp(lm);
This code snippet will also display a summary for the model which includes the values for coefficients which can be used to make predictions or further analysis of factors.
Hope it helps!
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Analysis of Variance and Covariance finden Sie in Help Center und File Exchange

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by