使用glmmML的step-function时出错

时间:2014-04-07 05:29:22

标签: r error-handling

当我尝试使用步骤功能时,我收到此错误:

"Error in if (all(is.finite(c(n0, nnew))) && nnew != n0) 
stop("number of rows in use has changed: remove missing values?") :  
   missing value where TRUE/FALSE needed"

似乎它与缺失的值有关。我检查过这个,没有。我搜索了有关此错误的更多信息。几年前我只能找到一篇未回答的帖子。

我已经从我的数据集中选择了随机样本,以及我使用的R代码。 (SD =整数。DISTCD =数字。HuntRegionDNIDcat =分类)。

Sika.sample <- structure(list(ID = c(16L, 19L, 68L, 58L, 35L, 21L, 21L, 83L, 
48L, 64L, 73L, 63L, 80L, 63L, 8L, 43L, 77L, 75L, 27L, 73L, 22L, 
65L, 32L, 78L, 61L, 68L, 46L, 30L, 44L, 78L, 58L, 72L, 27L, 46L, 
41L, 52L, 36L, 38L, 67L, 18L, 45L, 75L, 72L, 8L, 5L, 62L, 70L, 
23L, 4L, 8L, 7L, 30L, 37L, 7L, 68L, 20L, 80L, 44L, 39L, 6L, 83L, 
26L, 66L, 21L, 5L, 39L, 10L, 73L, 69L, 44L, 51L, 69L, 53L, 63L, 
27L, 29L, 15L, 13L, 1L, 18L, 31L, 9L, 42L, 32L, 78L, 62L, 23L, 
3L, 29L, 49L, 81L, 60L, 70L, 73L, 8L, 69L, 79L, 19L, 47L, 38L
), SD = c(8L, 3L, 4L, 6L, 2L, 1L, 8L, 0L, 4L, 2L, 8L, 2L, 0L, 
8L, 0L, 0L, 2L, 2L, 0L, 3L, 0L, 2L, 25L, 0L, 18L, 28L, 0L, 10L, 
1L, 0L, 0L, 1L, 0L, 10L, 1L, 0L, 0L, 7L, 0L, 0L, 18L, 0L, 0L, 
0L, 0L, 28L, 1L, 0L, 10L, 1L, 0L, 2L, 0L, 0L, 3L, 7L, 0L, 0L, 
8L, 0L, 5L, 1L, 3L, 33L, 1L, 3L, 0L, 1L, 0L, 0L, 19L, 0L, 3L, 
3L, 0L, 1L, 0L, 3L, 5L, 2L, 0L, 0L, 0L, 2L, 0L, 10L, 0L, 0L, 
0L, 0L, 2L, 0L, 2L, 0L, 8L, 1L, 0L, 0L, 0L, 0L), DIST = c(0, 
0, 42.7, 800.6, 44.6, 0, 0, 19.3, 42.8, 570.7, 111.7, 348.2, 
0, 348.2, 24, 0, 7.6, 3.1, 23.2, 111.7, 0, 404, 331.9, 0, 0, 
42.7, 0, 97.7, 0, 0, 800.6, 295.5, 23.2, 0, 0, 0, 4.3, 29.5, 
408.1, 37.7, 0, 3.1, 295.5, 24, 15.5, 0, 34.1, 0, 22.1, 24, 223.4, 
97.7, 99.1, 223.4, 42.7, 75.2, 0, 0, 279.5, 28, 19.3, 58, 972.3, 
0, 15.5, 279.5, 652.8, 111.7, 24.8, 0, 0, 24.8, 0, 348.2, 23.2, 
278.8, 20.1, 30.6, 4.9, 37.7, 46.3, 735.7, 1.2, 331.9, 0, 0, 
0, 5.8, 278.8, 817.6, 0, 190.4, 34.1, 111.7, 24, 24.8, 11.3, 
0, 0, 29.5), CD = c(103.9, 25.3, 46.6, 99.4, 55, 95.2, 68, 62.5, 
59, 78.8, 65.5, 46.6, 51.8, 78.2, 52.7, 15.7, 62.8, 81.3, 40.9, 
82.5, 64.9, 50.1, 62, 56.1, 88.9, 77.2, 48.1, 69.2, 37.9, 101.8, 
43.9, 82.4, 57, 75.1, 41.9, 42.2, 48.7, 53.3, 42, 61, 70.9, 38, 
51.9, 39.3, 44.9, 69.7, 25.1, 49, 61.8, 58, 61.2, 41.1, 90.3, 
45.8, 36.4, 103.1, 52.4, 84.6, 63.5, 53.5, 101.1, 64.4, 50, 80.8, 
75.1, 47.5, 79.7, 44.9, 37, 29.1, 65.9, 49, 56.7, 61.4, 31.1, 
102.7, 64.8, 51.4, 80.7, 61.6, 36, 50.3, 42.4, 47, 41.9, 68.4, 
88.9, 56.2, 52.1, 50.1, 69.1, 55.1, 48.4, 34.1, 51, 77.9, 53.5, 
36.8, 48.2, 38.7), DN = structure(c(1L, 2L, 2L, 1L, 2L, 1L, 2L,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, 2L, 2L, 1L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 1L, 2L), .Label = c("H", "S"), class = "factor"), IDcat = structure(c(16L, 
19L, 68L, 58L, 35L, 21L, 21L, 83L, 48L, 64L, 73L, 63L, 80L, 63L, 
8L, 43L, 77L, 75L, 27L, 73L, 22L, 65L, 32L, 78L, 61L, 68L, 46L, 
30L, 44L, 78L, 58L, 72L, 27L, 46L, 41L, 52L, 36L, 38L, 67L, 18L, 
45L, 75L, 72L, 8L, 5L, 62L, 70L, 23L, 4L, 8L, 7L, 30L, 37L, 7L, 
68L, 20L, 80L, 44L, 39L, 6L, 83L, 26L, 66L, 21L, 5L, 39L, 10L, 
73L, 69L, 44L, 51L, 69L, 53L, 63L, 27L, 29L, 15L, 13L, 1L, 18L, 
31L, 9L, 42L, 32L, 78L, 62L, 23L, 3L, 29L, 49L, 81L, 60L, 70L, 
73L, 8L, 69L, 79L, 19L, 47L, 38L), .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", 
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", 
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", 
"49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", 
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", 
"71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", 
"82", "83"), class = "factor")), .Names = c("ID", "SD", "DIST", 
"CD", "DN", "Hunt", "Region", "IDcat"), row.names = c(16L, 172L, 
328L, 222L, 86L, 21L, 174L, 332L, 308L, 228L, 96L, 291L, 233L, 
259L, 161L, 271L, 202L, 98L, 180L, 45L, 22L, 293L, 185L, 203L, 
257L, 264L, 274L, 81L, 304L, 50L, 286L, 95L, 27L, 242L, 269L, 
280L, 138L, 191L, 295L, 171L, 241L, 149L, 146L, 110L, 107L, 258L, 
195L, 125L, 55L, 8L, 160L, 183L, 37L, 109L, 296L, 20L, 297L, 
208L, 192L, 6L, 236L, 179L, 294L, 72L, 5L, 141L, 10L, 198L, 143L, 
272L, 311L, 194L, 249L, 323L, 129L, 29L, 66L, 166L, 52L, 69L, 
133L, 162L, 270L, 134L, 152L, 322L, 23L, 156L, 182L, 277L, 330L, 
288L, 42L, 147L, 59L, 41L, 204L, 19L, 275L, 140L), class = "data.frame")

Glmm_full <- glmmML(SD~DIST*as.factor(Hunt)*as.factor(Region)*as.factor(DN),
        offset=log(CD),data=Sika.sample,family="poisson",cluster=IDcat)

    finalModel <-step(Glmm_full) #ERROR-MESSAGE

0 个答案:

没有答案