如何绘制具有稳健标准误差的系数?

发布于 2025-01-20 15:13:29 字数 23847 浏览 0 评论 0原文

我有这个 LSDV 模型,使用“lm()”函数并添加国家虚拟变量减去截距。然后,我制作了稳健的标准误差,以修复异方差和自相关:

msubv2 <- lm(subv ~ preelec + elec + postelec + ideo + ali +
           crec_pib + pob + pob16 + pob64 + factor(ccaa)-1, data = datos)
rsecoef_msubv2 <- coeftest(msubv2, vcovHAC(msubv2))

这是我用来使用 stargazer() 实现回归输出中的新系数的代码:

cov12 <- vcovHAC(msubv2)
rsesubv2 <- sqrt(diag(cov12))

现在我想绘制解释性的这些新系数变量“preelec”、“elec”和“postelec”使用同名包中的 ggplot2() 或 coefplot()。但是,由于包含新系数的对象不是“lm”对象,因此当我使用这些函数时会出现错误。

因此,我只想知道如何将对象 rsecoef_msubv2 转换为“lm”对象,或者只是绘制这 3 个变量的系数的另一种方法。

PS 好的,这是我的数据的子集。必须将其转换为面板

structure(list(ccaa = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 
4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 
12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L), .Label = c("ANDALUCIA", 
"ARAGON", "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
"CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", "LA RIOJA", 
"MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", "VALENCIA"), class = "factor"), 
    year = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
    2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("1986", "1987", 
    "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", 
    "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", 
    "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", 
    "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor"), 
    ccaa_year = structure(c("AND86", "AND87", "ARA86", "ARA87", 
    "AST86", "AST87", "BAL86", "BAL87", "ISC86", "ISC87", "CANT86", 
    "CANT87", "CLM86", "CLM87", "CYL86", "CYL87", "CAT86", "CAT87", 
    "EXT86", "EXT87", "GAL86", "GAL87", "RIO86", "RIO87", "MAD86", 
    "MAD87", "MUR86", "MUR87", "NAV86", "NAV87", "PAV86", "PAV87", 
    "VAL86", "VAL87"), index = structure(list(ccaa = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L), .Label = c("ANDALUCIA", "ARAGON", 
    "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
    "CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", 
    "LA RIOJA", "MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", 
    "VALENCIA"), class = "factor"), year = structure(c(1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
    16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 
    28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
    9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
    20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 
    32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
    14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
    26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L), .Label = c("1986", 
    "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", 
    "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", 
    "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", 
    "2011", "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor")), row.names = c(1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
    39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
    51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 
    63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
    75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
    87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
    99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 
    109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
    119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 
    129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 
    139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 
    149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 
    159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 
    169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 
    179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 
    189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 
    199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
    209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 
    219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 
    229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 
    239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 
    249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 
    259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 
    269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 
    279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 
    321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 
    331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 
    341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 
    351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 
    361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 
    371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 
    381L, 382L, 383L, 384L, 513L, 514L, 515L, 516L, 517L, 518L, 
    519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L, 528L, 
    529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 
    539L, 540L, 541L, 542L, 543L, 544L, 385L, 386L, 387L, 388L, 
    389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 
    399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 
    409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 
    419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 
    429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L, 
    439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
    449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 
    459L, 460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 
    469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 
    479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 
    489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 
    499L, 500L, 501L, 502L, 503L, 504L, 505L, 506L, 507L, 508L, 
    509L, 510L, 511L, 512L, 289L, 290L, 291L, 292L, 293L, 294L, 
    295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 
    305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 
    315L, 316L, 317L, 318L, 319L, 320L), class = c("pindex", 
    "data.frame")), class = c("pseries", "character")), subv = structure(c(16.7302560676507, 
    20.4606384605254, 10.3964123452188, 6.36288798106429, 9.16543765426987, 
    8.40335369638951, 7.95058549475298, 7.07913989487299, 21.1288836451444, 
    18.6147451720256, 11.613581886766, 7.75476195855383, 24.3052882852147, 
    21.1325248124902, 7.19278302770739, 7.20350705287662, 25.860092626368, 
    23.3847976914879, 11.0315837047611, 17.5546273201597, 14.0537729379123, 
    14.8129830488661, 10.2404482920113, 6.98585616360406, 29.2092515156566, 
    17.1150774779986, 8.82174329305509, 7.9138138292632, 12.9945592447864, 
    13.0334015804209, 1.31541109940362, 2.11013964638404, 17.6289233833167, 
    19.691143771018), index = structure(list(ccaa = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L), .Label = c("ANDALUCIA", "ARAGON", 
    "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
    "CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", 
    "LA RIOJA", "MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", 
    "VALENCIA"), class = "factor"), year = structure(c(1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
    16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 
    28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
    9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
    20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 
    32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
    14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
    26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L), .Label = c("1986", 
    "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", 
    "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", 
    "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", 
    "2011", "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor")), row.names = c(1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
    39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
    51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 
    63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
    75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
    87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
    99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 
    109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
    119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 
    129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 
    139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 
    149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 
    159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 
    169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 
    179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 
    189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 
    199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
    209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 
    219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 
    229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 
    239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 
    249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 
    259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 
    269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 
    279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 
    321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 
    331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 
    341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 
    351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 
    361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 
    371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 
    381L, 382L, 383L, 384L, 513L, 514L, 515L, 516L, 517L, 518L, 
    519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L, 528L, 
    529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 
    539L, 540L, 541L, 542L, 543L, 544L, 385L, 386L, 387L, 388L, 
    389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 
    399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 
    409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 
    419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 
    429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L, 
    439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
    449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 
    459L, 460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 
    469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 
    479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 
    489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 
    499L, 500L, 501L, 502L, 503L, 504L, 505L, 506L, 507L, 508L, 
    509L, 510L, 511L, 512L, 289L, 290L, 291L, 292L, 293L, 294L, 
    295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 
    305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 
    315L, 316L, 317L, 318L, 319L, 320L), class = c("pindex", 
    "data.frame")), class = c("pseries", "numeric")), elec = c(1L, 
    0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 
    0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 
    0L, 0L, 1L), preelec = c(0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 
    1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 
    0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L), postelec = c(0L, 
    1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    1L, 0L, 0L), ideo = c(0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 
    1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 
    0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L), ali = c(1L, 1L, 
    1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 
    0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 
    1L, 1L)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -34L), groups = structure(list(ccaa = structure(1:17, .Label = c("ANDALUCIA", 
"ARAGON", "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
"CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", "LA RIOJA", 
"MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", "VALENCIA"), class = "factor"), 
    .rows = structure(list(1:2, 3:4, 5:6, 7:8, 9:10, 11:12, 13:14, 
        15:16, 17:18, 19:20, 21:22, 23:24, 25:26, 27:28, 29:30, 
        31:32, 33:34), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -17L), .drop = TRUE))

