问题描述
在R中,我使用unmarked
包安装了动态入住模型。最佳模型包括site covariate
中yearly-site covariate
和gamma-formula
之间的一个交互项。为了解释结果,我想绘制一个交互图。但是,我不知道如何完成此操作。尤其是因为yearly-site covariate
由两个向量组成(一个包含历史数据,一个包含最近数据)。
我的数据结构如下。 (不幸的是,我无法生成伪造的数据来产生有意义的模型,也许有人也可以帮忙吗?):
library (unmarked)
library (tidyverse)
M <- 40 # number of Sites
J <- 1 # num secondary sample periods
Times <- 2 # num primary sample periods
# there are two years in which 40 study plots were surveyed for the occurence of a bird species:
year1 <- c (1,1,0)
year2 <- c (0,0)
bird_territories <- array (data = c (year1,year2),dim = c (M,Times)) %>% as.matrix()
# the study plots are clustered in three regions:
region <- c (rep ("A",15),rep ("B",12),rep ("C",13))
# var_a,var_b and var_c are site-specific coefficients,not changing with time
var_a <- (year1 + 0.1) * rnorm (40)^2
var_b <- rnorm (40)^2
var_c <- 1/var_a*(year2+1)
#var_d is a site-specific coefficient that also changes with time
var_d <- data.frame ("historic" = var_b,"recent" = var_b + (as.numeric (gsub (-1,year2-year1))))
# aggregate environmental covariates
covariatesSite <- data.frame (region = region,var_a = var_a,var_b = var_b,var_c = var_c)
covariatesSiteYear <- list (var_d = var_d)
# create unmarked data frame
bird_data <- unmarkedMultFrame (y = bird_territories,numPrimary = Times,siteCovs = covariatesSite,yearlySiteCovs = covariatesSiteYear
)
summary (bird_data)
我适合模特:
m1 <- colext(psiformula= ~ var_a + var_b,gammaformula = ~ var_c * var_d,epsilonformula = ~ 1,pformula = ~ 1,data = bird_data,method="BFGS")
summary (m1)
如前所述,我无法为该示例创建“酷”数据。但是,让我们假设摘要看起来像这样:
Call:
colext(psiformula = ~elevation + tpi2160 + coniferous_forest +
abandonde_pasture,gammaformula = ~sNow * tpi2160 + coniferous_forest,epsilonformula = ~1,pformula = ~1,data = gridCells_dom,method = "BFGS")
Initial (logit-scale):
Estimate SE z P(>|z|)
(Intercept) -0.713 0.302 -2.36 0.018104
var_a 0.617 0.177 3.49 0.000491
var_b 0.578 0.158 3.67 0.000243
Colonization (logit-scale):
Estimate SE z P(>|z|)
(Intercept) 0.211 0.513 0.412 0.68035
var_c 0.247 0.187 1.324 0.18545
var_d 0.666 0.229 2.910 0.00362
var_c:var_d -0.652 0.304 -2.144 0.03201
Extinction (logit-scale):
Estimate SE z P(>|z|)
-0.517 0.537 -0.964 0.335
Detection (logit-scale):
Estimate SE z P(>|z|)
1.2 0.711 1.69 0.0918
AIC: 1282.268
Number of sites: 40
optim convergence code: 0
optim iterations: 57
Bootstrap iterations: 0
我看到var_c和var_d之间的交互很重要。但是我无法弄清楚这些变量与影响研究鸟类物种的发生之间的关系。我认为,互动情节可能会有所帮助。但是:如何产生这样的情节?
感谢您的帮助,并为错误的假数据感到抱歉-我只是想不出如何做好更好的准备。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)