具有固定变量和随机变量的GLMM脚本

时间:2018-09-05 19:45:42

标签: r lme4 mixed-models

我正在尝试在R中创建一个模型来说明我的调查。 该研究涉及许多解释变量,响应变量称为HUNTED,数据约为3个不同的时间PERIODS。 我的数据集太大,我只添加了一部分,以便您了解其分布情况。

我的问题:如果我像以前一样在脚本中保留变量PERIOD,程序会“理解”在PERIOD级别的名为“ “之前”的狩猎物种数量少于PERIOD级的“ DURING”(狩猎)物种吗?因此,因此DURING级别显得更为重要,还是我误解了结果?

Obs .:称为“ AFTER”的PERIOD级别未出现在控制台中,因为它的用法类似于基本级别。

我在控制台中得到的结果是:

Random effects:
 Groups Name        Variance Std.Dev.
 Specie (Intercept) 1.728    1.314   
Number of obs: 5622, groups:  Specie, 25

Fixed effects:
                 Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -1.611e+01 2.510e+00 -6.420 1.36e-10 *     
eco             9.337e-02 6.522e-02 1.432 0.152254    
TrophicLevel    4.403e-01 3.561e-01 1.236 0.216324    
age             8.676e-04 2.616e-03 0.332 0.740175    
log(body_mass)  8.717e+00 1.495e+00 5.833 5.46e-09    
habitat        -5.238e-01 8.269e-02 -6.335 2.37e-10     
ABUND           4.432e-01 4.938e-02 8.976 < 2e-16 *    
BEFORE         -2.850e-01 1.090e-01 -2.615 0.008932 ** 
DURING          3.478e-01 9.103e-02 3.821 0.000133 ***     
taboo          -1.057e+00 1.016e+00 -1.041 0.297926

我的代码

allspecies4<-read.csv(file= "dataGLMM.csv", header= TRUE, sep= ";" )
attach(allspecies4)
library(lme4)
allspecies4<- glmer(HUNTED~ eco+TrophicLevel+age+ log(body_mass)+
                      habitat+ABUND + PERIOD + tabu +(1|Specie),
                    data=dataGLMM, family=binomial)

summary(allspecies4)

示例数据

    Specie body_mass TrophicLevel age eco habitat PERIOD HUNTED ABUND tabu
  Cerc_mit      3.70            2  57   2       F DURING      0     2    1
  Cerc_mit      3.70            2  57   2       F  AFTER      0     3    1
  Cerc_mit      3.70            2  57   2       F BEFORE      0     4    1
  Cerc_mit      3.70            2  67   2       F DURING      1     2    1
  Cerc_mit      3.70            2  67   2       F  AFTER      0     2    1
 Chlor_cyn      3.70            2  53   2       S DURING      0     3    0
 Chlor_cyn      3.70            2  74   2       S DURING      0     3    0
 Chlor_cyn      3.70            2  30   2       S DURING      0     4    0
 Chlor_cyn      3.70            2  63   2       S DURING      0     4    0
 Chlor_cyn      3.70            2  54   2       S DURING      0     3    0
 Chlor_cyn      3.70            2  30   2       S DURING      0     4    0
 Chlor_cyn      3.70            2  30   2       S DURING      0     3    0
 Phil_mont      3.69            2  24   3       F DURING      0     3    0
 Phil_mont      3.69            2  24   3       F BEFORE      0     4    0
 Phil_mont      3.69            2  33   3       F  AFTER      1     4    0
 Phil_mont      3.69            2  33   3       F BEFORE      0     4    0
 Phil_mont      3.69            2  33   3       F DURING      0     4    0
 Phil_mont      3.69            2  43   3       F BEFORE      0     4    0
 Phil_mont      3.69            2  43   3       F DURING      0     4    0

0 个答案:

没有答案