数据我只需要这样的东西

PS 我只需要这样的东西

PS 最后我想我找到了解决方案。系数图可以使用“GGally”包中的函数“ggcoef”来执行,这使我们能够将 coeftest() 参数作为对象包含在内。然后我们可以这样继续:

首先我们为 coeftest() 创建一个对象:

matrix_coeftestmsubv2 <- coeftest(msubv2, vcovHAC(msubv2))

之后我们只需使用“ggcoef()”创建绘图:

ggcoef(matrix_coefmsubv2) + coord_flip() 

尽管如此,我仍然对如何从模型中保留某些变量有一些疑问,如何在 X 轴上对它们进行排序以及如何添加一条线来连接系数点,但我想我会发表一篇新文章以获得答案。

I have this LSDV model using the "lm()" function and adding the country dummy variables minus the intercept. Then I made robust standard errors in order to fix heteroskedasticity and autocorrelation:

msubv2 <- lm(subv ~ preelec + elec + postelec + ideo + ali +
           crec_pib + pob + pob16 + pob64 + factor(ccaa)-1, data = datos)
rsecoef_msubv2 <- coeftest(msubv2, vcovHAC(msubv2))

This is the code I used in order to implement the new coefficients in a regression output with stargazer() by the way:

cov12 <- vcovHAC(msubv2)
rsesubv2 <- sqrt(diag(cov12))

Now I want to plot these new coefficients of the explanatory variables "preelec", "elec" and "postelec" using either ggplot2() or coefplot() from the namesake package. However, as my object which contains the new coefficients is not an "lm" object, when I use those functions I get an error.

Hence, I just want to know how can I convert the object rsecoef_msubv2 into an "lm" object, or just another way to plot the coefficients for those 3 variables.

P.S. Ok, so this is a subset of my data. It must be converted into a panel data

