使用 'poly' 时出错:使用 'effects' 包时 'degree' 必须小于唯一点数
Error using 'poly': 'degree' must be less than number of unique points while using 'effects' package
我正在尝试使用 effects
包在线性混合模型中创建效果图。我指定型号
fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
对于这个模型,我可以使用 summary
或 anova
生成分析结果,但当我尝试查看特定效果时:
allEffects(fit1)
#or
plot(allEffects(fit1))
#or
emmeans(fit1, pairwise ~ stimuli)
返回错误:
Error in poly(distance.code, 3, raw = FALSE) :
'degree' must be less than number of unique points
(对于 plot
函数,错误是不同的,但可能是由 allEffects
的错误引起的)
我了解到,根据对 and this question 的回复,“数值溢出”可能是 poly
术语的问题。但是,我不清楚这意味着什么或如何解决这个问题。
我还在 this post 和另一个关于 lme4 的 post 中看到我再也找不到了,我可能需要更新软件包所以我更新了 'effects' 和 'lme4' 尝试补救但无济于事。
因此,如果此错误是由于“数值溢出”引起的,我该如何解决该问题?或者,如果不是数字溢出,这是怎么回事,我该如何解决?
我使用 dput
的数据子集是:
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 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 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("before",
"during", "after"), class = "factor"), timeperiod = c(6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L), distance.code = c(0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L),
Values = c(910.721895276374, 922.652711611841, 926.219785713456,
918.776924477918, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 917.610324052986,
992.059286431433, 1042.05240231832, 1018.99804250179, 911.976009884021,
918.215389274037, 931.037495260958, 913.49701806948, 981.032280455129,
983.700699744073, 989.716307418049, 911.476759038955, 918.554393750162,
920.391856289719, 911.795802370903, 994.583211567691, 1006.58290843226,
1005.52479816571, 908.665064025178, 917.940176257067, 922.746174825048,
921.752449434568, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 924.221021573334,
982.154409713674, 1008.54477137219, 996.577798511801, 912.914857937818,
916.937508116615, 920.933077377339, 917.443294381608, 997.669828575817,
1007.44452218386, 1151.25894192961, 909.463528658898, 915.293665875472,
921.917039784441, 912.073280663674, 983.866984633392, 1002.04551764872,
986.791628665069, 907.695668282537, 917.845214744473, 932.330755620455,
917.500330773026, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 914.498616645498,
1000.3672969178, 1021.78461788922, 1011.40975353271, 915.037273600535,
914.099859036178, 924.116937361394, 913.523739017819, 994.428182266452,
1123.09745015276, 1004.1485272116, 914.431649376896, 915.27037594587,
929.411251949862, 910.549315840806, 974.273124973661, 1145.99211507205,
1013.58184367388, 913.467056616881, 920.213007520924, 919.794369158301,
912.333012054637, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 913.432298686233,
1015.24811721269, 1070.61183211249, 1016.57332551186, 910.196695694198,
923.403802532832, 905.400995326023, 934.612035397761, 1036.98011238981,
963.147077473505, 953.792949959199, 916.899569521736, 931.240844862156,
919.11781354823, 938.028220926723, 995.408916523572, 960.825305234446,
993.019295484939, 1026.22960551445, 1000.13773127026, 962.347584090332,
1074.31979099791, 904.090295814044, 908.836747102913, 928.867625382891,
918.100799763641, 906.282906701285, 913.146312873635, 921.224088728859,
977.094140033575, 972.599778534534, 964.658406857446, 1197.35130424458,
921.91272768213, 910.507770576621, 942.269786765654, 922.718235872787,
1014.34022271036, 1128.29327664605, 1043.1365958913, 1238.18704569961,
919.185972424773, 925.486310755197, 908.769520270226, 919.644447501213,
1030.20866627018, 956.104935565803, 955.159231718685, 922.01947330213,
934.451182538208, 928.626906337293, 941.089746683706, 986.326936258622,
1003.40797963907, 1007.57786522109, 1021.91264348048, 995.68658929192,
993.102343807935, 1114.80420865448, 901.633626404701, 908.255562868123,
922.840049924103, 917.012733437446, 907.541530752433, 915.050696506642,
925.95358291661, 983.542956895186, 972.236377246083, 965.082329354352,
1205.36753472358, 918.337944633569, 910.137012141557, 952.89462134025,
923.334999242316, 977.420371016686, 1154.17994731565, 1022.82998099991,
1186.66254220951, 927.061613377597, 926.745527716988, 908.284054932259,
921.213190559531, 966.157586219165, 974.986841619676, 959.421220417498,
916.559494755925, 935.817296050643, 918.835719171662, 912.457217113586,
1023.62078549133, 1009.23121097376, 978.938675917385, 1005.81651905991,
981.715747809821, 953.127134375762, 1088.16577366048, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 918.91715550342, 974.889830301362, 970.58615968713,
963.029605541189, 1182.94093491074, 915.889893279581, 908.147726780027,
942.742415528349, 928.20319656241, 979.939535179807, 1153.51966568673,
1020.93502990084, 1154.799618481, 916.246150801212, 936.016759720656,
914.4488779132, 918.823772018551, 962.397352323664, 986.957848140285,
972.131488585193, 985.364195731404, 932.548910038465, 917.363220594089,
919.124801182577, 1085.89850605988, 1031.66330597084, 974.763804119707,
1005.64983154588, 991.988118229379, 975.384741587994, 1064.14809010237,
902.60240793926, 907.989086075871, 923.287310593779, 912.878571722023,
904.107623756648, 905.563259817979, 917.423553921906, 991.530368160932,
975.190212414434, 965.951810135591, 1192.3330908297, 915.334621878897,
910.857441830446, 936.093336975328, 932.960789822422, 972.074491630181,
1106.77459226532, 993.45400883741, 1138.94109332484, 951.911391767329,
927.688604859773, 915.194279622847, 920.98264624041, 971.414103170297,
956.138106650696, 969.385400747507, 965.458656222347, 944.097918792458,
947.157460200658, 915.929397317864, 1029.14870726558, 992.151638322899,
964.680220137879, 954.129642526236, 981.48182339388, 968.10870393618,
1097.48462256339, 906.941701681267, 917.956716926981, 923.05649603805,
934.459432014683, 922.801034508827, 920.724850575215, 935.811146196027,
981.478432929603, 1012.67364507927, 966.471299899978, 1192.4066704659,
912.640460101352, 906.34455384334, 923.738349342148, 916.883929696437,
970.987788560016, 1210.42940542072, 975.753397539076, 1138.97675920151,
911.747488522664, 928.34872697947, 910.852487444859, 916.227875349016,
982.304620375747, 1028.52794775628, 999.236663664046, 913.408967803895,
934.334726415048, 916.354017093653, 918.660674732388, 1036.08727658415,
974.408618327141, 1006.21629092128, 1004.71633485176, 995.142763465394,
987.00017276687), wind.speed = c(0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 65, 65, 65,
65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9,
0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50,
50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55,
55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65,
65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50,
50, 50, 0, 0, 0)), row.names = c(85L, 86L, 87L, 88L, 89L,
90L, 91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L,
115L, 116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L,
133L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L,
158L, 159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L,
201L, 202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L,
226L, 227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L,
244L, 245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L,
269L, 270L, 271L, 272L, 273L, 615L, 616L, 617L, 618L, 619L, 620L,
621L, 622L, 623L, 624L, 625L, 626L, 627L, 628L, 629L, 630L, 631L,
632L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 647L, 648L, 649L,
650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L,
661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L, 670L, 671L,
672L, 673L, 674L, 675L, 676L, 684L, 685L, 686L, 687L, 688L, 689L,
690L, 691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L,
701L, 702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L,
712L, 713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 728L, 729L,
730L, 731L, 732L, 733L, 734L, 735L, 736L, 737L, 738L, 739L, 740L,
741L, 742L, 743L, 744L, 745L, 746L, 747L, 748L, 749L, 750L, 751L,
752L, 753L, 754L, 755L, 756L, 757L, 758L, 759L, 760L, 761L, 762L,
763L, 764L, 772L, 773L, 774L, 775L, 776L, 777L, 778L, 779L, 780L,
781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L, 790L, 791L,
792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L, 801L, 802L,
803L, 804L, 805L, 806L, 807L, 808L, 816L, 817L, 818L, 819L, 820L,
821L, 822L, 823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L,
832L, 833L, 834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L,
843L, 844L, 845L, 846L, 847L, 848L, 849L, 850L, 851L), class = "data.frame")
> ex.df <- head(ex.df, 100)
> dput(ex.df)
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L), .Label = c("BSF1",
"BSG1", "RLF3", "RLG3", "CCBSF1", "CCBSG1", "CPF1", "CPF2", "CPG1",
"CPG2", "OSG1", "OSG2", "RLF4", "RLF5", "RLF1", "RLF2", "RLG1",
"RLG2", "BNPF1", "BNPG1", "OSG3", "OSF1", "CMG3", "CMF1", "BSG2",
"BSG3", "WSF1", "WSF2", "HPG1", "HPG2"), class = "factor"), stimuli = structure(c(3L,
3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 1L), .Label = c("FOSP", "BHCO", "COHA", "YEWA", "TUTI"
), class = "factor"), habitat = structure(c(2L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L), .Label = c("Grassland",
"Forest"), class = "factor"), exp.period = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
1L, 1L), .Label = c("before", "during", "after"), class = "factor"),
timeperiod = c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L), distance.code = c(0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L), Values = c(910.721895276374,
922.652711611841, 926.219785713456, 918.776924477918, 1030.28919690464,
1121.98321368732, 992.741416151102, 910.878353926705, 920.201901019659,
922.134996121665, 917.610324052986, 992.059286431433, 1042.05240231832,
1018.99804250179, 911.976009884021, 918.215389274037, 931.037495260958,
913.49701806948, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 911.795802370903,
994.583211567691, 1006.58290843226, 1005.52479816571, 908.665064025178,
917.940176257067, 922.746174825048, 921.752449434568, 986.419049170517,
1042.41789735969, 1082.89658057517, 916.02310296116, 918.254868924698,
931.01648294424, 924.221021573334, 982.154409713674, 1008.54477137219,
996.577798511801, 912.914857937818, 916.937508116615, 920.933077377339,
917.443294381608, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 912.073280663674,
983.866984633392, 1002.04551764872, 986.791628665069, 907.695668282537,
917.845214744473, 932.330755620455, 917.500330773026, 972.609449456089,
1155.55960936774, 1083.40557091613, 909.903267624225, 914.846316952797,
921.279328283221, 914.498616645498, 1000.3672969178, 1021.78461788922,
1011.40975353271, 915.037273600535, 914.099859036178, 924.116937361394,
913.523739017819, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 910.549315840806,
974.273124973661, 1145.99211507205, 1013.58184367388, 913.467056616881,
920.213007520924, 919.794369158301, 912.333012054637, 983.816025282468,
1103.11322201674, 974.792027063404, 910.532609655114, 917.616832229923,
923.462599912213, 913.432298686233, 1015.24811721269, 1070.61183211249,
1016.57332551186, 910.196695694198, 923.403802532832), wind.speed = c(0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 65, 65)), row.names = c(85L, 86L, 87L, 88L, 89L, 90L,
91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L, 115L,
116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L, 158L,
159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 183L,
184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L, 201L,
202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L, 244L,
245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L, 269L,
270L, 271L, 272L, 273L, 615L, 616L), class = "data.frame")
感谢您的帮助!
编辑!!
我按照评论运行terms(fit1)
,结果如下:
terms(fit1)
Values ~ stimuli + timeperiod + scale(poly(distance.code, 3,
raw = FALSE)) * habitat + wind.speed
attr(,"variables")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
attr(,"factors")
stimuli timeperiod scale(poly(distance.code, 3, raw = FALSE)) habitat wind.speed
Values 0 0 0 0 0
stimuli 1 0 0 0 0
timeperiod 0 1 0 0 0
scale(poly(distance.code, 3, raw = FALSE)) 0 0 1 0 0
habitat 0 0 0 1 0
wind.speed 0 0 0 0 1
scale(poly(distance.code, 3, raw = FALSE)):habitat
Values 0
stimuli 0
timeperiod 0
scale(poly(distance.code, 3, raw = FALSE)) 1
habitat 1
wind.speed 0
attr(,"term.labels")
[1] "stimuli" "timeperiod"
[3] "scale(poly(distance.code, 3, raw = FALSE))" "habitat"
[5] "wind.speed" "scale(poly(distance.code, 3, raw = FALSE)):habitat"
attr(,"order")
[1] 1 1 1 1 1 2
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
attr(,"predvars")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
这是一个简单的平行示例,说明在 scale()
中包装 poly()
是罪魁祸首:
> library(emmeans)
> mod1 = lm(mpg ~ am + poly(disp, 3), data = mtcars)
> ref_grid(mod1)
'emmGrid' object with variables:
am = 0, 1
disp = 230.72
> mod2 = lm(mpg ~ am + scale(poly(disp, 3)), data = mtcars)
> ref_grid(mod2)
Error in poly(disp, 3) :
'degree' must be less than number of unique points
具体来说,对 scale()
的调用弄乱了模型 terms
组件中的 predvars
属性:
> attr(terms(mod1), "predvars")
list(mpg, am, poly(disp, 3, coefs = list(alpha = c(230.721875,
279.549822668452, 298.198735227759), norm2 = c(1, 32, 476184.7946875,
5315202742.2241, 64139299346388.8))))
这提供了构造正交多项式基所需的系数;而...
> attr(terms(mod2), "predvars")
list(mpg, am, scale(poly(disp, 3)))
该信息被排除在外。
请注意,无论如何 scale()
调用都是完全没有必要的,因为 poly()
会生成预测变量的标准正交矩阵。
我正在尝试使用 effects
包在线性混合模型中创建效果图。我指定型号
fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
对于这个模型,我可以使用 summary
或 anova
生成分析结果,但当我尝试查看特定效果时:
allEffects(fit1)
#or
plot(allEffects(fit1))
#or
emmeans(fit1, pairwise ~ stimuli)
返回错误:
Error in poly(distance.code, 3, raw = FALSE) :
'degree' must be less than number of unique points
(对于 plot
函数,错误是不同的,但可能是由 allEffects
的错误引起的)
我了解到,根据对 poly
术语的问题。但是,我不清楚这意味着什么或如何解决这个问题。
我还在 this post 和另一个关于 lme4 的 post 中看到我再也找不到了,我可能需要更新软件包所以我更新了 'effects' 和 'lme4' 尝试补救但无济于事。
因此,如果此错误是由于“数值溢出”引起的,我该如何解决该问题?或者,如果不是数字溢出,这是怎么回事,我该如何解决?
我使用 dput
的数据子集是:
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L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L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("before",
"during", "after"), class = "factor"), timeperiod = c(6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L), distance.code = c(0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L),
Values = c(910.721895276374, 922.652711611841, 926.219785713456,
918.776924477918, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 917.610324052986,
992.059286431433, 1042.05240231832, 1018.99804250179, 911.976009884021,
918.215389274037, 931.037495260958, 913.49701806948, 981.032280455129,
983.700699744073, 989.716307418049, 911.476759038955, 918.554393750162,
920.391856289719, 911.795802370903, 994.583211567691, 1006.58290843226,
1005.52479816571, 908.665064025178, 917.940176257067, 922.746174825048,
921.752449434568, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 924.221021573334,
982.154409713674, 1008.54477137219, 996.577798511801, 912.914857937818,
916.937508116615, 920.933077377339, 917.443294381608, 997.669828575817,
1007.44452218386, 1151.25894192961, 909.463528658898, 915.293665875472,
921.917039784441, 912.073280663674, 983.866984633392, 1002.04551764872,
986.791628665069, 907.695668282537, 917.845214744473, 932.330755620455,
917.500330773026, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 914.498616645498,
1000.3672969178, 1021.78461788922, 1011.40975353271, 915.037273600535,
914.099859036178, 924.116937361394, 913.523739017819, 994.428182266452,
1123.09745015276, 1004.1485272116, 914.431649376896, 915.27037594587,
929.411251949862, 910.549315840806, 974.273124973661, 1145.99211507205,
1013.58184367388, 913.467056616881, 920.213007520924, 919.794369158301,
912.333012054637, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 913.432298686233,
1015.24811721269, 1070.61183211249, 1016.57332551186, 910.196695694198,
923.403802532832, 905.400995326023, 934.612035397761, 1036.98011238981,
963.147077473505, 953.792949959199, 916.899569521736, 931.240844862156,
919.11781354823, 938.028220926723, 995.408916523572, 960.825305234446,
993.019295484939, 1026.22960551445, 1000.13773127026, 962.347584090332,
1074.31979099791, 904.090295814044, 908.836747102913, 928.867625382891,
918.100799763641, 906.282906701285, 913.146312873635, 921.224088728859,
977.094140033575, 972.599778534534, 964.658406857446, 1197.35130424458,
921.91272768213, 910.507770576621, 942.269786765654, 922.718235872787,
1014.34022271036, 1128.29327664605, 1043.1365958913, 1238.18704569961,
919.185972424773, 925.486310755197, 908.769520270226, 919.644447501213,
1030.20866627018, 956.104935565803, 955.159231718685, 922.01947330213,
934.451182538208, 928.626906337293, 941.089746683706, 986.326936258622,
1003.40797963907, 1007.57786522109, 1021.91264348048, 995.68658929192,
993.102343807935, 1114.80420865448, 901.633626404701, 908.255562868123,
922.840049924103, 917.012733437446, 907.541530752433, 915.050696506642,
925.95358291661, 983.542956895186, 972.236377246083, 965.082329354352,
1205.36753472358, 918.337944633569, 910.137012141557, 952.89462134025,
923.334999242316, 977.420371016686, 1154.17994731565, 1022.82998099991,
1186.66254220951, 927.061613377597, 926.745527716988, 908.284054932259,
921.213190559531, 966.157586219165, 974.986841619676, 959.421220417498,
916.559494755925, 935.817296050643, 918.835719171662, 912.457217113586,
1023.62078549133, 1009.23121097376, 978.938675917385, 1005.81651905991,
981.715747809821, 953.127134375762, 1088.16577366048, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 918.91715550342, 974.889830301362, 970.58615968713,
963.029605541189, 1182.94093491074, 915.889893279581, 908.147726780027,
942.742415528349, 928.20319656241, 979.939535179807, 1153.51966568673,
1020.93502990084, 1154.799618481, 916.246150801212, 936.016759720656,
914.4488779132, 918.823772018551, 962.397352323664, 986.957848140285,
972.131488585193, 985.364195731404, 932.548910038465, 917.363220594089,
919.124801182577, 1085.89850605988, 1031.66330597084, 974.763804119707,
1005.64983154588, 991.988118229379, 975.384741587994, 1064.14809010237,
902.60240793926, 907.989086075871, 923.287310593779, 912.878571722023,
904.107623756648, 905.563259817979, 917.423553921906, 991.530368160932,
975.190212414434, 965.951810135591, 1192.3330908297, 915.334621878897,
910.857441830446, 936.093336975328, 932.960789822422, 972.074491630181,
1106.77459226532, 993.45400883741, 1138.94109332484, 951.911391767329,
927.688604859773, 915.194279622847, 920.98264624041, 971.414103170297,
956.138106650696, 969.385400747507, 965.458656222347, 944.097918792458,
947.157460200658, 915.929397317864, 1029.14870726558, 992.151638322899,
964.680220137879, 954.129642526236, 981.48182339388, 968.10870393618,
1097.48462256339, 906.941701681267, 917.956716926981, 923.05649603805,
934.459432014683, 922.801034508827, 920.724850575215, 935.811146196027,
981.478432929603, 1012.67364507927, 966.471299899978, 1192.4066704659,
912.640460101352, 906.34455384334, 923.738349342148, 916.883929696437,
970.987788560016, 1210.42940542072, 975.753397539076, 1138.97675920151,
911.747488522664, 928.34872697947, 910.852487444859, 916.227875349016,
982.304620375747, 1028.52794775628, 999.236663664046, 913.408967803895,
934.334726415048, 916.354017093653, 918.660674732388, 1036.08727658415,
974.408618327141, 1006.21629092128, 1004.71633485176, 995.142763465394,
987.00017276687), wind.speed = c(0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 65, 65, 65,
65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9,
0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50,
50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55,
55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65,
65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50,
50, 50, 0, 0, 0)), row.names = c(85L, 86L, 87L, 88L, 89L,
90L, 91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L,
115L, 116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L,
133L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L,
158L, 159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L,
201L, 202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L,
226L, 227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L,
244L, 245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L,
269L, 270L, 271L, 272L, 273L, 615L, 616L, 617L, 618L, 619L, 620L,
621L, 622L, 623L, 624L, 625L, 626L, 627L, 628L, 629L, 630L, 631L,
632L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 647L, 648L, 649L,
650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L,
661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L, 670L, 671L,
672L, 673L, 674L, 675L, 676L, 684L, 685L, 686L, 687L, 688L, 689L,
690L, 691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L,
701L, 702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L,
712L, 713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 728L, 729L,
730L, 731L, 732L, 733L, 734L, 735L, 736L, 737L, 738L, 739L, 740L,
741L, 742L, 743L, 744L, 745L, 746L, 747L, 748L, 749L, 750L, 751L,
752L, 753L, 754L, 755L, 756L, 757L, 758L, 759L, 760L, 761L, 762L,
763L, 764L, 772L, 773L, 774L, 775L, 776L, 777L, 778L, 779L, 780L,
781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L, 790L, 791L,
792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L, 801L, 802L,
803L, 804L, 805L, 806L, 807L, 808L, 816L, 817L, 818L, 819L, 820L,
821L, 822L, 823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L,
832L, 833L, 834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L,
843L, 844L, 845L, 846L, 847L, 848L, 849L, 850L, 851L), class = "data.frame")
> ex.df <- head(ex.df, 100)
> dput(ex.df)
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L), .Label = c("BSF1",
"BSG1", "RLF3", "RLG3", "CCBSF1", "CCBSG1", "CPF1", "CPF2", "CPG1",
"CPG2", "OSG1", "OSG2", "RLF4", "RLF5", "RLF1", "RLF2", "RLG1",
"RLG2", "BNPF1", "BNPG1", "OSG3", "OSF1", "CMG3", "CMF1", "BSG2",
"BSG3", "WSF1", "WSF2", "HPG1", "HPG2"), class = "factor"), stimuli = structure(c(3L,
3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 1L), .Label = c("FOSP", "BHCO", "COHA", "YEWA", "TUTI"
), class = "factor"), habitat = structure(c(2L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L), .Label = c("Grassland",
"Forest"), class = "factor"), exp.period = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
1L, 1L), .Label = c("before", "during", "after"), class = "factor"),
timeperiod = c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L), distance.code = c(0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L), Values = c(910.721895276374,
922.652711611841, 926.219785713456, 918.776924477918, 1030.28919690464,
1121.98321368732, 992.741416151102, 910.878353926705, 920.201901019659,
922.134996121665, 917.610324052986, 992.059286431433, 1042.05240231832,
1018.99804250179, 911.976009884021, 918.215389274037, 931.037495260958,
913.49701806948, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 911.795802370903,
994.583211567691, 1006.58290843226, 1005.52479816571, 908.665064025178,
917.940176257067, 922.746174825048, 921.752449434568, 986.419049170517,
1042.41789735969, 1082.89658057517, 916.02310296116, 918.254868924698,
931.01648294424, 924.221021573334, 982.154409713674, 1008.54477137219,
996.577798511801, 912.914857937818, 916.937508116615, 920.933077377339,
917.443294381608, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 912.073280663674,
983.866984633392, 1002.04551764872, 986.791628665069, 907.695668282537,
917.845214744473, 932.330755620455, 917.500330773026, 972.609449456089,
1155.55960936774, 1083.40557091613, 909.903267624225, 914.846316952797,
921.279328283221, 914.498616645498, 1000.3672969178, 1021.78461788922,
1011.40975353271, 915.037273600535, 914.099859036178, 924.116937361394,
913.523739017819, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 910.549315840806,
974.273124973661, 1145.99211507205, 1013.58184367388, 913.467056616881,
920.213007520924, 919.794369158301, 912.333012054637, 983.816025282468,
1103.11322201674, 974.792027063404, 910.532609655114, 917.616832229923,
923.462599912213, 913.432298686233, 1015.24811721269, 1070.61183211249,
1016.57332551186, 910.196695694198, 923.403802532832), wind.speed = c(0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 65, 65)), row.names = c(85L, 86L, 87L, 88L, 89L, 90L,
91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L, 115L,
116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L, 158L,
159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 183L,
184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L, 201L,
202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L, 244L,
245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L, 269L,
270L, 271L, 272L, 273L, 615L, 616L), class = "data.frame")
感谢您的帮助!
编辑!!
我按照评论运行terms(fit1)
,结果如下:
terms(fit1)
Values ~ stimuli + timeperiod + scale(poly(distance.code, 3,
raw = FALSE)) * habitat + wind.speed
attr(,"variables")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
attr(,"factors")
stimuli timeperiod scale(poly(distance.code, 3, raw = FALSE)) habitat wind.speed
Values 0 0 0 0 0
stimuli 1 0 0 0 0
timeperiod 0 1 0 0 0
scale(poly(distance.code, 3, raw = FALSE)) 0 0 1 0 0
habitat 0 0 0 1 0
wind.speed 0 0 0 0 1
scale(poly(distance.code, 3, raw = FALSE)):habitat
Values 0
stimuli 0
timeperiod 0
scale(poly(distance.code, 3, raw = FALSE)) 1
habitat 1
wind.speed 0
attr(,"term.labels")
[1] "stimuli" "timeperiod"
[3] "scale(poly(distance.code, 3, raw = FALSE))" "habitat"
[5] "wind.speed" "scale(poly(distance.code, 3, raw = FALSE)):habitat"
attr(,"order")
[1] 1 1 1 1 1 2
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
attr(,"predvars")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
这是一个简单的平行示例,说明在 scale()
中包装 poly()
是罪魁祸首:
> library(emmeans)
> mod1 = lm(mpg ~ am + poly(disp, 3), data = mtcars)
> ref_grid(mod1)
'emmGrid' object with variables:
am = 0, 1
disp = 230.72
> mod2 = lm(mpg ~ am + scale(poly(disp, 3)), data = mtcars)
> ref_grid(mod2)
Error in poly(disp, 3) :
'degree' must be less than number of unique points
具体来说,对 scale()
的调用弄乱了模型 terms
组件中的 predvars
属性:
> attr(terms(mod1), "predvars")
list(mpg, am, poly(disp, 3, coefs = list(alpha = c(230.721875,
279.549822668452, 298.198735227759), norm2 = c(1, 32, 476184.7946875,
5315202742.2241, 64139299346388.8))))
这提供了构造正交多项式基所需的系数;而...
> attr(terms(mod2), "predvars")
list(mpg, am, scale(poly(disp, 3)))
该信息被排除在外。
请注意,无论如何 scale()
调用都是完全没有必要的,因为 poly()
会生成预测变量的标准正交矩阵。