Skip to content

Commit

Permalink
add some TODOs about FD models with special data (only one obs in a g…
Browse files Browse the repository at this point in the history
…roup)
  • Loading branch information
tappek committed Jul 6, 2024
1 parent 6be1d03 commit a6e4f8f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
15 changes: 14 additions & 1 deletion inst/tests/test_FD_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ vcovHC(fd_plm2)
# vcovHC(fd_pggls)
# vcovHC(fd_pggls2)

# vcovXX on FD models
### vcovXX on FD models
data("Grunfeld", package = "plm")
pGrun <- pdata.frame(Grunfeld)
# one group with only one observation > gets first-differenced away
pGrun1 <- pGrun[-c(61:200), ]
pGrun1 <- pGrun1[-c(2:20), ]
pdim(pGrun1)
Expand All @@ -49,10 +50,22 @@ vcovHC(mod)
vcovBK(mod)
diff(pGrun1$inv)

## TODO: pggls errors
# mod.pggls <- pggls(inv ~ value + capital, data = pGrun1, model="fd")

# one time period with only one observation
pGrun2 <- pGrun[-c(21, 41, 61, 81, 101, 121, 141, 161, 181), ]
pdim(pGrun2)
pdim(pGrun2)$Tint
mod2 <- plm(inv ~ value + capital, data = pGrun2, model="fd")
vcovHC(mod2)

## TODO vcovBK errors
# vcovBK(mod2) # errors with Error in demX[groupinds, , drop = FALSE] : subscript out of bounds

mod2.pggls <- pggls(inv ~ value + capital, data = pGrun2, model="fd")



# data with one time period per group -> first-differenced away -> empty model
#pGrun3 <- pGrun[c(1, 21, 41, 61, 81, 101, 121, 141, 161, 181), ]
Expand Down
28 changes: 26 additions & 2 deletions inst/tests/test_FD_models.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ attr(,"cluster")
> # vcovHC(fd_pggls)
> # vcovHC(fd_pggls2)
>
> # vcovXX on FD models
> ### vcovXX on FD models
> data("Grunfeld", package = "plm")
> pGrun <- pdata.frame(Grunfeld)
> # one group with only one observation > gets first-differenced away
> pGrun1 <- pGrun[-c(61:200), ]
> pGrun1 <- pGrun1[-c(2:20), ]
> pdim(pGrun1)
Expand Down Expand Up @@ -322,7 +323,24 @@ attr(,"cluster")
3-1947 3-1948 3-1949 3-1950 3-1951 3-1952 3-1953 3-1954
-12.7 -0.9 -48.0 -4.8 41.7 22.1 22.2 10.1
>
> ## TODO: pggls errors
> # mod.pggls <- pggls(inv ~ value + capital, data = pGrun1, model="fd")
>
> # one time period with only one observation
> pGrun2 <- pGrun[-c(21, 41, 61, 81, 101, 121, 141, 161, 181), ]
> pdim(pGrun2)
Unbalanced Panel: n = 10, T = 19-20, N = 191
> pdim(pGrun2)$Tint
$Ti
1 2 3 4 5 6 7 8 9 10
20 19 19 19 19 19 19 19 19 19

$nt
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950
1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
1951 1952 1953 1954
10 10 10 10

> mod2 <- plm(inv ~ value + capital, data = pGrun2, model="fd")
> vcovHC(mod2)
(Intercept) value capital
Expand All @@ -331,12 +349,18 @@ value 0.02724565 0.0001316189 -0.001260823
capital -0.37044031 -0.0012608229 0.020684253
attr(,"cluster")
[1] "group"
>
> ## TODO vcovBK errors
> # vcovBK(mod2) # errors with Error in demX[groupinds, , drop = FALSE] : subscript out of bounds
>
> mod2.pggls <- pggls(inv ~ value + capital, data = pGrun2, model="fd")
>
>
>
> # data with one time period per group -> first-differenced away -> empty model
> #pGrun3 <- pGrun[c(1, 21, 41, 61, 81, 101, 121, 141, 161, 181), ]
> #mod3 <- plm(inv ~ value + capital, data = pGrun3, model="fd")
>
> proc.time()
user system elapsed
1.53 0.32 1.81
1.59 0.20 1.78

0 comments on commit a6e4f8f

Please sign in to comment.