structure(list(ccaa = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 
4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 
12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L), .Label = c("ANDALUCIA", 
"ARAGON", "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
"CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", "LA RIOJA", 
"MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", "VALENCIA"), class = "factor"), 
    year = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
    2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("1986", "1987", 
    "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", 
    "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", 
    "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", 
    "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor"), 
    ccaa_year = structure(c("AND86", "AND87", "ARA86", "ARA87", 
    "AST86", "AST87", "BAL86", "BAL87", "ISC86", "ISC87", "CANT86", 
    "CANT87", "CLM86", "CLM87", "CYL86", "CYL87", "CAT86", "CAT87", 
    "EXT86", "EXT87", "GAL86", "GAL87", "RIO86", "RIO87", "MAD86", 
    "MAD87", "MUR86", "MUR87", "NAV86", "NAV87", "PAV86", "PAV87", 
    "VAL86", "VAL87"), index = structure(list(ccaa = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L), .Label = c("ANDALUCIA", "ARAGON", 
    "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
    "CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", 
    "LA RIOJA", "MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", 
    "VALENCIA"), class = "factor"), year = structure(c(1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
    16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 
    28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
    9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
    20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 
    32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
    14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
    26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L), .Label = c("1986", 
    "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", 
    "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", 
    "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", 
    "2011", "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor")), row.names = c(1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
    39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
    51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 
    63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
    75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
    87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
    99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 
    109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
    119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 
    129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 
    139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 
    149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 
    159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 
    169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 
    179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 
    189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 
    199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
    209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 
    219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 
    229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 
    239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 
    249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 
    259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 
    269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 
    279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 
    321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 
    331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 
    341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 
    351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 
    361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 
    371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 
    381L, 382L, 383L, 384L, 513L, 514L, 515L, 516L, 517L, 518L, 
    519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L, 528L, 
    529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 
    539L, 540L, 541L, 542L, 543L, 544L, 385L, 386L, 387L, 388L, 
    389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 
    399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 
    409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 
    419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 
    429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L, 
    439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
    449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 
    459L, 460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 
    469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 
    479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 
    489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 
    499L, 500L, 501L, 502L, 503L, 504L, 505L, 506L, 507L, 508L, 
    509L, 510L, 511L, 512L, 289L, 290L, 291L, 292L, 293L, 294L, 
    295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 
    305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 
    315L, 316L, 317L, 318L, 319L, 320L), class = c("pindex", 
    "data.frame")), class = c("pseries", "character")), subv = structure(c(16.7302560676507, 
    20.4606384605254, 10.3964123452188, 6.36288798106429, 9.16543765426987, 
    8.40335369638951, 7.95058549475298, 7.07913989487299, 21.1288836451444, 
    18.6147451720256, 11.613581886766, 7.75476195855383, 24.3052882852147, 
    21.1325248124902, 7.19278302770739, 7.20350705287662, 25.860092626368, 
    23.3847976914879, 11.0315837047611, 17.5546273201597, 14.0537729379123, 
    14.8129830488661, 10.2404482920113, 6.98585616360406, 29.2092515156566, 
    17.1150774779986, 8.82174329305509, 7.9138138292632, 12.9945592447864, 
    13.0334015804209, 1.31541109940362, 2.11013964638404, 17.6289233833167, 
    19.691143771018), index = structure(list(ccaa = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
    12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 
    15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 
    16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 
    17L, 17L, 17L, 17L, 17L, 17L), .Label = c("ANDALUCIA", "ARAGON", 
    "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
    "CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", 
    "LA RIOJA", "MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", 
    "VALENCIA"), class = "factor"), year = structure(c(1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
    16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 
    28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
    9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
    20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 
    32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
    14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
    26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 
    6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
    19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
    13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 
    25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L), .Label = c("1986", 
    "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", 
    "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", 
    "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", 
    "2011", "2012", "2013", "2014", "2015", "2016", "2017"), class = "factor")), row.names = c(1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
    15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
    27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
    39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
    51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 
    63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
    75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 
    87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
    99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 
    109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
    119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 
    129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 
    139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 
    149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 
    159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 
    169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 
    179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 
    189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 
    199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
    209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 
    219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 
    229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 
    239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 
    249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 
    259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 
    269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 
    279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 
    321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 
    331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 
    341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 
    351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 
    361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 
    371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 
    381L, 382L, 383L, 384L, 513L, 514L, 515L, 516L, 517L, 518L, 
    519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L, 528L, 
    529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 
    539L, 540L, 541L, 542L, 543L, 544L, 385L, 386L, 387L, 388L, 
    389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 
    399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 
    409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 
    419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 
    429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L, 
    439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
    449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 
    459L, 460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 
    469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 
    479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 
    489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 
    499L, 500L, 501L, 502L, 503L, 504L, 505L, 506L, 507L, 508L, 
    509L, 510L, 511L, 512L, 289L, 290L, 291L, 292L, 293L, 294L, 
    295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 
    305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 
    315L, 316L, 317L, 318L, 319L, 320L), class = c("pindex", 
    "data.frame")), class = c("pseries", "numeric")), elec = c(1L, 
    0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 
    0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 
    0L, 0L, 1L), preelec = c(0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 
    1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 
    0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L), postelec = c(0L, 
    1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    1L, 0L, 0L), ideo = c(0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 
    1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 
    0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L), ali = c(1L, 1L, 
    1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 
    0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 
    1L, 1L)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -34L), groups = structure(list(ccaa = structure(1:17, .Label = c("ANDALUCIA", 
"ARAGON", "ASTURIAS", "BALEARES", "CANARIAS", "CANTABRIA", "CASTILLA LA-MANCHA", 
"CASTILLA Y LEÓN", "CATALUÑA", "EXTREMADURA", "GALICIA", "LA RIOJA", 
"MADRID", "MURCIA", "NAVARRA", "PAIS VASCO", "VALENCIA"), class = "factor"), 
    .rows = structure(list(1:2, 3:4, 5:6, 7:8, 9:10, 11:12, 13:14, 
        15:16, 17:18, 19:20, 21:22, 23:24, 25:26, 27:28, 29:30, 
        31:32, 33:34), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -17L), .drop = TRUE))

