R语言 使用分类环境水平的mvabund四角模型

z5btuh9x  于 2023-11-14  发布在  其他
关注(0)|答案(1)|浏览(224)

mvabund::traitglm()中,使用分类R矩阵而不是连续环境变量是否合适?我感兴趣的是MHW周期之间的相互作用的效果在典型的第四角模型中,使用L(分类丰度数据),R(环境数据)和Q(物种性状),R矩阵定义了与每个观察相关的环境变量。在这种情况下,我认为R是之前,期间,模型运行,swath_mod$fourth似乎反映了预期的趋势,但我不确定当环境矩阵R不连续时,这是否是traitglm()的适当使用。
这是L,R和Q的矩阵

  1. swath_L <- structure(list(pisaster_brevispinus = c(0, 0, 0, 0, 0, 0, 0,
  2. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), pterygophora_californica = c(61,
  3. 22, 0, 0, 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 70, 54, 15,
  4. 0, 0, 4, 0, 17), eisenia_arborea = c(5, 0, 0, 0, 0, 0, 0, 0,
  5. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), macrocystis_pyrifera = c(47,
  6. 225, 0, 184, 69, 10, 0, 0, 261, 29, 165, 2, 275, 0, 185, 13,
  7. 53, 49, 7, 54, 0, 0, 83, 322, 1), pisaster_giganteus = c(0, 4,
  8. 1, 7, 2, 3, 4, 1, 9, 0, 5, 3, 1, 1, 3, 5, 3, 7, 1, 4, 0, 0, 5,
  9. 15, 0), stephanocystis_osmundacea = c(0, 34, 0, 71, 14, 0, 0,
  10. 0, 14, 5, 19, 2, 3, 0, 11, 2, 8, 0, 33, 11, 0, 2, 2, 11, 0),
  11. strongylocentrotus_purpuratus = c(6, 1, 924, 0, 15, 7, 1818,
  12. 108, 3, 19, 1, 126, 2, 1671, 2, 952, 2, 46, 5, 0, 376, 365,
  13. 0, 0, 174), mesocentrotus_franciscanus = c(0, 0, 96, 0, 0,
  14. 5, 31, 80, 1, 1, 0, 11, 0, 133, 0, 73, 0, 0, 1, 1, 8, 42,
  15. 0, 0, 0), patiria_miniata = c(167, 82, 17, 83, 34, 99, 2,
  16. 24, 88, 9, 73, 24, 20, 12, 68, 23, 188, 80, 8, 39, 18, 44,
  17. 17, 49, 9), tethya_californiana = c(26, 22, 2, 8, 28, 6,
  18. 0, 5, 8, 0, 0, 9, 0, 0, 0, 0, 2, 13, 0, 61, 0, 0, 11, 0,
  19. 0), kelletia_kelletii = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  20. 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0), orthasterias_koehleri = c(0,
  21. 1, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
  22. 0, 0, 0, 0, 0), pisaster_ochraceus = c(0, 0, 0, 0, 0, 0,
  23. 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0),
  24. pycnopodia_helianthoides = c(1, 0, 0, 1, 1, 0, 0, 0, 1, 0,
  25. 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0), loxorhynchus_grandis = c(0,
  26. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  27. 0, 0, 0, 0, 0), neobernaya_spadicea = c(0, 0, 0, 0, 0, 0,
  28. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
  29. cancridae = c(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  30. 0, 0, 0, 1, 0, 0, 1, 0, 0, 0), lytechinus_pictus = c(0, 0,
  31. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  32. 0, 0, 0, 0), dermasterias_imbricata = c(4, 4, 1, 0, 2, 1,
  33. 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 1, 2, 1, 1, 0, 0, 0, 4, 0),
  34. crassadoma_gigantea = c(0, 0, 0, 0, 0, 1, 2, 478, 0, 0, 0,
  35. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1), henricia_leviuscula = c(2,
  36. 4, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 3, 0, 2,
  37. 0, 0, 1, 0, 3), nereocystis_luetkeana = c(0, 0, 0, 0, 0,
  38. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 11, 2, 0, 0, 0, 0,
  39. 65), pomaulax_gibberosus = c(0, 0, 4, 5, 8, 5, 0, 18, 0,
  40. 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 11, 0, 21, 1, 0, 0), aplysia_californica = c(0,
  41. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42. 0, 0, 0, 0, 0), cryptochiton_stelleri = c(1, 1, 1, 1, 0,
  43. 0, 1, 0, 3, 0, 9, 6, 9, 1, 1, 5, 1, 0, 0, 1, 2, 43, 1, 3,
  44. 0), mediaster_aequalis = c(5, 0, 0, 0, 5, 2, 0, 0, 0, 0,
  45. 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0), loxorhynchus_crispatus_scyra_acutifrons = c(0,
  46. 1, 0, 3, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 1, 1,
  47. 2, 3, 0, 1, 1), stylaster_californicus = c(0, 0, 0, 0, 0,
  48. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  49. 0), haliotis_rufescens = c(0, 0, 3, 0, 0, 3, 0, 0, 0, 0,
  50. 0, 4, 0, 0, 0, 9, 0, 3, 2, 0, 1, 1, 0, 2, 1), metridium = c(0,
  51. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  52. 0, 0, 0, 0, 0), megathura_crenulata = c(0, 0, 0, 0, 0, 0,
  53. 2, 0, 0, 0, 0, 3, 0, 1, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0),
  54. alaria_marginata = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  55. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), anthopleura_sola = c(0,
  56. 0, 0, 51, 0, 0, 0, 0, 5, 1, 9, 0, 0, 0, 2, 1, 0, 0, 0, 0,
  57. 5, 8, 0, 0, 0), pugettia_producta = c(0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), megastraea_undosa = c(0,
  59. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  60. 0, 0, 0, 0, 0), anthopleura_xanthogrammica = c(0, 0, 0, 0,
  61. 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
  62. 0, 0), pugettia_richii = c(1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
  63. 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0), costaria_costata = c(0,
  64. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  65. 0, 0, 0, 0, 1), cucumaria_miniata = c(5, 0, 0, 0, 0, 2, 0,
  66. 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 3, 0), cribrinopsis_albopunctata = c(14,
  67. 0, 28, 0, 3, 15, 0, 2, 0, 0, 0, 1, 0, 3, 0, 0, 1, 67, 12,
  68. 0, 0, 0, 0, 0, 0), ceratostoma_foliatum = c(2, 1, 4, 0, 1,
  69. 0, 23, 0, 0, 3, 0, 5, 9, 5, 0, 0, 0, 0, 0, 3, 0, 2, 0, 0,
  70. 1), pugettia_foliata = c(0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
  71. 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), styela_montereyensis = c(0,
  72. 0, 0, 0, 0, 1, 2, 0, 13, 1, 9, 0, 0, 0, 0, 0, 0, 1, 15, 0,
  73. 1, 0, 1, 2, 5), apostichopus_parvimensis = c(0, 0, 0, 1,
  74. 0, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
  75. 0, 0), apostichopus_californicus = c(0, 0, 0, 0, 0, 1, 0,
  76. 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0), laminaria_setchellii = c(2,
  77. 0, 0, 0, 15, 1, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 28, 139,
  78. 0, 3, 0, 0, 0, 405), balanus_nubilus = c(0, 0, 21, 0, 0,
  79. 0, 534, 15, 0, 3, 0, 2, 116, 130, 0, 29, 0, 0, 0, 0, 0, 3,
  80. 0, 19, 49), laminaria_farlowii = c(0, 0, 0, 0, 0, 0, 0, 0,
  81. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), pleurophycus_gardneri = c(3,
  82. 0, 0, 0, 4, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 1,
  83. 0, 0, 0, 0, 0), pachycerianthus_fimbriatus = c(0, 0, 0, 0,
  84. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  85. 0, 0), haliotis_walallensis = c(0, 0, 0, 0, 0, 0, 0, 0, 0,
  86. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), haliotis_kamtschatkana = c(0,
  87. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  88. 0, 0, 0, 0, 0), linckia_columbiae = c(0, 0, 0, 0, 0, 0, 0,
  89. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), solaster_dawsoni = c(0,
  90. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  91. 0, 0, 0, 0, 0), craniella_arb = c(0, 0, 0, 0, 0, 0, 0, 0,
  92. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), aplysia_vaccaria = c(0,
  93. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  94. 0, 0, 0, 0, 0), cryptolithodes_sitchensis = c(0, 0, 0, 0,
  95. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  96. 0, 0), leptasterias_hexactis = c(0, 0, 0, 0, 0, 0, 0, 0,
  97. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), urticina = c(0,
  98. 0, 0, 0, 4, 6, 0, 3, 0, 0, 3, 0, 0, 0, 0, 2, 6, 0, 2, 1,
  99. 0, 0, 0, 0, 0)), row.names = c(NA, -25L), class = "data.frame")
  100. swath_R <- structure(list(MHW = c("before", "before", "after", "before",
  101. "after", "after", "before", "before", "after", "during", "during",
  102. "before", "before", "before", "before", "before", "during", "before",
  103. "before", "during", "before", "before", "before", "before", "before"
  104. )), row.names = c(NA, -25L), class = "data.frame")
  105. swath_Q <- structure(list(trophic_ecology = structure(c(4L, 1L, 1L, 1L,
  106. 4L, 1L, 3L, 2L, 2L, 6L, 4L, 4L, 4L, 4L, 4L, 5L, 4L, 3L, 5L, 6L,
  107. 5L, 1L, 3L, 3L, 3L, 5L, 2L, 6L, 2L, 6L, 3L, 1L, 6L, 3L, 3L, 6L,
  108. 3L, 1L, 6L, 5L, 5L, 3L, 6L, 2L, 2L, 1L, 6L, 1L, 1L, 6L, 2L, 2L,
  109. 2L, 4L, 6L, 3L, 5L, 4L, 6L), levels = c("Autotroph", "Detritivore (algal)",
  110. "Herbivore", "Macroinvertivore", "Microinvertivore", "Planktivore"
  111. ), class = "factor")), row.names = c("pisaster_brevispinus",
  112. "pterygophora_californica", "eisenia_arborea", "macrocystis_pyrifera",
  113. "pisaster_giganteus", "stephanocystis_osmundacea", "strongylocentrotus_purpuratus",
  114. "mesocentrotus_franciscanus", "patiria_miniata", "tethya_californiana",
  115. "kelletia_kelletii", "orthasterias_koehleri", "pisaster_ochraceus",
  116. "pycnopodia_helianthoides", "loxorhynchus_grandis", "neobernaya_spadicea",
  117. "cancridae", "lytechinus_pictus", "dermasterias_imbricata", "crassadoma_gigantea",
  118. "henricia_leviuscula", "nereocystis_luetkeana", "pomaulax_gibberosus",
  119. "aplysia_californica", "cryptochiton_stelleri", "mediaster_aequalis",
  120. "loxorhynchus_crispatus_scyra_acutifrons", "stylaster_californicus",
  121. "haliotis_rufescens", "metridium", "megathura_crenulata", "alaria_marginata",
  122. "anthopleura_sola", "pugettia_producta", "megastraea_undosa",
  123. "anthopleura_xanthogrammica", "pugettia_richii", "costaria_costata",
  124. "cucumaria_miniata", "cribrinopsis_albopunctata", "ceratostoma_foliatum",
  125. "pugettia_foliata", "styela_montereyensis", "apostichopus_parvimensis",
  126. "apostichopus_californicus", "laminaria_setchellii", "balanus_nubilus",
  127. "laminaria_farlowii", "pleurophycus_gardneri", "pachycerianthus_fimbriatus",
  128. "haliotis_walallensis", "haliotis_kamtschatkana", "linckia_columbiae",
  129. "solaster_dawsoni", "craniella_arb", "aplysia_vaccaria", "cryptolithodes_sitchensis",
  130. "leptasterias_hexactis", "urticina"), class = "data.frame")

字符串
这就是traitglm模型

  1. swath_mod<- traitglm(swath_L, swath_R, swath_Q,
  2. method="glm1path", family = "negative.binomial")

fbcarpbf

fbcarpbf1#

是的,你可以这样做,如果你给予R的数据框输入,那么你可以有分类或定量。更多细节请访问github

相关问题