[R-sig-Geo] local R2
Roger.Bivand at nhh.no
Mon Dec 7 13:31:57 CET 2009
On Mon, 7 Dec 2009, Eda Laze wrote:
> Thank you very much Roger for your helpful answer. It worked pretty well.
> When I run gwr with polygon data I get:
> "Warning message:
> In gwr(formula = AFCCH07HA ~ ALDRO12MEA + ALDRO1MEAN + ALHSETTMEA + :
> data is Spatial* object, ignoring coords argument"
> However, I may provide now two results in one of combinations of variables I
> use. I use the same number of neighbors and variables in both cases,
> the only change is as follows:
> In case one I use longlat =TRUE and in case two I do not write longlat=TRUE.
> case one (longlat=TRUE): local R2 values vary from 0.1651 to 0.5328
> gwr.e pred localR2
> Min. :-465.4243 Min. :-142.267 Min. :0.1651
> 1st Qu.: -17.4693 1st Qu.: 5.429 1st Qu.:0.2461
> Median : -3.2120 Median : 16.735 Median :0.2788
> Mean : 0.3215 Mean : 17.798 Mean :0.2835
> 3rd Qu.: 16.0616 3rd Qu.: 29.726 3rd Qu.:0.3181
> Max. : 321.4507 Max. : 162.569 Max. :0.5328
> Min. :33.40
> 1st Qu.:56.47
> Median :62.22
> Mean :62.32
> Max. :91.10
> case two (without longlat=TRUE): local R2 values vary from 0.06066 to 0.70522
> gwr.e pred localR2
> Min. :-323.5487 Min. :-244.457 Min. :0.06066
> 1st Qu.: -13.4717 1st Qu.: -1.223 1st Qu.:0.32168
> Median : -1.2330 Median : 14.144 Median :0.38511
> Mean : 0.9375 Mean : 17.181 Mean :0.40192
> 3rd Qu.: 9.5695 3rd Qu.: 38.060 3rd Qu.:0.47538
> Max. : 320.2477 Max. : 176.522 Max. :0.70522
> Min. : 36.83
> 1st Qu.: 50.90
> Median : 56.49
> Mean : 57.56
> 3rd Qu.: 62.76
> Max. :120.35
> I thought that adapt=0.01 (number of neighbors) could decide on
> weights. Visualisation of map differs, map two is rather a "surface".
> Does it mean that weights differ from case one to two due to
> the fact that "longlat = TRUE uses distances on the ellipse with WGS84
> parameters" as described in the spgwr manual updated in June 2009.
> The polygon data are projected in:
> Projected Coordinate System: WGS_1984_UTM_Zone_34N.
> I would welcome very much an accurate response, despite my efforts to
> get the answer these days by myself.
Since the data are projected, they are in UTM zone 34, use longlat=FALSE.
As a sanity check, assign the projection to the object:
proj4string(obj) <- CRS("+proj=utm +zone=34 +datum=WGS84")
then inverse project to longlat:
obj_ll <- spTransform(obj, CRS("+proj=longlat +datum=WGS84"))
and rerun the analysis with longlat=TRUE (the bandwidth will be in km not
m), and even do:
writeOGR(obj_ll, "obj.kml", "obj", driver="KML")
for the input object, displaying in Google Earth or similar.
> Thank you in advance
> On Fri, Nov 27, 2009 at 1:12 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>> On Fri, 27 Nov 2009, Eda Laze wrote:
>>> I am currectly using gwr in R to get local R2. I have a shape file -
>>> polygon data.
>>> When I write codes as below: case 1 and 2, I get two different Local
>>> R2 values and maps:
>>> case1.adpt<-gwr(FCHA~PAC1+PAC2+PAC6, data=filename,
>>> coords=cbind(filename$X, filename$Y), adapt= 0.01, longlat=TRUE).
>>> case2.adpt<-gwr(FCHA~PAC1+PAC2+PAC6, data=filename,
>>> coords=cbind(filename$X, filename$Y), adapt= 0.01, hatmatrix = TRUE,
>>> se.fit=TRUE). Local R2 have different values from case 1 and map is
>>> different as well.
>> In the second case, you are not using longlat=TRUE, which will give rather
>> different weights. Please only give examples with available data sets, and
>> include say the first 5 local R2 values, so that helpers know that they are
>> looking at the same thing as you are. Always state the output of
>> Hope this helps,
>>> Furthermore, when I visualize case 1: i.e., local R2 on map, each
>>> polygon has a certain value and responding color while in case 2: map
>>> shows clustering of Local R2 (values) similar to Georgia case study.
>>> However, I wonder why this happen and which is the right way to get
>>> local R2.
>>> I read spgwr manual and update. Though an accurate answer is very welcome.
>>> Thank you.
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>> 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
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
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