P.S. I just need something like this

P.S. I just need something like this

P.S. Finally I think I found a solution. The coefficients plot can be performed with the fuction "ggcoef" from the "GGally" package, which enables us to include as an object the coeftest() argument. Then we can procede like this:

First we create an object for our coeftest():

matrix_coeftestmsubv2 <- coeftest(msubv2, vcovHAC(msubv2))

After that we just create the plot with "ggcoef()":

ggcoef(matrix_coefmsubv2) + coord_flip() 

Nevertheless, I still have some doubts regarding how to keep certain variables from the model, how to order them in the X Axis and how to add a line to connect the coefficients points, but I think I'll make a new post in order to get an answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

箜明 2025-01-27 15:13:29

因此,我找到了一个确定的解决方案,我将与大家分享。我们需要的功能是属于“ DotWhisker”软件包的DWPLOT()。这个允许我们包含一个“ coeftest”对象,并使用“ ggplot2”来轻松自定义图形。但是,我建议将Coeftest对象转换为数据框架,因为它可以更轻松地删除我们不需要的变量。

首先,我们需要将对象rsecoef_msubv2转换为dataframe:

 library(dotwhisker)
rsecoef_msubv2 <- as.data.frame(rsecoef_msubv2)

在此之后,我们删除了我们不需要的行,在我的情况下:

tidycoefisubv <- tidycoefisubv[-c(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26), ]

最后,我们只是使用“ dwplot”创建图。在此示例中,我翻转了轴的位置,改变了背景的颜色,两个轴文本的字体和大小。

 dwplot(tidycoefisubv, vars_order = c("Postelectoral", "Electoral", "Preelectoral")) + 
  coord_flip() + theme_bw() + theme(panel.grid.major = element_blank(), 
            panel.grid.minor = element_blank(), text = element_text(size = 10), 
axis.text.y = element_text(size=10, color="black"), axis.text.x = element_text(size=10, 
          color="black"),legend.position = "none") + labs(x = "Transferencias per cápita", y = NULL)

这就是结果:

”在此处输入图像描述”

So I found a definitive solution, I'm going to share it with you all. The function we need is dwplot() which belongs to the "dotwhisker" package. This one allows us to include a "coeftest" object and uses "ggplot2" to custom the graph easily. However, I recommend to convert the coeftest object into a dataframe because it makes it easier to delete the variables we don't need.

First we need to convert the object rsecoef_msubv2 into a dataframe:

 library(dotwhisker)
rsecoef_msubv2 <- as.data.frame(rsecoef_msubv2)

After that we delete the rows we don't need, in my case:

tidycoefisubv <- tidycoefisubv[-c(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26), ]

Finally we just create the plot using "dwplot". In this example I flipped the position of the axis, changed the color of the background and the font and size of the text of both axis.

 dwplot(tidycoefisubv, vars_order = c("Postelectoral", "Electoral", "Preelectoral")) + 
  coord_flip() + theme_bw() + theme(panel.grid.major = element_blank(), 
            panel.grid.minor = element_blank(), text = element_text(size = 10), 
axis.text.y = element_text(size=10, color="black"), axis.text.x = element_text(size=10, 
          color="black"),legend.position = "none") + labs(x = "Transferencias per cápita", y = NULL)

And this is the result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文