Skip to content

scm = F broken in multisynth #100

@mikeguggis

Description

@mikeguggis

Running multisynth with scm = F seems to throw an error Error in multisynth_formatted(wide = wide, relative = T, n_leads = n_leads, : object 'donors' not found. I suspect the error might at least have to do with line 396 of file multisynth_class.R msynth$donors <- donors not being wrapped in if(scm){}

Reproducible code

library(augsynth)
library(dplyr)

data <- read.csv("https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:10.7910/DVN/WGWMAV/3UHTLP", sep="\t")

data %>%
filter(!State %in% c("DC", "WI"),
       year >= 1959, year <= 1997) %>%
mutate(YearCBrequired = ifelse(is.na(YearCBrequired), 
                               Inf, YearCBrequired),
       cbr = 1 * (year >= YearCBrequired)) -> analysis_df

ppool_syn <- multisynth(lnppexpend ~ cbr, State, year, 
                      analysis_df, scm = F)

outputs

> library(augsynth)
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

  filter, lag

The following objects are masked from ‘package:base’:

  intersect, setdiff, setequal, union

> 
> data <- read.csv("https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:10.7910/DVN/WGWMAV/3UHTLP", sep="\t")
> 
> data %>%
+   filter(!State %in% c("DC", "WI"),
+          year >= 1959, year <= 1997) %>%
+   mutate(YearCBrequired = ifelse(is.na(YearCBrequired), 
+                                  Inf, YearCBrequired),
+          cbr = 1 * (year >= YearCBrequired)) -> analysis_df
> 
> ppool_syn <- multisynth(lnppexpend ~ cbr, State, year, 
+                         analysis_df, scm = F)
Error in multisynth_formatted(wide = wide, relative = T, n_leads = n_leads,  : 
object 'donors' not found

Session.info()

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


Random number generation:
RNG:     Mersenne-Twister 
Normal:  Inversion 
Sample:  Rounding 

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.1.2    augsynth_0.2.0

loaded via a namespace (and not attached):
[1] Formula_1.2-5     tidyr_1.3.1       utf8_1.2.3        R6_2.5.1          tidyselect_1.2.1 
[6] magrittr_2.0.3    gtable_0.3.4      glue_1.6.2        tibble_3.2.1      pkgconfig_2.0.3  
[11] generics_0.1.3    ggplot2_3.5.0     lifecycle_1.0.4   cli_3.6.1         fansi_1.0.4      
[16] scales_1.3.0      grid_4.3.1        vctrs_0.6.3       withr_3.0.0       compiler_4.3.1   
[21] purrr_1.0.2       rstudioapi_0.15.0 tools_4.3.1       munsell_0.5.1     pillar_1.9.0     
[26] colorspace_2.1-0  rlang_1.1.1      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions