1. ホーム
  2. r

[解決済み】RでAIC中に行数が変化するのはなぜですか?そうならないようにするにはどうしたらいいですか?

2022-02-10 16:05:49

質問内容

RでAICを使って最小の適切なモデルを見つけようとしているのですが、以下のようなエラーが出続けます。 Error in step(model) : number of rows in use has changed: remove missing values?

私のデータです。

data<-structure(list(ID = c(1L, 2L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
25L, 27L, 28L, 29L, 30L, 31L, 33L, 34L, 35L, 37L, 38L, 39L, 40L, 
41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 
67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 
80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 
93L, 94L, 95L, 96L, 98L, 99L, 100L, 102L, 103L, 104L, 105L, 106L, 
107L, 108L, 109L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
119L, 120L, 121L, 122L, 123L), QnWeight_initial = c(158L, 165L, 
137L, 129L, 155L, 150L, 119L, 153L, 137L, 153L, 158L, 163L, 159L, 
151L, 145L, 144L, 157L, 154L, 144L, 133L, 148L, 151L, 151L, 147L, 
158L, 178L, 164L, 166L, 134L, 151L, 151L, 157L, 148L, 142L, 127L, 
179L, 162L, 142L, 150L, 151L, 153L, 163L, 155L, 163L, 170L, 159L, 
151L, 149L, 154L, 129L, 165L, 128L, 160L, 162L, 134L, 145L, 147L, 
148L, 160L, 165L, 131L, 155L, 169L, 143L, 123L, 153L, 151L, 152L, 
146L, 157L, 154L, 144L, 163L, 153L, 141L, 133L, 167L, 151L, 155L, 
142L, 164L, 158L, 141L, 179L, 146L, 149L, 164L, 156L, 153L, 132L, 
159L, 139L, 139L, 163L, 160L, 155L, 163L, 154L, 135L, 152L, 149L, 
143L, 140L, 160L, 150L, 143L, 160L, 159L, 144L, 169L, 152L, 146L, 
152L, 148L, 138L, 152L), QnWeight_initial_mg = c(15.8, 16.5, 
13.7, 12.9, 15.5, 15, 11.9, 15.3, 13.7, 15.3, 15.8, 16.3, 15.9, 
15.1, 14.5, 14.4, 15.7, 15.4, 14.4, 13.3, 14.8, 15.1, 15.1, 14.7, 
15.8, 17.8, 16.4, 16.6, 13.4, 15.1, 15.1, 15.7, 14.8, 14.2, 12.7, 
17.9, 16.2, 14.2, 15, 15.1, 15.3, 16.3, 15.5, 16.3, 17, 15.9, 
15.1, 14.9, 15.4, 12.9, 16.5, 12.8, 16, 16.2, 13.4, 14.5, 14.7, 
14.8, 16, 16.5, 13.1, 15.5, 16.9, 14.3, 12.3, 15.3, 15.1, 15.2, 
14.6, 15.7, 15.4, 14.4, 16.3, 15.3, 14.1, 13.3, 16.7, 15.1, 15.5, 
14.2, 16.4, 15.8, 14.1, 17.9, 14.6, 14.9, 16.4, 15.6, 15.3, 13.2, 
15.9, 13.9, 13.9, 16.3, 16, 15.5, 16.3, 15.4, 13.5, 15.2, 14.9, 
14.3, 14, 16, 15, 14.3, 16, 15.9, 14.4, 16.9, 15.2, 14.6, 15.2, 
14.8, 13.8, 15.2), QnIdentityConfused = 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, 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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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), .Label = " No", class = "factor"), Match_mated_status = structure(c(NA, 
NA, NA, NA, 1L, NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, NA, NA, 
1L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1L, NA, 1L, NA, 1L, NA, 
NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, NA, NA, 1L, 1L, NA, 1L, 
1L, NA, NA, 1L, 1L, NA, NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, 
1L, NA, NA, NA, NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, 
NA, NA, 1L, NA, NA, NA, NA, 1L, NA, NA, NA, NA, NA, NA, NA, 1L, 
NA, 1L, NA), .Label = " Yes", class = "factor"), Days_till_1st_Wrkr = c(NA, 
21L, NA, 26L, NA, 23L, 22L, 20L, 22L, NA, 20L, 21L, 20L, 20L, 
20L, 21L, NA, NA, 20L, 27L, 21L, 20L, 21L, 20L, 21L, 22L, 22L, 
NA, NA, NA, 22L, NA, 23L, 22L, 22L, NA, 20L, NA, 21L, NA, NA, 
20L, 20L, 20L, 20L, NA, NA, 23L, NA, NA, 23L, 23L, NA, NA, 21L, 
20L, 22L, NA, 21L, NA, 20L, 21L, 21L, 23L, 21L, NA, 22L, 20L, 
22L, 21L, 20L, 26L, 20L, NA, 20L, NA, 20L, 21L, 21L, 21L, 20L, 
21L, 21L, 21L, NA, 20L, 22L, 20L, NA, NA, 20L, NA, 20L, 20L, 
20L, 20L, 21L, 20L, NA, NA, 21L, 20L, 22L, 21L, NA, 22L, 21L, 
21L, 22L, 21L, 21L, NA, NA, 21L, NA, NA), Days_before_max_Wrkr_Eclosion = c(NA, 
12L, NA, 7L, NA, 10L, 11L, 13L, 11L, NA, 13L, 12L, 13L, 13L, 
13L, 12L, NA, NA, 13L, 6L, 12L, 13L, 12L, 13L, 12L, 11L, 11L, 
NA, NA, NA, 11L, NA, 10L, 11L, 11L, NA, 13L, NA, 12L, NA, NA, 
13L, 13L, 13L, 13L, NA, NA, 10L, NA, NA, 10L, 10L, NA, NA, 12L, 
13L, 11L, NA, 12L, NA, 13L, 12L, 12L, 10L, 12L, NA, 11L, 13L, 
11L, 12L, 13L, 7L, 13L, NA, 13L, NA, 13L, 12L, 12L, 12L, 13L, 
12L, 12L, 12L, NA, 13L, 11L, 13L, NA, NA, 13L, NA, 13L, 13L, 
13L, 13L, 12L, 13L, NA, NA, 12L, 13L, 11L, 12L, NA, 11L, 12L, 
12L, 11L, 12L, 12L, NA, NA, 12L, NA, NA), Wrkr_Eclosion_Bin = c(NA, 
3L, NA, 1L, NA, 1L, 2L, 3L, 2L, NA, 3L, 3L, 3L, 3L, 3L, 3L, NA, 
NA, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, NA, NA, NA, 2L, NA, 1L, 
2L, 2L, NA, 3L, NA, 3L, NA, NA, 3L, 3L, 3L, 3L, NA, NA, 1L, NA, 
NA, 1L, 1L, NA, NA, 3L, 3L, 2L, NA, 3L, NA, 3L, 3L, 3L, 1L, 3L, 
NA, 2L, 3L, 2L, 3L, 3L, 1L, 3L, NA, 3L, NA, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, NA, 3L, 2L, 3L, NA, NA, 3L, NA, 3L, 3L, 3L, 3L, 3L, 
3L, NA, NA, 3L, 3L, 2L, 3L, NA, 2L, 3L, 3L, 2L, 3L, 3L, NA, NA, 
3L, NA, NA), QnMass_At_Wrkr_Eclosion = c(NA, 83L, NA, 73L, NA, 
67L, 53L, 78L, 56L, NA, 73L, 90L, 81L, 69L, 66L, 73L, NA, NA, 
70L, 63L, 76L, 78L, 88L, 79L, 75L, 77L, 71L, NA, NA, NA, 86L, 
NA, 66L, 69L, 69L, NA, 88L, NA, 69L, NA, 93L, 71L, 82L, 70L, 
80L, NA, NA, 73L, NA, NA, 93L, 66L, NA, NA, 64L, 72L, 78L, NA, 
76L, NA, 60L, 87L, 89L, 62L, 62L, NA, 63L, 74L, 78L, 71L, 70L, 
118L, 76L, NA, 74L, NA, 96L, 108L, 77L, 68L, 79L, 70L, 67L, 85L, 
115L, 76L, 72L, 81L, 113L, NA, 89L, NA, 75L, 81L, 89L, 82L, 74L, 
81L, NA, NA, 74L, 73L, 80L, 84L, NA, 65L, 73L, 70L, 69L, 76L, 
74L, NA, NA, 80L, NA, NA), ColonyMass_At_Wrkr_Eclosion = c(NA, 
117L, NA, 53L, NA, 91L, 85L, 111L, 96L, NA, 112L, 90L, 112L, 
120L, 110L, 109L, NA, NA, 99L, 86L, 108L, 109L, 87L, 108L, 116L, 
137L, 108L, NA, NA, NA, 93L, NA, 96L, 98L, 87L, NA, 111L, NA, 
114L, NA, 11L, 123L, 113L, 130L, 134L, NA, NA, 96L, NA, NA, 15L, 
74L, NA, NA, 75L, 96L, 88L, NA, 122L, NA, 101L, 83L, 123L, 89L, 
85L, NA, 112L, 98L, 87L, 123L, 115L, 16L, 125L, NA, 91L, NA, 
85L, 76L, 122L, 95L, 113L, 116L, 102L, 132L, 11L, 105L, 112L, 
102L, 8L, NA, 113L, NA, 93L, 104L, 119L, 116L, 112L, 77L, NA, 
NA, 105L, 105L, 41L, 99L, NA, 113L, 120L, 130L, 98L, 122L, 118L, 
NA, NA, 97L, NA, NA), Adult_Wrkrs_At_Wrkr_Eclosion = c(NA, 9L, 
NA, 5L, NA, 1L, 7L, 3L, 2L, NA, 7L, 3L, 6L, 9L, 1L, 5L, NA, NA, 
2L, 1L, 5L, 4L, 6L, 6L, 4L, 5L, 1L, NA, NA, NA, 4L, NA, 3L, 3L, 
2L, NA, 4L, NA, 4L, NA, 0L, 5L, 4L, 3L, 14L, NA, NA, 1L, NA, 
NA, 2L, 1L, NA, NA, 3L, 7L, 2L, NA, 1L, NA, 3L, 7L, 1L, 1L, 5L, 
NA, 1L, 7L, 2L, 4L, 8L, 1L, 2L, NA, 6L, NA, 4L, 5L, 7L, 3L, 6L, 
7L, 5L, 13L, 0L, 4L, 6L, 2L, 0L, NA, 7L, NA, 6L, 1L, 3L, 7L, 
3L, 8L, NA, NA, 6L, 1L, 2L, 6L, NA, 2L, 4L, 4L, 4L, 3L, 7L, NA, 
NA, 5L, NA, NA), Mature_Brood_At_Wrkr_Eclosion = c(NA, 25L, NA, 
13L, NA, 17L, 18L, 27L, 28L, NA, 21L, 22L, 25L, 22L, 35L, 28L, 
NA, NA, 26L, 25L, 26L, 27L, 17L, 26L, 28L, 38L, 30L, NA, NA, 
NA, 22L, NA, 23L, 25L, 27L, NA, 26L, NA, 31L, NA, 2L, 26L, 22L, 
27L, 25L, NA, NA, 26L, NA, NA, 2L, 21L, NA, NA, 20L, 18L, 25L, 
NA, 35L, NA, 26L, 18L, 35L, 27L, 20L, NA, 31L, 22L, 17L, 30L, 
27L, 3L, 35L, NA, 21L, NA, 19L, 27L, 31L, 28L, 24L, 24L, 27L, 
28L, 6L, 27L, 29L, 28L, 1L, NA, 24L, NA, 18L, 31L, 31L, 23L, 
27L, 15L, NA, NA, 30L, 25L, 11L, 32L, NA, 29L, 34L, 36L, 26L, 
33L, 31L, NA, NA, 22L, NA, NA), Sum_wrkrsPlusBrood_At_Wrkr_Eclosion = c(0L, 
34L, 0L, 18L, 0L, 18L, 25L, 30L, 30L, 0L, 28L, 25L, 31L, 31L, 
36L, 33L, 0L, 0L, 28L, 26L, 31L, 31L, 23L, 32L, 32L, 43L, 31L, 
0L, 0L, 0L, 26L, 0L, 26L, 28L, 29L, 0L, 30L, 0L, 35L, 0L, 2L, 
31L, 26L, 30L, 39L, 0L, 0L, 27L, 0L, 0L, 4L, 22L, 0L, 0L, 23L, 
25L, 27L, 0L, 36L, 0L, 29L, 25L, 36L, 28L, 25L, 0L, 32L, 29L, 
19L, 34L, 35L, 4L, 37L, 0L, 27L, 0L, 23L, 32L, 38L, 31L, 30L, 
31L, 32L, 41L, 6L, 31L, 35L, 30L, 1L, 0L, 31L, 0L, 24L, 32L, 
34L, 30L, 30L, 23L, 0L, 0L, 36L, 26L, 13L, 38L, 0L, 31L, 38L, 
40L, 30L, 36L, 38L, 0L, 0L, 27L, 0L, 0L), QnMass_2wksLater = c(NA, 
124L, NA, NA, NA, 111L, NA, NA, NA, NA, NA, 98L, NA, NA, 107L, 
NA, NA, NA, 126L, NA, 115L, NA, NA, NA, 112L, 121L, NA, NA, NA, 
NA, 142L, NA, NA, 132L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 122L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 123L, 
NA, NA, NA, 89L, NA, NA, NA, 100L, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 123L, NA, NA, 112L, NA, 126L, 112L, 105L, NA, NA, 129L, 
NA, NA, NA, NA, NA, NA, NA, 134L, NA, NA, NA, NA, NA, NA, 95L, 
85L, NA, NA, 115L, NA, NA, 119L, 122L, NA, NA, NA, 124L, NA, 
NA), QnMass_4wksLater = c(NA, 117L, NA, NA, NA, 88L, NA, NA, 
NA, NA, NA, 111L, NA, NA, 97L, NA, NA, NA, 125L, NA, 119L, NA, 
NA, NA, 104L, 127L, NA, NA, NA, NA, 125L, NA, NA, 126L, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, 106L, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, 104L, NA, NA, NA, 95L, NA, NA, NA, 
94L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 113L, NA, NA, 120L, 
NA, 120L, 104L, 103L, NA, NA, 120L, NA, NA, NA, NA, NA, NA, NA, 
129L, NA, NA, NA, NA, NA, NA, 102L, 75L, NA, NA, 107L, NA, NA, 
137L, 99L, NA, NA, NA, 111L, NA, NA), ColonyMass_4wksLater = c(NA, 
571L, NA, NA, NA, 736L, NA, NA, NA, NA, NA, 438L, NA, NA, 711L, 
NA, NA, NA, 537L, NA, 844L, NA, NA, NA, 560L, 561L, NA, NA, NA, 
NA, 594L, NA, NA, 457L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 714L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 417L, 
NA, NA, NA, 701L, NA, NA, NA, 25L, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 866L, NA, NA, 291L, NA, 659L, 354L, 743L, NA, NA, 696L, 
NA, NA, NA, NA, NA, NA, NA, 518L, NA, NA, NA, NA, NA, NA, 907L, 
27L, NA, NA, 625L, NA, NA, 957L, 804L, NA, NA, NA, 650L, NA, 
NA), Adult_Wrkr_4wksLater = c(NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), QnMass_2mnthsLater = c(NA, 
118L, NA, NA, NA, 86L, NA, NA, NA, NA, NA, 93L, NA, NA, 98L, 
NA, NA, NA, 105L, NA, 101L, NA, NA, NA, 100L, 111L, NA, NA, NA, 
NA, NA, NA, NA, 100L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 99L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 106L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 103L, NA, NA, NA, NA, 114L, 103L, 99L, NA, NA, 86L, NA, 102L, 
NA, NA, NA, NA, NA, 125L, NA, NA, NA, NA, NA, NA, 70L, NA, NA, 
NA, 98L, NA, NA, 111L, 115L, NA, NA, NA, NA, NA, NA), ColonyMass_2mnthsLater = c(NA, 
445L, NA, NA, NA, 1817L, NA, NA, NA, NA, NA, 2683L, NA, NA, 1775L, 
NA, NA, NA, 429L, NA, 77L, NA, NA, NA, 279L, 23L, NA, NA, NA, 
NA, NA, NA, NA, 111L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 70L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 71L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 249L, NA, NA, NA, NA, 1249L, 636L, 710L, NA, NA, 27L, NA, 
50L, NA, NA, NA, NA, NA, 531L, NA, NA, NA, NA, NA, NA, 63L, NA, 
NA, NA, 416L, NA, NA, 400L, 902L, NA, NA, NA, NA, NA, NA), V1Nonconservative = 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, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, NA, 1L, 
1L, 1L, 1L, 2L, 1L, NA, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
NA, 1L, 1L), .Label = c("No", "Yes"), class = "factor"), V2Nonconservative = structure(c(2L, 
2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
1L, NA, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, NA, 1L, 
1L, 1L, 1L, 2L, 1L, NA, NA, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
1L, 2L, 1L, 1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
NA, 1L, 1L), .Label = c("No", "Yes"), class = "factor"), V3Nonconservative = 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, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, NA, 1L, 
1L, 1L, 2L, 1L, 1L, NA, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, NA, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
NA, 2L, 1L), .Label = c("No", "Yes"), class = "factor"), Gp9cntrlNonconservative = struct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 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, NA, 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, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, NA, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
NA, 1L, 1L), .Label = "Yes", class = "factor"), IR = c(0.1617747, 
0.2898704, 0.480131, 0.9517305, 0.7081732, 0.7203002, 0.9173295, 
0.5015458, 0.7489186, 0.4672413, 0.2329974, 0.1283224, 0.1037859, 
0.3372611, 0.0686602, 0.2223887, 0.4985669, 0.2526208, 0.2808523, 
0.3160422, 0.3585694, 0.2895266, 0.2573105, 0.3509661, 0.2708949, 
0.2781856, 0.5290147, 0.0879555, 0.2356172, 0.2086934, 0.3675043, 
0.1121473, 0.19609, 0.1658575, 0.320782, 0.150549, 0.0650061, 
0.4318525, 0.1926485, 0.2751303, 0.3924438, 0.6618555, 0.3558781, 
0.1552525, 0.2323201, 0.2106574, 0.1507224, 0.2987708, 0.7546178, 
NA, 0.3175084, 0.4063618, 0.3910241, 0.4099034, 0.2768228, 0.4121248, 
0.3127472, 0.2195151, 0.1534949, 0.6100645, 0.358541, 0.4791841, 
0.5261724, 0.6689824, 0.438704, 0.4832887, 0.312482, 0.6114833, 
0.4164931, 0.3158829, 0.3357824, 0.3177672, 0.1476469, 0.246839, 
0.2243354, 0.2173642, 0.3469673, 0.2809981, 0.4637596, 0.1582555, 
0.6860244, 0.3079741, 0.1891029, 0.3180592, 0.0475673, 0.2628201, 
NA, 0.2719091, 0.3845972, 0.1224785, 0.2148636, 0.2241886, 0.2652855, 
0.0942216, 0.3210833, 0.0900333, 0.0696456, 0.2735982, 0.3406816, 
0.121216, 0.0950757, 0.29159, -0.0305616, -0.0081555, 0.053223, 
0.0357914, 0.0624308, 0.4233811, 0.1393026, 0.0919119, 0.0961197, 
0.2592455, 0.1489129, 0.1683235, 0.2655108, 0.0996865), SH = c(1.10417, 
1.03056, 0.73612, 0.09815, 0.49074, 0.46621, 0.17176, 0.73612, 
0.39259, 0.73612, 0.98149, 1.10417, 1.17778, 0.88334, 1.20232, 
1.00602, 0.63797, 0.98149, 0.95695, 0.90788, 0.83426, 0.98149, 
0.98149, 0.8588, 0.95695, 1.00602, 0.61343, 1.15325, 0.98149, 
1.07964, 0.80973, 1.20232, 1.07964, 1.07964, 0.95695, 1.0551, 
1.20232, 0.68704, 1.07964, 1.00602, 0.80973, 0.58889, 0.8588, 
1.10417, 1.07964, 0.98149, 1.12871, 0.93241, 0.39259, NA, 0.93241, 
0.8588, 0.8588, 0.80973, 0.98149, 0.80973, 0.90788, 1.03056, 
1.07964, 0.56436, 0.8588, 0.76065, 0.61343, 0.53982, 0.83426, 
0.71158, 0.90788, 0.56436, 0.73612, 0.8588, 0.88334, 0.88334, 
1.12871, 0.95695, 1.00602, 1.07964, 0.8588, 0.95695, 0.68704, 
1.07964, 0.46621, 0.90788, 1.0551, 0.8588, 1.22686, 0.95695, 
NA, 0.95695, 0.83426, 1.17778, 1.03056, 0.95695, 0.95695, 1.22686, 
0.88334, 1.15325, 1.17778, 1.00602, 0.83426, 1.17778, 1.2514, 
0.90788, 1.32501, 1.30047, 1.15325, 1.17778, 1.22686, 0.78519, 
1.07964, 1.17778, 1.12871, 0.95695, 1.0551, 1.03056, 0.95695, 
1.20232), HL = c(0.5055, 0.5553, 0.6738, 0.9606, 0.7857, 0.7666, 
0.9168, 0.679, 0.83, 0.66, 0.5354, 0.5003, 0.4477, 0.6148, 0.4645, 
0.5503, 0.71, 0.5504, 0.5663, 0.5932, 0.6013, 0.5694, 0.5622, 
0.6101, 0.5733, 0.5316, 0.7292, 0.4692, 0.5511, 0.4926, 0.6117, 
0.4632, 0.5304, 0.5104, 0.5723, 0.5061, 0.4353, 0.6641, 0.4926, 
0.5631, 0.6045, 0.7498, 0.602, 0.5204, 0.5147, 0.5582, 0.4867, 
0.5749, 0.8145, NA, 0.5693, 0.6012, 0.6315, 0.6432, 0.564, 0.6508, 
0.6197, 0.5368, 0.5176, 0.7587, 0.6324, 0.6373, 0.6977, 0.781, 
0.6408, 0.6727, 0.6003, 0.7477, 0.6452, 0.6008, 0.5984, 0.5913, 
0.49, 0.5747, 0.5246, 0.5233, 0.6189, 0.5882, 0.6793, 0.4947, 
0.7958, 0.6017, 0.5217, 0.6193, 0.4501, 0.5587, NA, 0.5497, 0.6168, 
0.495, 0.5283, 0.5401, 0.5752, 0.4637, 0.5892, 0.4993, 0.4534, 
0.5648, 0.6284, 0.4803, 0.4474, 0.614, 0.4175, 0.4268, 0.4509, 
0.4406, 0.4229, 0.6455, 0.5069, 0.4591, 0.5014, 0.5696, 0.5155, 
0.5246, 0.5822, 0.4771)), .Names = c("ID", "QnWeight_initial", 
"QnWeight_initial_mg", "QnIdentityConfused", "Lost_queen_status", 
"Polygyne_status", "Match_mated_status", "Days_till_1st_Wrkr", 
"Days_before_max_Wrkr_Eclosion", "Wrkr_Eclosion_Bin", "QnMass_At_Wrkr_Eclosion", 
"ColonyMass_At_Wrkr_Eclosion", "Adult_Wrkrs_At_Wrkr_Eclosion", 
"Mature_Brood_At_Wrkr_Eclosion", "Sum_wrkrsPlusBrood_At_Wrkr_Eclosion", 
"QnMass_2wksLater", "QnMass_4wksLater", "ColonyMass_4wksLater", 
"Adult_Wrkr_4wksLater", "QnMass_2mnthsLater", "ColonyMass_2mnthsLater", 
"V1Nonconservative", "V2Nonconservative", "V3Nonconservative", 
"Gp9cntrlNonconservative", "V1", "V2", "V3", "Gp9cntrl", "IR", 
"SH", "HL"), class = "data.frame", row.names = c(NA, -116L))

私のコード

#NOTE: this will have to be adjusted to your particular directory
pipeline_dir='/Users/mf/Desktop/pipeline/'

response='QnWeight_initial'
predictors=c('HL','V1','V2')
predictor_filename='HL_V1_V2'


model <- lm(formula=as.formula(paste(paste(response,'~', sep=''),paste(predictors,collapse='+'), sep='')),data)
sink(file=paste(paste(pipeline_dir,'MAMs/', sep=''),paste(paste(paste(response, 'on', sep=''), predictor_filename, sep=''),'_fullModel.txt', sep='')))
print(summary(model))
sink()
sink(file=paste(paste(pipeline_dir,'MAMs/', sep=''),paste(paste(paste(response, 'on', sep=''), predictor_filename, sep=''),'.txt', sep='')))
step(model)
sink()

解決するには?

の「警告」セクションから {コード :

モデルフィッティングは、同じデータセットにモデルを適用する必要があります。これは、欠損値があり、Rのデフォルトであるna.action = na.omitが使用されている場合に問題となることがあります。まず、欠損値を削除することをお勧めします。

ということは、こうすればいいんですね。

?step