1
2R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
3Copyright (C) 2020 The R Foundation for Statistical Computing
4Platform: x86_64-w64-mingw32/x64 (64-bit)
5
6R is free software and comes with ABSOLUTELY NO WARRANTY.
7You are welcome to redistribute it under certain conditions.
8Type 'license()' or 'licence()' for distribution details.
9
10R is a collaborative project with many contributors.
11Type 'contributors()' for more information and
12'citation()' on how to cite R or R packages in publications.
13
14Type 'demo()' for some demos, 'help()' for on-line help, or
15'help.start()' for an HTML browser interface to help.
16Type 'q()' to quit R.
17
18> #### Testfile to see the attr(vcov, which="cluster") for various vcovXX methods
19> #
20> # see also testfile tests/test_pwaldtest.R for general tests of the F test and Chisq test
21>
22> options(scipen = 999)
23> options(digits = 8)
24> library(plm)
25> data("Grunfeld", package="plm")
26> gp <- plm(inv ~ value + capital, data = Grunfeld, model = "pooling")
27> gi <- plm(inv ~ value + capital, data = Grunfeld,
28+           effect = "individual", model = "within")
29> gt <- plm(inv ~ value + capital, data = Grunfeld,
30+           effect = "time", model = "within")
31> gd <- plm(inv ~ value + capital, data = Grunfeld,
32+           effect = "twoways", model = "within")
33>
34> # vcovHC
35> print(attr(vcovHC(gi), which="cluster"))                     # group - default
36[1] "group"
37> print(attr(vcovHC(gi, cluster="group"), which="cluster"))    # group
38[1] "group"
39> print(attr(vcovHC(gi, cluster="time"), which="cluster"))     # time
40[1] "time"
41>
42> # vcovBK
43> print(attr(vcovBK(gi), which="cluster"))                    # group - default
44[1] "group"
45> print(attr(vcovBK(gi, cluster="group"), which="cluster"))   # group
46[1] "group"
47> print(attr(vcovBK(gi, cluster="time"), which="cluster"))    # time
48[1] "time"
49>
50> # vcovSCC
51> print(attr(vcovSCC(gi), which="cluster"))                    # time - default and should be the only option for SCC
52[1] "time"
53> print(attr(vcovSCC(gi, cluster="group"), which="cluster"))   # group
54[1] "group"
55> print(attr(vcovSCC(gi, cluster="time"), which="cluster"))    # time
56[1] "time"
57>
58> # vcovNW
59> print(attr(vcovNW(gi), which="cluster"))                    # time - default and should be the only option for NW
60[1] "time"
61> print(attr(vcovNW(gi, cluster="group"), which="cluster"))   # group
62[1] "group"
63> print(attr(vcovNW(gi, cluster="time"), which="cluster"))    # time
64[1] "time"
65>
66> # vcovDC
67> print(attr(vcovDC(gi), which="cluster"))                    # group-time - nothing else possible
68[1] "group-time"
69>
70>
71> # pooling model F test - robust - function
72> plm::pwaldtest(gp, test = "F", vcov = vcovHC)
73
74	F test for joint significance (robust), vcov: vcovHC
75
76data:  inv ~ value + capital
77F = 57.9049, df1 = 2, df2 = 9, p-value = 0.0000072606
78alternative hypothesis: at least one coefficient is not null
79
80> plm::pwaldtest(gp, test = "F", vcov = vcovBK)
81
82	F test for joint significance (robust), vcov: vcovBK
83
84data:  inv ~ value + capital
85F = 32.9422, df1 = 2, df2 = 9, p-value = 0.000072332
86alternative hypothesis: at least one coefficient is not null
87
88> plm::pwaldtest(gp, test = "F", vcov = vcovSCC)
89
90	F test for joint significance (robust), vcov: vcovSCC
91
92data:  inv ~ value + capital
93F = 105.718, df1 = 2, df2 = 19, p-value = 0.000000000050573
94alternative hypothesis: at least one coefficient is not null
95
96> plm::pwaldtest(gp, test = "F", vcov = vcovNW)
97
98	F test for joint significance (robust), vcov: vcovNW
99
100data:  inv ~ value + capital
101F = 92.1225, df1 = 2, df2 = 19, p-value = 0.00000000016671
102alternative hypothesis: at least one coefficient is not null
103
104> plm::pwaldtest(gp, test = "F", vcov = vcovDC) # no finite-sample adj. for df2 done, because not yet clear how to handle "group-time" clustering
105
106	F test for joint significance (robust), vcov: vcovDC
107
108data:  inv ~ value + capital
109F = 65.0889, df1 = 2, df2 = 197, p-value < 0.000000000000000222
110alternative hypothesis: at least one coefficient is not null
111
112>
113> # within model individual F test - robust - function
114> plm::pwaldtest(gi, test = "F", vcov = vcovHC)
115
116	F test for joint significance (robust), vcov: vcovHC
117
118data:  inv ~ value + capital
119F = 31.7744, df1 = 2, df2 = 9, p-value = 0.000083417
120alternative hypothesis: at least one coefficient is not null
121
122> plm::pwaldtest(gi, test = "F", vcov = vcovBK)
123
124	F test for joint significance (robust), vcov: vcovBK
125
126data:  inv ~ value + capital
127F = 64.3086, df1 = 2, df2 = 9, p-value = 0.000004678
128alternative hypothesis: at least one coefficient is not null
129
130> plm::pwaldtest(gi, test = "F", vcov = vcovSCC)
131
132	F test for joint significance (robust), vcov: vcovSCC
133
134data:  inv ~ value + capital
135F = 75.9419, df1 = 2, df2 = 19, p-value = 0.00000000086597
136alternative hypothesis: at least one coefficient is not null
137
138> plm::pwaldtest(gi, test = "F", vcov = vcovNW)
139
140	F test for joint significance (robust), vcov: vcovNW
141
142data:  inv ~ value + capital
143F = 29.0557, df1 = 2, df2 = 19, p-value = 0.0000016616
144alternative hypothesis: at least one coefficient is not null
145
146> plm::pwaldtest(gi, test = "F", vcov = vcovDC) # no finite-sample adj. for df2 done, because not yet clear how to handle "group-time" clustering
147
148	F test for joint significance (robust), vcov: vcovDC
149
150data:  inv ~ value + capital
151F = 55.4686, df1 = 2, df2 = 188, p-value < 0.000000000000000222
152alternative hypothesis: at least one coefficient is not null
153
154>
155> # within model time F test - robust - function
156> plm::pwaldtest(gt, test = "F", vcov = vcovHC)
157
158	F test for joint significance (robust), vcov: vcovHC
159
160data:  inv ~ value + capital
161F = 62.1078, df1 = 2, df2 = 9, p-value = 0.0000054149
162alternative hypothesis: at least one coefficient is not null
163
164> plm::pwaldtest(gt, test = "F", vcov = vcovBK)
165
166	F test for joint significance (robust), vcov: vcovBK
167
168data:  inv ~ value + capital
169F = 28.7897, df1 = 2, df2 = 9, p-value = 0.00012276
170alternative hypothesis: at least one coefficient is not null
171
172> plm::pwaldtest(gt, test = "F", vcov = vcovSCC)
173
174	F test for joint significance (robust), vcov: vcovSCC
175
176data:  inv ~ value + capital
177F = 89.0247, df1 = 2, df2 = 19, p-value = 0.00000000022372
178alternative hypothesis: at least one coefficient is not null
179
180> plm::pwaldtest(gt, test = "F", vcov = vcovNW)
181
182	F test for joint significance (robust), vcov: vcovNW
183
184data:  inv ~ value + capital
185F = 103.116, df1 = 2, df2 = 19, p-value = 0.000000000062831
186alternative hypothesis: at least one coefficient is not null
187
188> plm::pwaldtest(gt, test = "F", vcov = vcovDC) # no finite-sample adj. for df2 done, because not yet clear how to handle "group-time" clustering
189
190	F test for joint significance (robust), vcov: vcovDC
191
192data:  inv ~ value + capital
193F = 64.2897, df1 = 2, df2 = 178, p-value < 0.000000000000000222
194alternative hypothesis: at least one coefficient is not null
195
196>
197> # within model twoways F test - robust - function
198> plm::pwaldtest(gd, test = "F", vcov = vcovHC)
199
200	F test for joint significance (robust), vcov: vcovHC
201
202data:  inv ~ value + capital
203F = 74.6338, df1 = 2, df2 = 9, p-value = 0.0000024936
204alternative hypothesis: at least one coefficient is not null
205
206> plm::pwaldtest(gd, test = "F", vcov = vcovBK)
207
208	F test for joint significance (robust), vcov: vcovBK
209
210data:  inv ~ value + capital
211F = 58.0144, df1 = 2, df2 = 9, p-value = 0.0000072035
212alternative hypothesis: at least one coefficient is not null
213
214> plm::pwaldtest(gd, test = "F", vcov = vcovSCC)
215
216	F test for joint significance (robust), vcov: vcovSCC
217
218data:  inv ~ value + capital
219F = 46.9641, df1 = 2, df2 = 19, p-value = 0.000000044313
220alternative hypothesis: at least one coefficient is not null
221
222> plm::pwaldtest(gd, test = "F", vcov = vcovNW)
223
224	F test for joint significance (robust), vcov: vcovNW
225
226data:  inv ~ value + capital
227F = 33.8818, df1 = 2, df2 = 19, p-value = 0.00000054194
228alternative hypothesis: at least one coefficient is not null
229
230> plm::pwaldtest(gd, test = "F", vcov = vcovDC) # no finite-sample adj. for df2 done, because not yet clear how to handle "group-time" clustering
231
232	F test for joint significance (robust), vcov: vcovDC
233
234data:  inv ~ value + capital
235F = 104.851, df1 = 2, df2 = 169, p-value < 0.000000000000000222
236alternative hypothesis: at least one coefficient is not null
237
238>
239> # pooling model Chisq - robust - function
240> plm::pwaldtest(gp, test = "Chisq", vcov = vcovHC)
241
242	Wald test for joint significance (robust), vcov: vcovHC
243
244data:  inv ~ value + capital
245Chisq = 115.81, df = 2, p-value < 0.000000000000000222
246alternative hypothesis: at least one coefficient is not null
247
248> plm::pwaldtest(gp, test = "Chisq", vcov = vcovBK)
249
250	Wald test for joint significance (robust), vcov: vcovBK
251
252data:  inv ~ value + capital
253Chisq = 65.8844, df = 2, p-value = 0.0000000000000049361
254alternative hypothesis: at least one coefficient is not null
255
256> plm::pwaldtest(gp, test = "Chisq", vcov = vcovSCC)
257
258	Wald test for joint significance (robust), vcov: vcovSCC
259
260data:  inv ~ value + capital
261Chisq = 211.437, df = 2, p-value < 0.000000000000000222
262alternative hypothesis: at least one coefficient is not null
263
264> plm::pwaldtest(gp, test = "Chisq", vcov = vcovNW)
265
266	Wald test for joint significance (robust), vcov: vcovNW
267
268data:  inv ~ value + capital
269Chisq = 184.245, df = 2, p-value < 0.000000000000000222
270alternative hypothesis: at least one coefficient is not null
271
272> plm::pwaldtest(gp, test = "Chisq", vcov = vcovDC) # finite-sample adj. for df2 irrelevant b/c Chisq test
273
274	Wald test for joint significance (robust), vcov: vcovDC
275
276data:  inv ~ value + capital
277Chisq = 130.178, df = 2, p-value < 0.000000000000000222
278alternative hypothesis: at least one coefficient is not null
279
280>
281> # within model individual Chisq - robust - function
282> plm::pwaldtest(gi, test = "Chisq", vcov = vcovHC)
283
284	Wald test for joint significance (robust), vcov: vcovHC
285
286data:  inv ~ value + capital
287Chisq = 63.5489, df = 2, p-value = 0.000000000000015869
288alternative hypothesis: at least one coefficient is not null
289
290> plm::pwaldtest(gi, test = "Chisq", vcov = vcovBK)
291
292	Wald test for joint significance (robust), vcov: vcovBK
293
294data:  inv ~ value + capital
295Chisq = 128.617, df = 2, p-value < 0.000000000000000222
296alternative hypothesis: at least one coefficient is not null
297
298> plm::pwaldtest(gi, test = "Chisq", vcov = vcovSCC)
299
300	Wald test for joint significance (robust), vcov: vcovSCC
301
302data:  inv ~ value + capital
303Chisq = 151.884, df = 2, p-value < 0.000000000000000222
304alternative hypothesis: at least one coefficient is not null
305
306> plm::pwaldtest(gi, test = "Chisq", vcov = vcovNW)
307
308	Wald test for joint significance (robust), vcov: vcovNW
309
310data:  inv ~ value + capital
311Chisq = 58.1114, df = 2, p-value = 0.00000000000024058
312alternative hypothesis: at least one coefficient is not null
313
314> plm::pwaldtest(gi, test = "Chisq", vcov = vcovDC) # finite-sample adj. for df2 irrelevant b/c Chisq test
315
316	Wald test for joint significance (robust), vcov: vcovDC
317
318data:  inv ~ value + capital
319Chisq = 110.937, df = 2, p-value < 0.000000000000000222
320alternative hypothesis: at least one coefficient is not null
321
322>
323> # within model time Chisq - robust - function
324> plm::pwaldtest(gt, test = "Chisq", vcov = vcovHC)
325
326	Wald test for joint significance (robust), vcov: vcovHC
327
328data:  inv ~ value + capital
329Chisq = 124.216, df = 2, p-value < 0.000000000000000222
330alternative hypothesis: at least one coefficient is not null
331
332> plm::pwaldtest(gt, test = "Chisq", vcov = vcovBK)
333
334	Wald test for joint significance (robust), vcov: vcovBK
335
336data:  inv ~ value + capital
337Chisq = 57.5795, df = 2, p-value = 0.00000000000031389
338alternative hypothesis: at least one coefficient is not null
339
340> plm::pwaldtest(gt, test = "Chisq", vcov = vcovSCC)
341
342	Wald test for joint significance (robust), vcov: vcovSCC
343
344data:  inv ~ value + capital
345Chisq = 178.049, df = 2, p-value < 0.000000000000000222
346alternative hypothesis: at least one coefficient is not null
347
348> plm::pwaldtest(gt, test = "Chisq", vcov = vcovNW)
349
350	Wald test for joint significance (robust), vcov: vcovNW
351
352data:  inv ~ value + capital
353Chisq = 206.232, df = 2, p-value < 0.000000000000000222
354alternative hypothesis: at least one coefficient is not null
355
356> plm::pwaldtest(gt, test = "Chisq", vcov = vcovDC) # finite-sample adj. for df2 irrelevant b/c Chisq test
357
358	Wald test for joint significance (robust), vcov: vcovDC
359
360data:  inv ~ value + capital
361Chisq = 128.579, df = 2, p-value < 0.000000000000000222
362alternative hypothesis: at least one coefficient is not null
363
364>
365> # within model twoways Chisq - robust - function
366> plm::pwaldtest(gd, test = "Chisq", vcov = vcovHC)
367
368	Wald test for joint significance (robust), vcov: vcovHC
369
370data:  inv ~ value + capital
371Chisq = 149.268, df = 2, p-value < 0.000000000000000222
372alternative hypothesis: at least one coefficient is not null
373
374> plm::pwaldtest(gd, test = "Chisq", vcov = vcovBK)
375
376	Wald test for joint significance (robust), vcov: vcovBK
377
378data:  inv ~ value + capital
379Chisq = 116.029, df = 2, p-value < 0.000000000000000222
380alternative hypothesis: at least one coefficient is not null
381
382> plm::pwaldtest(gd, test = "Chisq", vcov = vcovSCC)
383
384	Wald test for joint significance (robust), vcov: vcovSCC
385
386data:  inv ~ value + capital
387Chisq = 93.9283, df = 2, p-value < 0.000000000000000222
388alternative hypothesis: at least one coefficient is not null
389
390> plm::pwaldtest(gd, test = "Chisq", vcov = vcovNW)
391
392	Wald test for joint significance (robust), vcov: vcovNW
393
394data:  inv ~ value + capital
395Chisq = 67.7637, df = 2, p-value = 0.0000000000000019289
396alternative hypothesis: at least one coefficient is not null
397
398> plm::pwaldtest(gd, test = "Chisq", vcov = vcovDC) # finite-sample adj. for df2 irrelevant b/c Chisq test
399
400	Wald test for joint significance (robust), vcov: vcovDC
401
402data:  inv ~ value + capital
403Chisq = 209.701, df = 2, p-value < 0.000000000000000222
404alternative hypothesis: at least one coefficient is not null
405
406>
407>
408>
409>
410> proc.time()
411   user  system elapsed
412   2.56    0.23    2.78
413