Comments (5)
The help says:
weights : dict-like
Dictionary like object (e.g. a DataFrame) containing variable
weights. Each entry must have the same number of observations as
data. If an equation label is not a key weights, the weights will
be set to unity
so that weights should be a dictionary (or possibly a DataFrame) with columns eq1
and eq2
in your case where the column has the weights for respective weights. Let me know if this works.
from linearmodels.
BTW, weights must be positive, so randn is a bad choice.
from linearmodels.
Thanks for the help. Here is the code with adaptions that work in regards to weights.
import pandas as pd
import numpy as np
np.random.seed(123)
data = pd.DataFrame(np.random.randn(500, 4), columns=['y1', 'x1_1', 'y2', 'x2_1'])
weight = abs(pd.DataFrame(np.random.randn(500, 2), columns=['eq1','eq2']))
from linearmodels.system import SUR
formula = {'eq1': 'y1 ~ 1 + x1_1', 'eq2': 'y2 ~ 1 + x2_1'}
mod = SUR.from_formula(formula, data, weights=weight)
res = mod.fit(cov_type='unadjusted')
res
Is out-of-sample prediction possible? Or, for such a simple model should I do the calculation "manually"?
from linearmodels.
Have a look at the help here:
from linearmodels.
Here is my final code
import pandas as pd
import numpy as np
np.random.seed(123)
data = pd.DataFrame(np.random.randn(500, 4), columns=['y1', 'x1_1', 'y2', 'x2_1'])
weight = abs(pd.DataFrame(np.random.randn(500, 2), columns=['eq1','eq2']))
from linearmodels.system import SUR
formula = {'eq1': 'y1 ~ 1 + x1_1', 'eq2': 'y2 ~ 1 + x2_1'}
mod = SUR.from_formula(formula, data, weights=weight)
res = mod.fit(cov_type='unadjusted')
data1 = pd.DataFrame(np.random.randn(500, 4), columns=['y1', 'x1_1', 'y2', 'x2_1'])
pre = res.predict(data=data1)
Thanks again.
from linearmodels.
Related Issues (20)
- Add options to operate comparison table #feature HOT 2
- ENH: Add average adjusted R2 in FamaMacBeth HOT 3
- Add Adjusted R-Square to linearmodels.panel.results.PanelEffectsResults HOT 1
- Variables order in results HOT 8
- Tests fail to run: E ModuleNotFoundError: No module named 'interface_meta' HOT 7
- wald_test HOT 4
- Option to avoid MissingValueWarning warning. HOT 3
- Suggestion: Implement a `.remove_data` function for Results
- Min. obs pr Entities/Time Periods is sometimes reported as 0 HOT 3
- Small sample correction clustered avaialble? HOT 2
- Clustered standard errors in `lineramodels` and `statsmodels` HOT 3
- Fixed-effect `p-value` with clustered covariance differs from Stata HOT 2
- PanelOLS : Dropping absorbed variables doesn't work with sample weights HOT 2
- 14 tests fail HOT 2
- ENH: Implement 2+ fixed-effect with multi-way clustering OLS
- Estimated Effects in random effect HOT 7
- Different results for Random Effects models for Python vs Stata HOT 5
- Fixed effects std. error and p-values HOT 2
- Sanitize extra text from summary
- Interaction terms for Categorical Variables in a RE Model HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linearmodels.