Hallo Nadja

Similar as Bert I do not know how the function works. From the help page -
synth.data - is used in example. Check if your data structure is consistent
with synth.data by comparing str(synth.data) and str( INVESTMENTVOLUME).
Names of columns should be in both cases match the names in dataprep call
and type of columns should be also same.

Cheers.
Petr



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Neobsahuje
žádné viry.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_7252664788356473291_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

út 16. 4. 2024 v 9:58 odesílatel <nadja.delliehau...@bluewin.ch> napsal:

> Good Morning
>
>
>
> I want to perform a synthetic control method with R. For this purpose, I
> created the following code:
>
>
>
> # Re-load packages
>
> library(Synth)
>
> library(readxl)
>
>
>
> # Pfadeinstellung Excel-Blatt
>
> excel_file_path <-
> ("C:\\Users\\xxxxx\\Desktop\\DATA_INVESTMENTVOLUMEN_FOR_R_WITHOUT_NA.xlsx")
>
>
>
> # Load the Excel file
>
> INVESTMENTVOLUME <- read_excel(excel_file_path)
>
>
>
> # Anzeigen des gesamten Dataframes
>
> print(INVESTMENTVOLUME)
>
>
>
> # Make sure BFS is numeric right before dataprep
>
> INVESTMENTVOLUME$BFS <- as.numeric(INVESTMENTVOLUME$BFS)
>
>
>
> # running dataprep
>
> dataprep_out <- dataprep(
>
>   foo = INVESTMENTVOLUME,
>
>   predictors = c("Predictor 1", " Predictor 2", " Predictor 3" Predictor
> 4",
> " Predictor 5", " Predictor 6"),
>
>   special.predictors = list(list("Special Predictor 1", seq(1, 12, by =
> 1))),
>
>   dependent = "INVESTMENTVOLUME_12_MONTH_AVERAGE",
>
>   unit.variable = "BFS",
>
>   time.variable = "DATE",
>
>   treatment.identifier = XXXX,
>
>   controls.identifier =
> unique(INVESTMENTVOLUME$BFS[-which(INVESTMENTVOLUME$BFS == XXXX)]),
>
>   time.predictors.prior = as.Date("2010-01-01"):as.Date("2017-10-01"),
>
>   time.optimize.ssr = as.Date("2010-01-01"):as.Date("2017-10-01"),
>
>   time.plot = as.Date("2010-01-01"):as.Date("2024-03-01"),
>
>   unit.names.variable = "BFS"
>
> )
>
>
>
> synth_out <- synth(
>
>   data.prep.obj = dataprep_out
>
> )
>
>
>
> I keep getting the same error message. Unfortunately, ChatGPT and solutions
> from various forums do not help. My unit variables are all numeric except
> one, which is a date and has POSIXct as type.
>
> Fehler in dataprep(foo = INVESTMENTVOLUME, predictors = c("Predictor 1",
> :
>
>
>
>  unit.variable not found as numeric variable in foo.
>
>
>
> I would be very grateful if you could help me with my problem.
>
>
>
> Thank you in advance for your efforts.
>
>
>
> Kind regards
>
> Nadja Delliehausen
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to