Here's what the reprex should look like. I can reproduce the error, can't see why it should not work based on the example, and have found no express error messages in the function code for pvargmm, so I will be running that looking for subset operations later tonight.
The reprex doesn't generate because two of the variables given as an argument, "gdp", "pop_urb_per" don't exist. However, removing them doesn't help, either
suppressPackageStartupMessages({
library(panelvar)
})
VARtestdata <- structure(list(
country = c(
"AGO", "AGO", "AGO", "AGO", "AGO",
"AGO"
), year = c(1980, 1981, 1982, 1983, 1984, 1985), elec_gen_kwh = c(
8.96,
8.96, 9, 9.01, 9.01, 9.01
), elec_con_kwh = c(
8.87, 8.87, 8.91,
8.92, 8.93, 8.92
), elec_cap_kw = c(
8.78, 8.78, 8.78, 8.78, 8.78,
8.78
), elec_loss_kwh = c(8.23, 8.23, 8.26, 8.29, 8.23, 8.31),
en_con_tot_toe = c(6.17, 6.16, 6.19, 6.22, 6.18, 6.27), en_con_petr_toe = c(
6.04,
6.04, 6.06, 6.08, 6.02, 6.13
), petr_con_mt = c(
6, 6, 6.02,
6.04, 5.98, 6.1
)
), class = c(
"spec_tbl_df", "tbl_df", "tbl",
"data.frame"
), row.names = c(NA, -6L), spec = structure(list(
cols = list(country = structure(list(), class = c(
"collector_character",
"collector"
)), year = structure(list(), class = c(
"collector_double",
"collector"
)), elec_gen_kwh = structure(list(), class = c(
"collector_double",
"collector"
)), elec_con_kwh = structure(list(), class = c(
"collector_double",
"collector"
)), elec_cap_kw = structure(list(), class = c(
"collector_double",
"collector"
)), elec_loss_kwh = structure(list(), class = c(
"collector_double",
"collector"
)), en_con_tot_toe = structure(list(), class = c(
"collector_double",
"collector"
)), en_con_petr_toe = structure(list(), class = c(
"collector_double",
"collector"
)), petr_con_mt = structure(list(), class = c(
"collector_double",
"collector"
))), default = structure(list(), class = c(
"collector_guess",
"collector"
)), skip = 1L
), class = "col_spec"pvargmm))e(list(), class = c(
"collector_double",
"collector"
))), default = structure(suppressPackageStartupMessages({
library(panelvar)
})
# reproduce the error
varex1 <- pvargmm(dependent_vars = c("en_con_tot_toe", "gdp", "pop_urb_per"), lags = 1, transformation = "fod", data = VARtestdata, panel_identifier = c("country", "year"), steps = c("twostep"), system_instruments = FALSE)