Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
831 views
in Technique[技术] by (71.8m points)

statistics - Categorical covariate with two way anova in R

This is a random sample of my data set:

structure(list(DTI_ID = structure(c(31L, 241L, 84L, 298L, 185L, 
269L, 198L, 24L, 286L, 177L, 228L, 158L, 57L, 293L, 218L, 8L, 
180L, 39L, 211L, 134L, 291L, 309L, 99L, 70L, 154L, 138L, 250L, 
41L, 276L, 262L, 96L, 139L, 232L, 12L, 294L, 38L, 244L, 289L, 
280L, 196L, 58L, 44L, 188L, 152L, 143L, 302L, 201L, 27L, 24L, 
67L, 247L, 223L, 74L, 32L, 110L, 98L, 303L, 256L, 71L, 30L, 236L, 
266L, 307L, 224L, 100L, 73L, 288L, 230L, 182L, 159L, 190L, 123L, 
241L, 169L, 103L, 40L, 248L, 293L, 60L, 260L, 168L, 267L, 144L, 
89L, 139L, 231L, 204L, 130L, 278L, 227L, 205L, 268L, 88L, 221L, 
208L, 306L, 242L, 145L, 21L, 165L, 217L, 159L, 206L, 70L, 121L, 
181L, 95L, 279L, 265L, 4L, 122L, 177L, 234L, 34L, 261L, 86L, 
2L, 296L, 39L, 283L, 251L, 126L, 188L, 176L, 220L, 77L, 225L, 
73L, 48L, 107L, 280L, 118L, 38L, 310L, 297L, 258L, 89L, 205L, 
4L, 54L, 16L, 95L, 119L, 40L, 9L, 66L, 64L, 55L, 131L, 290L, 
166L, 170L, 182L, 139L, 125L, 201L, 302L, 137L, 8L, 81L, 61L, 
119L, 278L, 135L, 117L, 65L, 21L, 200L, 150L, 146L, 54L, 262L, 
152L, 224L, 162L, 111L, 251L, 130L, 41L, 271L, 33L, 86L, 32L, 
199L, 49L, 180L, 101L, 271L, 80L, 84L, 293L, 5L, 170L, 74L, 279L, 
281L, 255L, 210L, 52L, 248L, 53L, 121L, 190L, 141L, 213L, 138L, 
112L, 234L, 235L, 40L, 233L, 115L, 154L, 11L, 76L, 29L, 19L, 
249L, 1L, 207L), .Label = c("5356", "5357", "5358", "5359", "5360", 
"5363", "5373", "5381", "5383", "5386", "5395", "5397", "5400", 
"5401", "5444", "5445", "5446", "5448", "5450", "5451", "5454", 
"5472", "5473", "5475", "5476", "5477", "5478", "5480", "5481", 
"5483", "5487", "5494", "5495", "5504", "5505", "5506", "5507", 
"5508", "5509", "5513", "5514", "5515", "5516", "5517", "5518", 
"5519", "5521", "5523", "5524", "5526", "5527", "5528", "5544", 
"5545", "5546", "5547", "5551", "5552", "5553", "5554", "5555", 
"5558", "5559", "5560", "5562", "5564", "5566", "5573", "5574", 
"5575", "5576", "5577", "5578", "5579", "5584", "5585", "5587", 
"5588", "5589", "5591", "5594", "5595", "5604", "5611", "5612", 
"5613", "5615", "5616", "5619", "5620", "5621", "5622", "5626", 
"5627", "5628", "5631", "5632", "5634", "5635", "5643", "5652", 
"5653", "5654", "5655", "5656", "5657", "5659", "5660", "5661", 
"5664", "5665", "5666", "5669", "5671", "5672", "5673", "5678", 
"5680", "5688", "5689", "5690", "5691", "5692", "5698", "5699", 
"5700", "5702", "5703", "5704", "5706", "5708", "5709", "5710", 
"5730", "5731", "5732", "5733", "5734", "5735", "5739", "5740", 
"5741", "5742", "5743", "5744", "5745", "5746", "5747", "5748", 
"5749", "5750", "5753", "5754", "5755", "5766", "5767", "5776", 
"5777", "5778", "5779", "5780", "5781", "5787", "5788", "5789", 
"5790", "5791", "5792", "5793", "5797", "5798", "5799", "5800", 
"5801", "5810", "5811", "5812", "5813", "5814", "5819", "5820", 
"5821", "5822", "5823", "5824", "5825", "5827", "5828", "5829", 
"5830", "5857", "5859", "5874", "5875", "5876", "5877", "5878", 
"5879", "5883", "5884", "5886", "5887", "5888", "5889", "5890", 
"5892", "5893", "5896", "5899", "5900", "5909", "5910", "5918", 
"5919", "5920", "5921", "5922", "5923", "5927", "5929", "5931", 
"5932", "5933", "5934", "5936", "5937", "5941", "5943", "5944", 
"5949", "5950", "5951", "5952", "5956", "5957", "5958", "5959", 
"5971", "5972", "5973", "5976", "5979", "5980", "5981", "6001", 
"6002", "6003", "6004", "6005", "6009", "6027", "6028", "6033", 
"6042", "6054", "6063", "6067", "6073", "6076", "6077", "6078", 
"6079", "6080", "6081", "6082", "6083", "6098", "6102", "6103", 
"6104", "6105", "6106", "6107", "6111", "6119", "6133", "6146", 
"6147", "6157", "6158", "6160", "6161", "6162", "6163", "6164", 
"6165", "6166", "6167", "6168", "6169", "6170", "6171", "6172", 
"6173", "6174", "6175", "6190", "6193", "6195", "6196", "6197", 
"6208", "6228", "6229", "6232", "6255", "6268", "6269", "6270", 
"6275"), class = "factor"), Gender = structure(c(2L, 2L, 1L, 
2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 
1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 
2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 
1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 
2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 
2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 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, 3L, 2L
    ), .Label = c("A", "B","C", "D"), class = "factor"), 
    value = c(0.326713741, 0.349206239, 0.365954667, 
    0.313958377, 0.480487555, 0.431199849, 0.446729183, 0.337009728, 
    0.331222087, 0.386937141, 0.372758657, 0.305083066, 0.504718482, 
    0.414191663, 0.40949735, 0.271525055, 0.30009532, 0.50117749, 
    0.387669057, 0.330797315, 0.390679717, 0.452181876, 0.423188657, 
    0.396808296, 0.388510793, 0.298505336, 0.412985921, 0.327000797, 
    0.304242313, 0.277513236, 0.394773901, 0.4322685, 0.440891623, 
    0.439061254, 0.453015536, 0.385896087, 0.452299237, 0.296923041, 
    0.443324417, 0.420699686, 0.282610774, 0.303566545, 0.535346806, 
    0.393591255, 0.32561186, 0.309230596, 0.417596817, 0.281766504, 
    0.445347071, 0.353419632, 0.354420125, 0.429613769, 0.385733992, 
    0.155136898, 0.485385537, 0.439544022, 0.436584443, 0.458706915, 
    0.600399196, 0.440390527, 0.362952292, 0.37253055, 0.37306264, 
    0.371298164, 0.469741255, 0.573943496, 0.283266962, 0.391182601, 
    0.663566113, 0.517713368, 0.327498972, 0.353969425, 0.443648636, 
    0.449972481, 0.434426159, 0.305042148, 0.422493547, 0.194572225, 
    0.331083208, 0.418288261, 0.447215647, 0.429001331, 0.339149892, 
    0.336879104, 0.471237898, 0.408330619, 0.393405557, 0.486086488, 
    0.427713692, 0.379242182, 0.40456596, 0.326695889, 0.393235713, 
    0.452374548, 0.332855165, 0.323469192, 0.396484613, 0.372199923, 
    0.257353246, 0.405249774, 0.326494843, 0.420468688, 0.335335255, 
    0.267627925, 0.379383296, 0.338241786, 0.416064918, 0.381003618, 
    0.284006208, 0.442705005, 0.494199812, 0.464447916, 0.370418996, 
    0.293953657, 0.34482345, 0.47208631, 0.378798842, 0.407261223, 
    0.34767586, 0.424341202, 0.434532404, 0.342623293, 0.628901243, 
    0.381492049, 0.540111601, 0.392371207, 0.4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Adding Gender to group_by as well, allowed the code to run properly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...