Comments (7)
from mgwr.
from mgwr.
Just a crazy and probably dumb idea but will throw it out there just in case there's some value. Would it make sense to have an "umbrella" module for all models in pysal that implements this formula approach but allows us to do it somehow "on top" of all the packages we have that implement models?
I'm thinking something where the user could pass a formula, a GeoDataFrame, and either the class or a str for the model they want to run, and the module/method would do the magic of dispatching everything. If well-designed, it'd be much easier to use from the user's perspective, and it'd also allow us to benefit from having pysal as a "package of packages"/federation, unifying APIs where possible across modules.
What do you think?
from mgwr.
I really like that! We'd need to spec out 4 things with this, I think. Only the first was on my radar before... let's consider hoval = crime + income
.
- What about autoregression? Before, something I had suggested was defining an operator to specify that something was simultaneous autoregressive. In that proposal, something like
r(hoval) = crime + income
was SAR-lag, andhoval = crime + income + r()
was SAR-Error. HAC estimators would still need to be specified in a keyword, I think. - What about instruments?
- Now, we have
mgwr
, what about locality? Same as above, we could define al()
function to mean "local", so thathoval = l(crime) + l(income)
is an MGWR for crime & income, buthoval = l(crime + income)
is a GWR, andhoval = l(crime) + income
is semiparametric GWR with only a local term for crime. @TaylorOshan, perspective? - With
spvcm
, what about multilevels? We'd need to figure out alme4
-style syntax, in addition to aspreg
-style autoregressive indicator, since patsy doesn't understand the pipe-plus-grouping syntax,(effect | group)
.
from mgwr.
I recall chatting about this a few years back. In highlighting those four issues above that need to be addressed in order to produce module-wide formula API, I think I am sensing two different situations. One is some kind of functionality that creates a design matrix to be passed to a method whereas the other, which could satisfy all four of the above points, is a dispatcher that allows one or more methods to be called by only specifying a formula? In terms of mgwr, I think it would be really neat to have a formula based API that would allow you to deploy all the different variations of gwr/mgwr/semiparametric, though I wonder if this would be too specific to this type of method. For example if we have a single API that accommodates all four points above, are we opening users up to the possibility of easily specifying nonsensical models? Perhaps a simple API for building design matrices would be a good place to start that applies module-wide and then we could build module-specific tweaks and dispatchers on top of this?
from mgwr.
i was thinking along the same lines as Taylor. Ideally we could have a dispatcher that lives in libpysal and provides a robust way of expressing lots of different models using only a formula. If we're going to put some real effort into this, this is probably the "right" way because it opens the door to a wider variety of model specs.
As a first cut, though, we could use patsy to just prepare input data to the existing models (i.e. where models live in their own classes), if for no other reason than to make it easier to use geodataframes. Responding also to @lanselin 's comment from the other thread
not only is there a potential issue with spatial lags, there are also regime variables. how would those fit into the patsy syntax?
same with spatially lagged explanatory variables (SLX, spatial Durbin), ideally computed on the fly (but not in the current implementation). and where would the weights be specified?
I think we could use something like the groups
and re_formula
arguments for spreg
regimes and spvcm
grouping variables like statsmodels does for multilevel models (in R, more nlme
than lme4
, where random
is specified separately). I think a stateful transform might work for lagged explanatory variables but the shortest path would probably be to have grouping/regime/W/additional lags in separate arguments, similar to the way it's handled now.
I was looking into some of these ideas here. It seems to work pretty well for mgwr. It fails for spreg though... I don't think it's related to patsy per-se but also stumped for other ideas.
from mgwr.
an additional small thing is the way intercepts are handled. our packages expect matrices without the constant, so right now patsy strings need to exclude the intercept
from mgwr.
Related Issues (20)
- permissions for the steering council HOT 1
- Debugging LinAlgError - any idea what is going on? HOT 7
- Information about the effect of the else independent variable on the dependent variable HOT 1
- Can't upload the Data File HOT 10
- Switching from multiprocessing to joblib HOT 1
- Edit: Please delete - Binomial/Logistic Family not working
- Admit precomputed distance matrices
- How to solve the problem about the "invalid index to scalar variable" when use Sel_BW.search( ) ? HOT 3
- Undefined local variable used in search.py: golden_section (Line 46, 47) HOT 2
- Sensitivity word as variable used: search.py line 56
- Unused argument defined: search.py: function multi_bw in line 192 (family defined but not used inside function)
- Unused input argument defined: kernels.py: line 44
- What dose the pred_results.predy mean? HOT 2
- 'operands could not be broadcast together with shapes' when using 'pred_results.predictions' HOT 2
- Saving results in Python
- Crashes in QGIS
- modernize infra - `pyproject.toml` [2024-07-08]
- support Python 3.12 - add to CI matrix
- Scaling of kernel functions HOT 4
- No MGWR.predict() functionality
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 mgwr.