How to retrieve a table entry using row name?
    30 ビュー (過去 30 日間)
  
       古いコメントを表示
    
The function anova returns a 3x5 table and I would like retreive the value from the row named Model and column named pValue. How do I do this? I don't know how to retreive a table entry by the row name, only by the row number.
mr = anova(lm,'summary')

0 件のコメント
採用された回答
  dpb
      
      
 2020 年 4 月 10 日
        It's a table; use the curlies "{}" to dereference row names to return the content of the row or regular paren's "()" to return a table:
Used example for anova to illustrate w/o your data to replicate--
load hospital
tbl = table(hospital.Age,hospital.Sex,hospital.BloodPressure(:,2), ...
                        'VariableNames',{'Age','Sex','BloodPressure'});
tbl.Sex = categorical(tbl.Sex);
mdl = fitlm(tbl,'BloodPressure ~ Sex + Age'); simplified model to remove nonlinear terms
>> tAnova=anova(mdl,'summary')
tAnova =
  5×5 table
                     SumSq     DF    MeanSq       F        pValue 
                     ______    __    ______    _______    ________
    Total            4757.8    99    48.059                       
    Model             243.8     2     121.9     2.6194    0.077994
    Residual           4514    97    46.537                       
    . Lack of fit      1514    40    37.851    0.71916     0.86306
    . Pure error       3000    57    52.632                       
>> 
>> tAnova('Total',:)  % retrieve Total SSQ by row name as table
ans =
  1×5 table
             SumSq     DF    MeanSq     F     pValue
             ______    __    ______    ___    ______
    Total    4757.8    99    48.059    NaN     NaN  
>> 
>> tAnova{'Total',:}  % retrieve as array of values only
ans =
   1.0e+03 *
    4.7578    0.0990    0.0481       NaN       NaN
>> 
See the detailed description of addressing tables that is in the lind from "See Also" for table for all the skinny on all the ways to address tables.
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で ANOVA についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!