This helper function provides a simple way to retrieve the
widened data from a fitted dpm()
object.
get_wide_data(model)
A dpm
object.
A data.frame
with input data transformed from "long" to "wide"
format, with just one row per person/entity. Internally, this is
generated by calling panelr::widen_panel()
after some
preprocessing.
data("WageData", package = "panelr")
wages <- panel_data(WageData, id = id, wave = t)
fit <- dpm(wks ~ pre(lag(union)) + lag(lwage), data = wages)
get_wide_data(fit)
#> # A tibble: 595 × 22
#> id union_1 wks_1 lwage_1 union_2 wks_2 lwage_2 union_3 wks_3 lwage_3
#> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 0 32 5.56 0 43 5.72 0 40 6.00
#> 2 2 0 34 6.16 0 27 6.21 1 33 6.26
#> 3 3 1 50 5.65 1 51 6.44 1 50 6.55
#> 4 4 0 52 6.16 0 46 6.24 0 46 6.30
#> 5 5 1 50 6.44 1 46 6.62 1 40 6.63
#> 6 6 0 44 6.91 0 47 6.91 0 47 6.91
#> 7 7 1 46 6.13 1 48 6.17 1 49 6.21
#> 8 8 1 51 6.33 1 50 6.40 1 50 6.54
#> 9 9 0 50 6.55 0 48 6.55 0 50 6.80
#> 10 10 0 49 6.40 0 47 6.44 0 46 6.44
#> # ℹ 585 more rows
#> # ℹ 12 more variables: union_4 <dbl>, wks_4 <dbl>, lwage_4 <dbl>,
#> # union_5 <dbl>, wks_5 <dbl>, lwage_5 <dbl>, union_6 <dbl>, wks_6 <dbl>,
#> # lwage_6 <dbl>, union_7 <dbl>, wks_7 <dbl>, lwage_7 <dbl>