1

我正在使用 R (test.bic.surv) 中的 BMA 包从大量变量(100 个基本变量和每个变量大约 60 个滞后)中估计 Cox 比例模型。当我尝试使用以下代码进行第一组测试时,它可以工作。

x1<- x[,c(     "comprisk", "compriskL1", "compriskL2", "compriskL3", "compriskL4", "econrisk", "econrisk_1", "econrisk_2", "econrisk_3", "econrisk_4", "econrisk_5", "finrisk", "finrisk_1", "finrisk_2", "finrisk_3", "finrisk_4", "finrisk_5", "polrisk", "polrisk_1","polrisk_2","polrisk_3","polrisk_4","polrisk_5","polrisk_6","polrisk_7","polrisk_8","polrisk_9","polrisk_10","polrisk_11","polrisk_12")]

surv.t<- x$crisis1
cens<- x$cen1
test.bic.surv<- bic.surv(x1, surv.t, cens, factor.type=FALSE, strict=FALSE, nbest=2000)

但是,每当我尝试将更多自变量添加到 x1 中时,例如“comprisk5L”或“econriskL1”,

test.bic.surv<- bic.surv(x1, surv.t, cens, factor.type=FALSE, strict=FALSE, nbest=2000)

向我展示了这样的错误:

 "Error in terms.formula(formula, special, data = data) :    '.' in formula and no 'data' argument".

我在网上搜索了几天,但无法弄清楚问题出在哪里。谁能告诉我该怎么做??提前非常感谢你!!!:)

示例数据如下所示:

     crisis1 cen1 comprisk econrisk econrisk_1 econrisk_2 econrisk_3 econrisk_4
