masaasami / pysynthdid Goto Github PK
View Code? Open in Web Editor NEWSynthetic difference in differences for Python
License: Apache License 2.0
Synthetic difference in differences for Python
License: Apache License 2.0
Hi, thanks so much for this package! I'm really grateful to you for coding this up and building it. For one of my applications, however, I'm finding some apparent discrepancies between the graphed quantities and the reported
This
Can you help me understand what might be causing this discrepancy? I was trying to debug by inspecting the fixed effects, but I wasn't able to see in the code where the fixed effects are stored, so had trouble understanding what might have gone amiss; I'm not sure if the plot is wrong, if
`Collecting git+https://github.com/MasaAsami/pysynthdid
Cloning https://github.com/MasaAsami/pysynthdid to /tmp/pip-req-build-ey_7xzv7
Running command git clone --filter=blob:none --quiet https://github.com/MasaAsami/pysynthdid /tmp/pip-req-build-ey_7xzv7
Resolved https://github.com/MasaAsami/pysynthdid to commit 01afe33
Preparing metadata (setup.py) ... done
Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from pysynthdid==0.0.1) (1.5.3)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from pysynthdid==0.0.1) (3.7.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from pysynthdid==0.0.1) (1.23.5)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from pysynthdid==0.0.1) (4.66.1)
Collecting sklearn (from pysynthdid==0.0.1)
Using cached sklearn-0.0.post7.tar.gz (3.6 kB)
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Preparing metadata (setup.py) ... error
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.`
Hey! thanks for your package
I've been playing around with it as an extension of Google's CausalImpact tool.
Got a dataset with market data having different scales, so log transformation is needed. However, I couldn't transform back ATT from its value estimated from log input data to one unscaled. Which formula should I use? Also, is it possible to get confidence interval for tau?
I am trying to apply the code to a time series dataset I am working with. I arranged it as in the example
When I run:
'sdid = SynthDID(df_int, pre_terem, post_terem, treatment )
sdid.fit(zeta_type="base")
hat_omega_simple = sdid.estimated_params(model="sc")
hat_omega_simple'
the sc_weight is the same for all the features, at 0.027
Then when I run:
'sdid.plot(model="sc")'
I get:
TypeError Traceback (most recent call last)
Input In [139], in <cell line: 1>()
----> 1 sdid.plot(model="sc")
File ~/anaconda3/lib/python3.9/site-packages/synthdid/plot.py:12, in Plot.plot(self, model, figsize)
10 result = pd.DataFrame({"actual_y": self.target_y()})
11 post_actural_treat = result.loc[self.post_term[0] :, "actual_y"].mean()
---> 12 post_point = np.mean(self.Y_post_c.index)
14 if model == "sdid":
15 result["sdid"] = self.sdid_trajectory()
File <array_function internals>:5, in mean(*args, **kwargs)
File ~/anaconda3/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3438, in mean(a, axis, dtype, out, keepdims, where)
3436 pass
3437 else:
-> 3438 return mean(axis=axis, dtype=dtype, out=out, **kwargs)
3440 return _methods._mean(a, axis=axis, dtype=dtype,
3441 out=out, **kwargs)
File ~/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/extension.py:95, in _inherit_from_data..method(self, *args, **kwargs)
93 if "inplace" in kwargs:
94 raise ValueError(f"cannot use inplace with {type(self).name}")
---> 95 result = attr(self._data, *args, **kwargs)
96 if wrap:
97 if isinstance(result, type(self._data)):
TypeError: mean() got an unexpected keyword argument 'dtype'
Getting ValueError: Cannot index with multidimensional key from:
self.Y_pre_t = self.df.loc[self.pre_term[0] : self.pre_term[1], self.treatment]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.