Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Obtain predictions at new points in geographically weighted regression in r

$
0
0

I have a list of observed points at which I wish to estimate a geographically weighted regression. I then have a separate and distinct set of points at which I want to make a prediction, using this estimated model. This is simulated using this code:

library(spgwr)
library(sp)

set.seed(1)
e <- runif(100,0,1)
n <- runif(100,0,1)
y <- runif(100,0,1)
x1 <- runif(100,0,1)
x2 <- runif(100,0,1)
est.df <- data.frame(cbind(y,x1,x2,e,n))
coordinates(est.df) <- ~ e + n

e < -runif(50,0,1)
n <- runif(50,0,1)
x1 <- runif(50,0,1)
x2 <- runif(50,0,1)
pred.df <- data.frame(cbind(x1,x2,e,n))
coordinates(pred.df) <- ~ e + n

remove(list = c("e","n","y","x1","x2"))

S.gwr <- gwr(y~x1+x2,
           data=est.df,
           coords=cbind(est.df$e, est.df$n),
           bandwidth=0.1,
           predictions = TRUE,
           fit.points=pred.df)

dim(S.gwr$SDF@data)
length(S.gwr$lm$fitted.values)

My problem is that the only fitted values in the S.gwr structure are length 100, and are for the 100 points used to estimate the model, not the 50 points in pred.df for which I want a predicted y_hat. Can anyone help point me to the issue that is not providing me with the 50 predictions from points in pred.df? Thanks.


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>