1         0    1     57.0     25.5        3.3        6.7        4.0        6.7
2         0    1     57.0     25.5        3.3        6.7        4.0        6.7
3         0    1     57.0     25.5        3.3        6.7        4.0        6.7
4         0    1     58.5     26.5        3.8        7.5        4.0        7.5
5         0    1     58.5     27.0        3.8        7.5        4.0        7.5
6         0    1     58.5     26.0        3.8        7.5        4.0        7.5
7         0    1     59.0     26.5        3.8        7.5        4.0        7.5
8         0    1     59.0     26.5        3.8        7.5        4.0        7.5
9         0    1     59.0     27.0        3.8        7.5        4.0        7.5
10        0    1     59.0     26.5        3.8        7.5        4.0        7.5
11        0    1     59.0     26.5        3.8        7.5        4.0        7.5
12        0    1     59.0     27.0        3.8        7.5        4.0        7.5
13        0    1     59.0     27.0        3.8        7.5        4.0        7.5
14        0    1     57.5     27.0        3.8        7.5        4.0        7.5
15        0    1     57.5     27.5        3.8        7.5        4.0        7.5
16        0    1     57.0     27.5        3.3        6.7        4.0        6.7
17        0    1     57.0     27.5        3.3        6.7        4.0        6.7
18        0    1     57.0     27.5        3.3        6.7        4.0        6.7
19        0    1     56.0     27.0        3.3        6.7        4.0        6.7
20        0    1     56.5     28.5        2.9        5.8        4.0        5.8
21        0    1     55.5     26.5        2.9        5.8        4.0        5.8
22        0    1     55.0     26.0        2.9        5.8        4.0        5.8
23        0    1     55.0     26.0        2.9        5.8        4.0        5.8
24        0    1     55.0     26.0        2.9        5.8        4.0        5.8
25        0    1     55.0     26.0        2.9        5.8        4.0        5.8
26        0    1     54.5     25.5        2.9        5.8        6.5        5.8
27        0    1     54.0     25.5        2.9        5.8        6.5        5.8
28        0    1     53.5     25.5        2.5        5.0        6.5        5.0
29        0    1     53.5     25.5        2.5        5.0        6.5        5.0
30        0    1     54.0     26.5        2.5        5.0        6.5        5.0
31        0    1     54.0     26.5        2.5        5.0        6.5        5.0
32        0    1     54.0     26.5        2.5        5.0        6.5        5.0
33        0    1     56.0     26.5        2.5        5.0        6.5        5.0
34        0    1     56.0     27.0        2.5        5.0        6.5        5.0
35        0    1     57.0     27.0        2.5        5.0        6.5        5.0
36        0    1     58.0     27.0        2.9        5.8        6.5        5.8
37        1    1     59.0     28.5        2.9        5.8        6.5        5.8
38        1    1     60.0     29.5        2.9        5.8        6.5        5.8
39        1    1     59.5     29.5        2.9        5.8        6.5        5.8
40        1    1     60.0     29.5        2.9        5.8        6.5        5.8
41        1    1     59.5     29.5        2.9        5.8        6.5        5.8
42        1    1     59.0     28.0        2.9        5.8        6.5        5.8
43        1    1     59.5     28.0        2.9        5.8        6.5        5.8
44        1    1     59.5     28.0        2.9        5.8        6.5        5.8
45        1    1     59.5     28.5        2.9        5.8        6.5        5.8
46        1    1     56.0     28.0        2.9        5.8        6.5        5.8
47        1    1     54.0     28.0        2.5        5.0        6.5        5.0
48        1    1     53.0     24.5        2.1        4.2        6.5        4.2
49        1    1     53.0     25.0        2.1        4.2        6.5        4.2
50        1    1     54.0     26.0        2.1        4.2        6.5        4.2
51        1    1     54.5     26.0        2.1        4.2        6.5        4.2
52        1    1     54.5     25.5        2.1        4.2        6.5        4.2
53        1    1     54.0     24.0        2.1        4.2        6.0        4.2
54        1    1     54.0     24.0        2.1        4.2        6.0        4.2
55        1    1     55.0     24.0        2.1        4.2        6.0        4.2
56        1    1     55.0     24.0        2.1        4.2        6.0        4.2
57        1    1     55.0     24.0        2.1        4.2        6.0        4.2
58        1    1     55.0     24.5        2.1        4.2        6.0        4.2
59        1    1     55.0     24.5        2.1        4.2        6.0        4.2
60        1    1     55.0     25.0        2.1        4.2        6.0        4.2
61        1    1     55.0     23.5        2.1        4.2        6.0        4.2
62        1    1     55.0     24.0        2.1        4.2        6.0        4.2
63        1    1     55.0     23.5        2.1        4.2        6.5        4.2
64        1    1     55.0     23.5        1.7        3.3        6.5        3.3
65        1    1     55.0     22.5        1.7        3.3        6.5        3.3
66        1    1     56.0     25.5        1.3        2.5        6.5        2.5
67        1    1     56.0     25.5        1.3        2.5        6.5        2.5
68        1    1     56.5     25.0        1.3        2.5        6.5        2.5
69        1    1     58.5     29.5        1.3        2.5        6.5        2.5
70        1    1     58.5     28.5        1.3        2.5        6.5        2.5
71        1    1     58.5     28.5        1.3        2.5        6.5        2.5
72        1    1     59.5     29.5        1.3        2.5        6.5        2.5
73        1    1     61.5     33.0        1.3        2.5        6.0        2.5
74        1    1     61.0     33.0        1.3        2.5        6.0        2.5
75        1    1     61.5     32.0        1.7        3.3        6.0        3.3
76        1    1     59.5     32.0        1.7        3.3        6.0        3.3
77        1    1     60.0     32.5        1.7        3.3        6.0        3.3
78        1    1     57.5     32.5        2.1        4.2        6.0        4.2
79        1    1     58.0     33.0        2.1        4.2        6.0        4.2
80        1    1     58.5     32.5        2.1        4.2        6.0        4.2
81        1    1     57.5     31.5        2.1        4.2        5.0        4.2
82        1    1     57.5     31.5        2.1        4.2        5.0        4.2
83        1    1     59.0     31.5        2.5        5.0        5.0        5.0
84        1    1     58.5     30.5        2.5        5.0        4.0        5.0
85        0    1     55.5     27.5        2.5        5.0        3.5        5.0
86        0    1     54.0     27.5        2.5        5.0        3.5        5.0
87        0    1     53.5     27.0        2.5        5.0        3.5        5.0
88        0    1     53.0     27.0        2.5        5.0        3.5        5.0
89        0    1     53.0     27.5        2.1        4.2        3.5        4.2
90        0    1     52.5     27.0        2.1        4.2        3.5        4.2
91        0    1     50.5     27.5        2.1        4.2        3.5        4.2
92        0    1     51.5     27.5        2.1        4.2        3.5        4.2
93        0    1     51.5     27.0        2.5        5.0        3.5        5.0
94        0    1     52.0     27.0        2.5        5.0        3.5        5.0
95        0    1     52.0     27.0        2.5        5.0        3.5        5.0
96        0    1     52.0     28.0        2.5        5.0        3.5        5.0
97        0    1     52.5     28.5        2.5        5.0        3.5        5.0
98        0    1     54.0     28.5        2.5        5.0        3.5        5.0
99        0    1     54.0     29.0        2.5        5.0        4.0        5.0
100       0    1     53.0     28.0        2.5        5.0        4.0        5.0
101       0    1     52.5     28.0        2.1        4.2        3.5        4.2
102       0    1     52.5     28.0        2.1        4.2        3.5        4.2
103       0    1     53.0     28.0        2.1        4.2        3.5        4.2
104       0    1     53.0     28.0        2.1        4.2        3.5        4.2
105       0    1     52.5     26.0        2.1        4.2        4.0        4.2
106       0    1     54.0     26.5        2.1        4.2        4.0        4.2
107       0    1     53.5     26.5        2.1        4.2        4.0        4.2
108       0    1     53.5     26.5        2.1        4.2        4.0        4.2
109       1    1     56.0     29.5        2.1        4.2        5.0        4.2
110       1    1     53.5     27.0        2.1        4.2        4.0        4.2
111       1    1     53.5     27.0        2.1        4.2        4.0        4.2
112       1    1     53.5     26.5        2.1        4.2        5.0        4.2
113       1    1     54.0     26.5        2.1        4.2        5.0        4.2
114       1    1     52.5     24.0        2.1        4.2        4.0        4.2
115       1    1     53.0     24.5        2.1        4.2        5.0        4.2
116       1    1     54.0     26.0        2.1        4.2        4.0        4.2
117       1    1     54.0     26.0        2.1        4.2        4.0        4.2
118       1    1     54.5     26.0        2.1        4.2        4.0        4.2
119       1    1     52.5     24.5        2.1        4.2        3.5        4.2
120       1    1     52.5     24.5        2.1        4.2        3.5        4.2
121       1    1     54.0     27.5        2.1        4.2        4.0        4.2
122       1    1     54.0     27.5        2.1        4.2        4.0        4.2
123       1    1     53.0     28.5        2.1        4.2        4.0        4.2
124       1    1     53.0     28.5        2.1        4.2        4.0        4.2
125       1    1     52.5     28.0        2.1        4.2        4.0        4.2
126       1    1     52.5     27.5        2.1        4.2        4.0        4.2
127       1    1     53.0     28.0        2.1        4.2        4.5        4.2
128       1    1     53.5     28.0        2.5        5.0        4.5        5.0
129       1    1     54.5     28.0        2.5        5.0        4.5        5.0
130       1    1     54.0     26.5        2.5        5.0        3.5        5.0
131       1    1     53.5     26.0        2.5        5.0        3.5        5.0
132       1    1     54.5     26.5        2.5        5.0        3.5        5.0
133       0    1     55.5     28.0        2.5        5.0        3.5        5.0
134       0    1     56.0     28.0        2.5        5.0        3.5        5.0
135       0    1     56.0     28.0        2.5        5.0        3.5        5.0
136       0    1     54.5     27.5        2.5        5.8        3.5        5.8
137       0    1     56.0     24.5        2.9        5.8        5.0        5.8
138       0    1     58.5     29.0        2.9        5.8        5.0        5.8
139       0    1     57.5     28.5        2.9        5.8        5.0        5.8
140       0    1     57.0     28.5        2.9        5.8        5.0        5.8
141       0    1     57.0     28.5        2.9        5.8        5.0        5.8
142       0    1     58.0     28.5        2.9        5.8        5.0        5.8
143       0    1     58.0     29.5        2.9        5.8        5.0        5.8
144       0    1     59.0     29.5        2.9        5.8        5.0        5.8
145       0    1     59.0     31.0        2.9        5.8        5.5        5.8
146       0    1     59.0     31.0        2.9        5.8        5.5        5.8
147       0    1     58.5     31.0        2.9        5.8        5.5        5.8
148       0    1     58.5     31.0        2.9        5.8        5.5        5.8
149       0    1     58.5     32.0        2.5        5.0        5.5        5.0
150       0    1     58.0     32.0        2.5        5.0        5.5        5.0
151       0    1     56.8     32.5        2.5        5.0        5.5        5.0
152       0    1     58.3     31.5        3.8        7.5        5.5        7.5
153       0    1     59.0     37.0        0.5        8.5        5.5        9.5
154       0    1     59.2     37.5        1.0        8.5        5.5        9.5
155       0    1     61.0     39.5        0.5        9.0        8.0        9.0
156       0    1     60.5     39.5        0.5        9.0        8.0        9.0
157       0    1     60.0     39.5        0.5        9.0        8.0        9.0
158       0    1     59.2     39.0        0.5        8.5        8.0        9.0
159       0    1     59.5     39.5        0.5        8.5        8.5        9.0
160       0    1     59.5     39.5        0.5        8.5        8.5        9.0
161       0    1     59.5     39.5        0.5        8.5        8.5        9.0
162       0    1     59.2     39.0        0.5        8.0        8.5        9.0
163       0    1     58.7     39.0        0.5        8.0        8.5        9.0
164       0    1     58.5     38.5        0.5        7.5        8.5        9.0
165       0    1     58.0     35.0        1.0        4.0        8.5        8.0
166       0    1     57.0     35.0        1.0        4.0        8.5        8.0
167       0    1     56.2     33.5        0.5        4.0        7.5        8.0
168       0    1     56.5     34.0        1.0        4.0        7.5        8.0
169       0    1     54.7     33.5        1.0        8.5        7.5        6.0
170       0    1     52.7     30.5        1.0        6.0        7.5        6.0
171       0    1     52.7     30.5        1.0        6.0        7.5        6.0
172       0    1     54.0     33.0        1.0        8.5        7.5        6.0
173       0    1     52.1     32.7        0.2        8.5        8.0        6.0
174       0    1     50.8     32.2        0.2        8.0        8.0        6.0
175       0    1     52.1     32.2        0.2        8.0        8.0        6.0
176       0    1     51.9     32.2        0.2        8.0        8.0        6.0
177       0    1     51.7     31.5        1.0        7.0        7.5        6.0
178       0    1     51.5     31.5        1.0        7.0        7.5        6.0
179       0    1     52.7     31.5        1.0        7.0        7.5        6.0
180       0    1     52.5     31.5        1.0        7.0        7.5        6.0
181       0    1     54.5     33.5        1.0        8.5        8.5        3.5
182       0    1     55.5     33.5        1.0        8.5        8.5        3.5
183       0    1     56.7     35.0        1.0        9.0        8.5        3.5
184       0    1     56.2     35.0        1.0        9.0        8.5        3.5
185       0    1     55.5     35.0        1.0        9.0        8.5        3.5
186       0    1     56.2     35.0        1.0        9.0        8.5        3.5
187       0    1     56.7     35.0        1.0        9.0        8.5        3.5
188       0    1     56.0     34.0        1.0        9.0        7.5        3.5
189       0    1     55.0     34.0        1.0        9.0        7.5        3.5
190       0    1     55.5     34.0        1.0        9.0        7.5        3.5
191       0    1     55.2     34.0        1.0        9.0        7.5        3.5
192       0    1     59.0     37.0        1.0        9.0        8.5        3.5
193       0    1     62.2     42.0        1.0        9.5        8.0        8.5
194       0    1     61.8     42.0        1.0        9.5        8.0        8.5
195       0    1     60.2     41.0        1.0        9.5        8.0        8.5
196       0    1     63.7     41.0        1.0        9.5        8.0        8.5
197       0    1     60.2     37.0        1.0        8.5        8.0        8.5
198       0    1     64.2     42.0        1.0        9.5        9.0        8.5
199       0    1     63.0     40.0        1.0        8.5        8.0        8.5
200       0    1     61.5     38.5        1.0        8.5        8.0        8.5
201       0    1     61.7     38.5        1.0        8.5        8.0        8.5
202       0    1     62.0     38.5        1.0        8.5        8.0        8.5
203       0    1     62.0     38.5        1.0        8.5        8.0        8.5
204       0    1     62.2     38.5        1.0        8.5        8.0        8.5
205       0    1     61.5     38.5        1.0        8.5        8.0        8.5
206       0    1     61.2     38.0        1.0        8.5        8.0        8.5
207       0    1     60.5     38.0        1.0        8.5        8.0        8.5
208       0    1     61.0     38.0        1.0        8.5        8.0        8.5
209       0    1     61.5     38.0        1.0        8.5        8.0        8.5
210       0    1     61.7     38.0        1.0        8.5        8.0        8.5
211       0    1     62.0     38.0        1.0        8.5        8.0        8.5
212       0    1     61.7     38.0        1.0        8.5        8.0        8.5
213       0    1     61.5     38.0        1.0        8.5        8.0        8.5
214       0    1     61.2     38.0        1.0        8.5        8.0        8.5
215       0    1     63.7     40.5        1.0        8.0        9.0        8.5
216       0    1     63.7     40.5        1.0        8.0        9.0        8.5
217       0    1     63.7     40.5        1.0        8.0        9.0        8.5
218       0    1     65.7     43.5        1.0        9.5        8.5        9.5
219       0    1     65.5     43.5        1.0        9.5        8.5        9.5
220       0    1     65.5     43.5        1.0        9.5        8.5        9.5
221       0    1     65.0     43.5        1.0        9.5        8.5        9.5
222       0    1     65.0     43.5        1.0        9.5        8.5        9.5
223       0    1     65.0     43.5        1.0        9.5        8.5        9.5
224       0    1     66.2     43.5        1.0       10.0        9.5        8.0
225       0    1     66.2     43.5        1.0       10.0        9.5        8.0
226       0    1     66.2     43.5        1.0       10.0        9.5        8.0
227       0    1     66.0     44.0        1.0       10.0        9.5        8.5
228       0    1     65.7     44.0        1.0       10.0        9.5        8.5
229       0    1     65.5     43.5        1.0        9.5        9.5        8.5
230       0    1     65.5     43.0        1.0       10.0        9.0        8.5
231       0    1     65.5     43.0        1.0       10.0        9.0        8.5
232       0    1     68.2     43.0        1.0       10.0        9.0        8.5
233       0    1     71.5     44.5        1.0       10.0        9.0        9.5
234       0    1     71.7     44.5        1.0       10.0        9.0        9.5
235       0    1     73.2     44.5        1.0       10.0        9.0        9.5
236       0    1     74.7     44.5        1.0       10.0        9.0        9.5
237       0    1     74.7     44.5        1.0       10.0        9.0        9.5
238       0    1     74.7     44.5        1.0       10.0        9.0        9.5
239       0    1     75.5     45.0        1.0       10.0        9.0       10.0
240       0    1     75.5     45.0        1.0       10.0        9.0       10.0
241       0    1     76.0     45.0        1.0       10.0        9.0       10.0
242       0    1     76.7     44.5        1.0       10.0        8.5       10.0
243       0    1     76.7     44.5        1.0       10.0        8.5       10.0
244       0    1     76.7     44.5        1.0       10.0        8.5       10.0
245       0    1     78.0     44.5        1.0       10.0        8.5       10.0
246       0    1     78.0     44.5        1.0       10.0        8.5       10.0
247       0    1     77.0     44.5        1.0       10.0        8.5       10.0
248       0    1     77.2     44.5        1.0       10.0        8.5       10.0
249       0    1     77.2     44.5        1.0       10.0        8.5       10.0
250       0    1     77.7     44.5        1.0       10.0        8.5       10.0
4

1 回答 1

1

这是你的答案:

test.bic.surv <- bic.surv(
    x[, 3:ncol(x)],
    x$crisis1, x$cen1, factor.type=FALSE, strict=FALSE, nbest=2000, maxCol=50
)

您必须提供 maxCol 参数。默认值为 30,因此可能不足以满足您的需求。

于 2013-09-08T18:49:41.220 回答