here is a weird one:
I am working on the following data frame:
str(ccomb)
'data.frame': 358 obs. of 36 variables:
$ Country.Name : chr "Albania" "Albania" "Albania" ...
$ Donor : chr "EU Institutions" "EU Institutions" ...
$ Aid.type : chr "ODA: Total Net" "ODA: Total Net" ...
$ Amount.type : chr "Constant Prices" "Constant Prices" ...
$ year : num 2002 2003 2004 ...
$ Unit : chr "US Dollar" "US Dollar" "US Dollar" ...
$ PowerCode : chr "Millions" "Millions" "Millions" ...
$ Reference.Period : int 2020 2020 2020 ...
$ Total_Net_ODA : num 48.3 43.6 50.8 ...
$ geo : chr "EU27_2020" "EU27_2020" "EU27_2020" ...
$ EU_Exp : num 1166 1281 1376 ...
$ EU_Imp : num 355 396 416 ...
$ Control_of_Corruption : num -0.854 -0.724 -0.813 ...
$ Government_Effectiveness : num -0.569 -0.409 -0.705 ...
$ Political_Stability_and_Absence_of_Violence_and_Terrorism: num -0.31 -0.427 -0.505 ...
$ Regulatory_Quality : num -0.4902 -0.1875 -0.4007 ...
$ Rule_of_Law : num -0.716 -0.701 -0.764 ...
$ Voice_and_Accountability : num 0.07031 0.00724 0.00367 ...
$ pop : num 3.04 3.03 3.01 2.99 2.97 ...
$ GDPpC : num 2381 2522 2676 2851 3045 ...
$ aNNI : num 6.66 7.06 7.33 7.85 8.14 ...
$ openness : num 67 67 70.9 74.3 83.2 ...
$ import : num 46.2 44.8 47.9 ...
$ export : num 20.8 22.2 23 ...
$ infmort : num 20.4 19.1 17.8 ...
$ unemploy : num 17 16.3 16 15.6 16 ...
$ v2x_polyarchy : num 0.491 0.485 0.508 ...
$ v2x_libdem : num 0.398 0.4 0.416 0.436 ...
$ v2x_partipdem : num 0.318 0.322 0.341 ...
$ v2x_delibdem : num 0.383 0.382 0.422 ...
$ v2x_egaldem : num 0.355 0.353 0.361 ...
$ ref_UNHCR_EU : int 3851 3720 5385 ...
$ ref_asyl_seekers_EU : int 667 504 543 ...
$ refugees_EU : int 4518 4224 5928 ...
$ Governance : num -2.87 -2.44 -3.18 ...
$ region : chr "Western Balkan" "Western Balkan" ...
When using plm() on this data, there are several issues, resulting in the error messages: First, the error message occurs:
Error in plm(Total_Net_ODA ~ logpop, logGDPpC, openness, import, export, : arguments 'restrict.matrix' and 'restrict.rhs' cannot yet be used for single equations
When resolving this by setting restrict.matrix = NULL and restrict.rhs = NULL, it cannot find most of the variables anymore. So, I used pdata.frame() to deal with this. It actually works, but causes another problem. I used the following code for the transformation:
ccomb <- comb
str(ccomb)
rowvec <- c(1:358)
make.unique(.rowNamesDF(ccomb, make.names = TRUE) <- as.character(rowvec))
unique(rownames(ccomb))
duplicated(rownames(ccomb))
ccomb <- pdata.frame(comb, index=c("Country.Name", "year"), row.names = FALSE)
modE<-plm(Total_Net_ODA ~ openness, import, export, index=c("Country.Name", "year"),data = ccomb, model="within")
So, the code results in this error message:
Error in
.rowNamesDF<-
(x, value = value) : duplicate 'row.names' not allowed In addition: Warning message: non-unique values when setting 'row.names': ‘19’, ‘21’, ‘22’, ‘23’, ‘24’, ‘25’, ‘26’, ‘27’, ‘28’, ‘29’, ‘30’, ‘31’, ‘32’, ‘33’, ‘34’, ‘35’, ‘36’, ‘37’, ‘38’, ‘39’, ‘40’, ‘41’, ‘42’, ‘43’, ‘44’, ‘45’, ‘46’, ‘47’, ‘48’, ‘49’, ‘50’, ‘51’, ‘52’, ‘53’, ‘54’, ‘55’, ‘56’, ‘58’, ‘59’, ‘60’, ‘61’, ‘62’, ‘63’, ‘64’, ‘65’, ‘66’, ‘67’, ‘68’, ‘69’, ‘71’, ‘73’, ‘76’, ‘78’
Which is weird, as the code above explicitly cancels out any nun-unique row names and the duplicated(rownames(ccomb))
line explicitly states FALSE to every row.
I hope that this information is sufficient. If not, please let me know.
Here is my session info, in case that helps:
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.2.2 (2022-10-31 ucrt)
os Windows 10 x64 (build 19044)
system x86_64, mingw32
ui RStudio
language (EN)
collate German_Germany.utf8
ctype German_Germany.utf8
tz Europe/Berlin
date 2023-02-23
rstudio 2022.12.0+353 Elsbeth Geranium (desktop)
pandoc 2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 4.2.0)
backports 1.4.1 2021-12-13 [1] CRAN (R 4.2.0)
bayestestR 0.13.0 2022-09-18 [1] CRAN (R 4.2.2)
bdsmatrix 1.3-6 2022-06-03 [1] CRAN (R 4.2.0)
bit 4.0.5 2022-11-15 [1] CRAN (R 4.2.2)
bit64 4.0.5 2020-08-30 [1] CRAN (R 4.2.1)
bitops 1.0-7 2021-04-24 [1] CRAN (R 4.2.0)
boot 1.3-28.1 2022-11-22 [1] CRAN (R 4.2.2)
broom 1.0.3 2023-01-25 [1] CRAN (R 4.2.2)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.1)
callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.2)
car * 3.1-1 2022-10-19 [1] CRAN (R 4.2.2)
carData * 3.0-5 2022-01-06 [1] CRAN (R 4.2.1)
caTools 1.18.2 2021-03-28 [1] CRAN (R 4.2.1)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.2.1)
cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.2)
coda 0.19-4 2020-09-30 [1] CRAN (R 4.2.1)
collapse 1.9.2 2023-01-25 [1] CRAN (R 4.2.2)
colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.2)
crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.2)
datawizard 0.6.5 2022-12-14 [1] CRAN (R 4.2.2)
devtools * 2.4.5 2022-10-11 [1] CRAN (R 4.2.2)
digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2)
dplyr * 1.1.0 2023-01-29 [1] CRAN (R 4.2.2)
dreamerr 1.2.3 2020-12-05 [1] CRAN (R 4.2.1)
dyn * 0.2-9.6 2018-03-19 [1] CRAN (R 4.2.1)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.1)
emmeans 1.8.4-1 2023-01-17 [1] CRAN (R 4.2.2)
estimability 1.4.1 2022-08-05 [1] CRAN (R 4.2.1)
evaluate 0.20 2023-01-17 [1] CRAN (R 4.2.2)
fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.2)
farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.1)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.1)
fixest * 0.11.1 2023-01-10 [1] CRAN (R 4.2.2)
forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.2.2)
foreign * 0.8-83 2022-09-28 [2] CRAN (R 4.2.2)
Formula 1.2-4 2020-10-16 [1] CRAN (R 4.2.0)
fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.2)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.1)
ggeffects 1.1.5 2023-01-25 [1] CRAN (R 4.2.2)
ggplot2 * 3.4.1 2023-02-10 [1] CRAN (R 4.2.2)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.1)
gplots * 3.1.3 2022-04-25 [1] CRAN (R 4.2.1)
gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.1)
gtools 3.9.4 2022-11-27 [1] CRAN (R 4.2.2)
highr 0.10 2022-12-22 [1] CRAN (R 4.2.2)
hms 1.1.2 2022-08-19 [1] CRAN (R 4.2.2)
htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2)
htmlwidgets 1.6.1 2023-01-07 [1] CRAN (R 4.2.2)
httpuv 1.6.9 2023-02-14 [1] CRAN (R 4.2.2)
httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.2)
insight 0.19.0 2023-01-30 [1] CRAN (R 4.2.2)
irr * 0.84.1 2019-01-26 [1] CRAN (R 4.2.1)
kableExtra * 1.3.4 2021-02-20 [1] CRAN (R 4.2.1)
KernSmooth 2.23-20 2021-05-03 [2] CRAN (R 4.2.2)
knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.2.0)
later 1.3.0 2021-08-18 [1] CRAN (R 4.2.1)
lattice 0.20-45 2021-09-22 [2] CRAN (R 4.2.2)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.2)
lme4 1.1-31 2022-11-01 [1] CRAN (R 4.2.2)
lmtest * 0.9-40 2022-03-21 [1] CRAN (R 4.2.1)
lpSolve * 5.6.18 2023-02-01 [1] CRAN (R 4.2.2)
lubridate * 1.9.2 2023-02-10 [1] CRAN (R 4.2.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.1)
MASS 7.3-58.2 2023-01-23 [1] CRAN (R 4.2.2)
Matrix 1.5-3 2022-11-11 [1] CRAN (R 4.2.2)
maxLik 1.5-2 2021-07-26 [1] CRAN (R 4.2.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.1)
mgcv 1.8-41 2022-10-21 [1] CRAN (R 4.2.2)
mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.1)
minqa 1.2.5 2022-10-19 [1] CRAN (R 4.2.2)
miscTools 0.6-26 2019-12-08 [1] CRAN (R 4.2.1)
modelr 0.1.10 2022-11-11 [1] CRAN (R 4.2.2)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.1)
mvtnorm 1.1-3 2021-10-08 [1] CRAN (R 4.2.0)
nlme 3.1-162 2023-01-31 [1] CRAN (R 4.2.2)
nloptr 2.0.3 2022-05-26 [1] CRAN (R 4.2.1)
numDeriv 2016.8-1.1 2019-06-06 [1] CRAN (R 4.2.0)
pcse * 1.9.1.1 2018-06-07 [1] CRAN (R 4.2.0)
performance 0.10.2 2023-01-12 [1] CRAN (R 4.2.2)
pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.1)
pkgbuild 1.4.0 2022-11-27 [1] CRAN (R 4.2.2)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.1)
pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.2.2)
plm * 2.6-2 2022-08-16 [1] CRAN (R 4.2.2)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.1)
processx 3.8.0 2022-10-26 [1] CRAN (R 4.2.2)
profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.1)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.1)
ps 1.7.2 2022-10-26 [1] CRAN (R 4.2.2)
purrr * 1.0.1 2023-01-10 [1] CRAN (R 4.2.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.1)
ragg 1.2.5 2023-01-12 [1] CRAN (R 4.2.2)
rbibutils 2.2.13 2023-01-13 [1] CRAN (R 4.2.2)
Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.2)
Rdpack 2.4 2022-07-20 [1] CRAN (R 4.2.1)
readr * 2.1.4 2023-02-10 [1] CRAN (R 4.2.2)
readxl * 1.4.2 2023-02-09 [1] CRAN (R 4.2.2)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.1)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.2)
rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.2.2)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.2)
rvest 1.0.3 2022-08-19 [1] CRAN (R 4.2.2)
sandwich * 3.0-2 2022-06-15 [1] CRAN (R 4.2.1)
scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.1)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.1)
shiny 1.7.4 2022-12-15 [1] CRAN (R 4.2.2)
sjlabelled 1.2.0 2022-04-10 [1] CRAN (R 4.2.1)
sjmisc 2.8.9 2021-12-03 [1] CRAN (R 4.2.1)
sjPlot * 2.8.12 2022-11-19 [1] CRAN (R 4.2.2)
sjstats 0.18.2 2022-11-19 [1] CRAN (R 4.2.2)
stargazer * 5.2.3 2022-03-04 [1] CRAN (R 4.2.0)
stringi 1.7.12 2023-01-11 [1] CRAN (R 4.2.2)
stringr * 1.5.0 2022-12-02 [1] CRAN (R 4.2.2)
svglite 2.1.1 2023-01-10 [1] CRAN (R 4.2.2)
systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.2.1)
texreg * 1.38.6 2022-04-06 [1] CRAN (R 4.2.1)
textshaping 0.3.6 2021-10-13 [1] CRAN (R 4.2.1)
tibble * 3.1.8 2022-07-22 [1] CRAN (R 4.2.1)
tidyr * 1.3.0 2023-01-24 [1] CRAN (R 4.2.2)
tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.2)
tidyverse * 2.0.0 2023-02-22 [1] CRAN (R 4.2.2)
timechange 0.2.0 2023-01-11 [1] CRAN (R 4.2.2)
tzdb 0.3.0 2022-03-28 [1] CRAN (R 4.2.1)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.1)
usethis * 2.1.6 2022-05-25 [1] CRAN (R 4.2.1)
utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.2)
vctrs 0.5.2 2023-01-23 [1] CRAN (R 4.2.2)
viridisLite 0.4.1 2022-08-22 [1] CRAN (R 4.2.1)
vroom 1.6.1 2023-01-22 [1] CRAN (R 4.2.2)
vtable * 1.4.1 2022-11-02 [1] CRAN (R 4.2.2)
webshot 0.5.4 2022-09-26 [1] CRAN (R 4.2.2)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.1)
xfun 0.37 2023-01-31 [1] CRAN (R 4.2.2)
xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.1)
xtable * 1.8-4 2019-04-21 [1] CRAN (R 4.2.1)
zoo * 1.8-11 2022-09-17 [1] CRAN (R 4.2.2)
This line seems flawed:
modE<-plm(Total_Net_ODA ~ openness, import, export, index=c("Country.Name", "year"),data = ccomb, model="within")
Seems like you want to estimate coefficients for variables import
and export
, so you would need to specify them within the formula
argument, the first argument, like so:
modE<-plm(Total_Net_ODA ~ openness + import + export, index=c("Country.Name", "year"),data = ccomb, model="within")
Your command inputs import
and export
as 2nd and 3rd argument to plm
, respectively, which is the data
and subset
argument.