Writing a linear model for anova with a nested design

조회 수: 5 (최근 30일)
Zach
Zach 2015년 10월 21일
답변: David Lewis 2019년 6월 12일
I am currently trying to create a fixed effect linear model using fitlm to run ANOVA on. My variables are 'Location','Block','Count','Disease', and response variable is 'Y'. My issue is that I am not sure what syntax I should use in the formula so that Blocks are nested within Location. My current model formula is:
lm1 = fitlm(table,'Y~Count*Disease*Location+Block','ResponseVar','Y','PredictorVars',...{'Count','Disease','Location','Block'},'CategoricalVar',{'Location','Block','Disease'});
This is giving me a linear model but it does not appear that Blocks are nested within location. Does anyone know how I should change my formula so blocks are nested within location?
Thanks

답변 (1개)

David Lewis
David Lewis 2019년 6월 12일
Here is the documentation for analysis of variance. An name/value option for nesting is included.

카테고리

Help CenterFile Exchange에서 ANOVA에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by