-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An error occurred while fitting the spatial model: Not yet able to subset general weights lists: SAC SAR LM and lw matrixes #54
Comments
Please add the output of |
R version 4.3.1 (2023-06-16 ucrt) Matrix products: default locale: time zone: Europe/London attached base packages: other attached packages: loaded via a namespace (and not attached): |
Please update |
Updates completed. They have not solved the issue |
In addition to the missing data, the complete analysis is undermined by the next steps:
while the points are in geographical coordinates. Do you really need distances in degrees? 500 degrees is more than once around the Earth. I suggest rather:
in which k=12 is chosen to link the two major goups of points together, using the geographical coordinates properly throughout. The first argument to I wonder also whether you realise that the default |
I've been working on fitting a spatial autoregressive model (sacsarlm) to property price data in Córdoba, Argentina. While the model runs smoothly on smaller datasets, I've encountered an error when using larger samples, specifically when working with a 4K. observations dataset
.Here’s a breakdown of what happened, what I suspect the issue is, and some potential fixes.
The Datasets
For context, I’m working with three versions of the Cordoba dataset:
Cordoba Full Dataset: The complete dataset with all observations.
Cordoba Non-Working Sample (4K observations): A subset that consistently throws an error.
Cordoba Working Sample (1.5K observations): A smaller subset that runs without issues.
Here are the versions: https://drive.google.com/drive/folders/1VoJ-Rbb9uwh68q-lHQajh7qubeD9olAH?usp=sharing
Str of Cordoba
Geometry:
Type: sfc_POINT
Description: Each entry in the dataset is represented by a point geometry, capturing the precise location of properties in Córdoba.
CRS: WGS 84
The Error
The issue arises when I attempt to fit the SACARLM model with the 4K observation subset.
My libraries for this code
This is the spatial model creating a linear regression then applying it into the sacsar creating list weights based on a 0-500 neighbour catchment area and then using the inverse distance to weight the neighbours.
The error appears trying to pass sac <- sacsarlm(model, listw = lw, data = data, zero.policy = TRUE)
The error message I get is:
(Error in subset.listw(listw, subset, zero.policy = zero.policy) :
Not yet able to subset general weights lists
5.stop("Not yet able to subset general weights lists")
4. subset.listw(listw, subset, zero.policy = zero.policy)
3. subset(listw, subset, zero.policy = zero.policy)
2. sacsarlm(model, listw = lw, data = data, zero.policy = TRUE)
1.fit_spatial_model(Cordoba, has_river = TRUE)
The way Cordoba Full becomes subsets is through a bigger dataset from Argentina in the following way.
One can easily make Cordoba_subset with replacing dataset = Argentina with Cordoba.
Key steps
Removed NAs: Filters were added to remove any rows with NA values in pm2, surface_total, and geometry to prevent issues with the spatial model fitting.
Jittering: Applied jitter to the spatial data to prevent infinite values in the weight matrices that could cause problems during spatial regression.
So the following paths are taking for the formulas. First we analyze the location and then we run the regression as:
If anybody could help I would be really thankful
The text was updated successfully, but these errors were encountered: