[R-sig-Geo] GWR : Confidence intervals on predictions

Roger Bivand Roger.Bivand at nhh.no
Fri Oct 3 21:40:19 CEST 2008

On Fri, 3 Oct 2008, Jean-Paul Kibambe Lubamba wrote:

> Hello everybody,
> I want to obtain confidence intervals on predictions when using gwr. I
> received some matrix algebra to implement to do that, but I need the gwr
> weight matrix and I do not know how to get it. Could anyone help me ?

Which of the n matrices (for n fit points - are your fit points and data 
points identical?) do you want? I think that first you need to find out 
whether you should trust the local betas and the GWR sigma^2 - where the 
latter crucially depends on the assumed effective degrees of freedom. I 
guess this is around p. 55 in the GWR book? My feeling is that until the 
coefficient forcing collinearity is resolved (the strong negative 
correlation between fitted local coefficients), GWR should not be relied 
on to give helpful inferential results.

In this case, it isn't clear whether your fit points are your data points, 
or where the new x values are on the map. If they are at a fit point, you 
could just multiply them through (vector of betas, vector of x) to use 
your fitted betas. I guess one could do what you describe, but I don't 
think it is prudent (also based on having discussed prediction with one of 
the book authors after the book was published).

The method is for detecting non-stationarity to help in reaching a better 
model specification. When the model is well-specified, you may predict 
using standard functions, ones that are well-studied. If a spatial process 
is important for you, given GWR's point support, consider using a kriging 
approach instead, where prediction and prediction uncertainty are 

Sorry to be negative. In the case in which data and fit points are 
identical, I can more or less see how one might call the predict() method 
for lm objects internally on the i-th point using unchanged x values, but 
the n lm fits are not stored, and C varies for each i. Using new x values 
would mean storing the fits - in principle, it could be done, but I don't 
know whether the effort would be worthwhile given the underlying doubts 
surrounding the technique. For example, Danlin Yu has a conference paper 
showing that the local coefficient patterning may be sensitive to the 
distribution of the response, over and above the collinearity demonstrated 
by Wheeler & Tiefelsdorf. Unfortunately, as far as I am aware, the GWR 
authors have not engaged these issues.

Best wishes,


> Thanks in advance for any help !
> JP
> Here is below the matrix operations, using a latex notation:
> The vector of regression coefficients at a given point is
> \beta = (X^TWX)^(-1) X^TWy
> Where the weight matrix W depends on the location of the point,  as usual.
> We can simplify this by writing
> \beta = Cy where C = (X^TWX)^(-1) X^TW
> Then
> Var(\beta) = CC^T \sigma^2 - so far,  this is in the GWR book - including
> how to estimate \sigma^2
> Now if we have a new vector of predictors x at the same point,  then
> predictor of the y-variable is
> x^T \beta
> And so its variance is
> x^T C x \sigma^2
> This gives the variance of the expected y-variable given a set of
> predictors - but this is just the variance of the mean of its
> distribution.  The y-variable itself will be the sum of the predicted mean
> plus an error term with mean zero and variance\sigma^2.
> This has variance
> x^T C x \sigma^2 + \sigma^2
> or
> (x^T C x + 1)\sigma^2
> And so the standard error of the prediction is
> sqrt(x^T C x + 1)\sigma
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list