Fw: Asking for Problems in Package "spreg"

30 views
Skip to first unread message

Julia Koschinsky

unread,
Aug 9, 2024, 12:06:13 PM8/9/24
to Openspace List, wenru...@polytechnique.edu
Please respond to wenru...@polytechnique.edu
Thanks, Julia


Julia Koschinsky, Ph.D.
Executive Director and Senior Research Associate
Center for Spatial Data Science
University of Chicago



From: spatial...@lists.uchicago.edu <spatial...@lists.uchicago.edu> on behalf of Dai Wenrui (M.) <wenru...@polytechnique.edu>
Sent: Friday, August 9, 2024 11:04 AM
To: spa...@uchicago.edu <spa...@uchicago.edu>
Subject: [spatial] Asking for Problems in Package "spreg"
 
To whom it may concern at Center for Spatial Data Science, University of Chicago:

I hope this message finds you well. My name is Wenrui DAI, and currently I'm a research assistant at Politecnico di Milano. I send this message because I encountered some problems when using the latest version of the Python package "spreg v.1.5.0".

To be more detailed, there are two problems:
1. I cannot import the function "GM_Combo" when trying to run SARAR analysis. The error was reported as below:
--------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) Cell In[1], line 5      3 import geopandas as gpd      4 from libpysal import weights ----> 5 from spreg import GM_Combo      6 import libpysal      7 from sklearn.preprocessing import StandardScaler ImportError: cannot import name 'GM_Combo' from 'spreg' (unknown location)

2. When doing GWR analysis using the package "mgwr", it said that there is no module named "spreg.utils":
--------------------------------------------------------------------------- ModuleNotFoundError                       Traceback (most recent call last) Cell In[1], line 3      1 import pandas as pd      2 import geopandas as gpd ----> 3 from mgwr.gwr import GWR, MGWR      4 from mgwr.sel_bw import Sel_BW      5 from shapely.geometry import Point File ~\anaconda3\Lib\site-packages\mgwr\__init__.py:3      1 __version__ = "2.1.2" ----> 3 from . import gwr      4 from . import sel_bw      5 from . import diagnostics File ~\anaconda3\Lib\site-packages\mgwr\gwr.py:11      9 from scipy.special import factorial     10 from itertools import combinations as combo ---> 11 from spglm.family import Gaussian, Binomial, Poisson     12 from spglm.glm import GLM, GLMResults      13 from spglm.iwls import iwls, _compute_betas_gwr File ~\anaconda3\Lib\site-packages\spglm\__init__.py:3      1 __version__ = '1.0.8' ----> 3 from . import glm      4 from . import family      5 from . import utils File ~\anaconda3\Lib\site-packages\spglm\glm.py:7      5 import numpy as np      6 import numpy.linalg as la ----> 7 from spreg.utils import RegressionPropsY, spdot      8 from spreg import user_output as USER      9 from .utils import cache_readonly ModuleNotFoundError: No module named 'spreg.utils'

I can confirm that the installation is correct, and I can run the code when using version 1.2.4. I also checked the API file of spreg, but I can still see the module "GM_Combo".
I would appreciate it if you can reply to my message and figure these problems out. It would be of great help to my ongoing project.
Thank you and wish you a great day.

Best regards,
Wenrui DAI
08/10/2024

Julia Koschinsky

unread,
Aug 9, 2024, 12:30:59 PM8/9/24
to Openspace List
FYI


Julia Koschinsky, Ph.D.
Executive Director and Senior Research Associate
Center for Spatial Data Science
University of Chicago



From: Levi Wolf <levi.jo...@gmail.com>
Sent: Friday, August 9, 2024 11:29 AM
To: wenru...@polytechnique.edu <wenru...@polytechnique.edu>
Subject: Re: Asking for Problems in Package "spreg"
 

Hi Wenrui,

 

You may need to check that the version of spreg that you are accessing from within your jupyter environment is correct. Sometimes, when we install two different versions of a package in two different computational environments, one environment might not correctly identify the version of the package it needs to use.

 

Can you try putting the two lines at the top of your script, and tell me the output?

 

import spreg

print(spreg.__version__)

 

 

ljw

 

--
You received this message because you are subscribed to the Google Groups "Openspace List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openspace-lis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openspace-list/PH0PR11MB49980A5EE8E5CFD3F7AD5F09CDBA2%40PH0PR11MB4998.namprd11.prod.outlook.com.

Luc Anselin

unread,
Aug 9, 2024, 1:41:47 PM8/9/24
to openspa...@googlegroups.com, wenru...@polytechnique.edu
The complete path would be:

from spreg import error_sp.GM_Combo

but from spreg import GM_Combo seems to still work (it imports spreg.error_sp.GM_Combo).

Please note that the preferred approach to run a SARSAR model  is to
use the new GMM_Error Class with argument add_wy = True. Also, the new argument
“estimator” defaults to ‘het’, which is the preferred approach. GM_Combo uses the old
Kelejian-Prucha method from 1998, which does not provide inference for the spatial error
parameter, whereas estimator = ‘het’ does (and estimator = ‘hom’). Unless you use
GM_Combo for a different purpose, GMM_Error with add_wy = True is preferred since
it provides inference.

L.



-- 
Reply all
Reply to author
Forward
0 new messages