[R-sig-Geo] GWR Analysis
Roger Bivand
Roger.Bivand at nhh.no
Mon Jun 21 18:14:11 CEST 2010
On Mon, 21 Jun 2010, Pinar Aslantas Bostan wrote:
> Dear Roger,
>
> Maybe you can remember, last week I asked some questions about gwr analysis
> and you helped me. In order to make refresh, I want to summarize my problem.
> I am trying to make gwr analysis to predict precipitation distribution on a
> DEM. I have two datasets; first one is 'station' consists of 225 prec.
> measurements and 3 independent variables (Z, V1, V2). The second one is 'DEM'
> dataset which has 31203 # of pixels. Firstly I tried with using SPDF
> (SpatialPointsDataFrame) and obtained predicted precipitations on DEM. But
> when I plot the predicted precipitation values, I saw a lot of negative
> values which is impossible to get such a values.
No, this is just a weighted linear model. Unless you limit it by design,
all such linear models will happily predict out of domain. Consider how
you might by design limit the response to non-negative values.
> I thought that this was
> caused because I used point data sets (SPDF) for grid.
Why would you think that? All you need to provoke this is a slightly
unfortunate placing of the met stations (all in west and falling trend
eastwards beyond the observed stations). Did the regular lm() fit also
predict negative values (very likely yes).
This isn't a GWR problem, it's more general. Fix it for lm() first.
Roger
> Then I tried with
> using SGDF (SpatialGridDataFrame). At this time, gwr() resulted with an error
> message "new data matrix rows mismatch". You told me that 'The error message
> is generated when the number of columns in the matrix of X variables is not
> the same in data and and fit.points.' I gave some information about datasets
> below.
>
>> class(station)
> [1] "SpatialPointsDataFrame"
> attr(,"package")
> [1] "sp"
>> names(station)
> [1] "PREC" "Z" "V1" "V2"
>> class(dem)
> [1] "SpatialGridDataFrame"
> attr(,"package")
> [1] "sp"
>> names(dem)
> [1] "Z" "V1" "V2"
>
> 'PREC' is the observations and I want to get predictions of them on 'dem'.
>
> I checked the str() and variables are stored in the same way.
>
>> bw=gwr.sel(PREC~Z+V1+V2,data=station,adapt=T)
>> xx1<-gwr(PREC~Z+V1+V2,station,adapt=bw,hatmatrix=TRUE)
>> x1 <-gwr(PREC~Z+V1+V2,data=station,adapt=bw, fit.points = dem, predict=T,
>> se.fit=T, fittedGWRobject=xx1)
> Error in gwr(PREC ~ Z + V1 + V2, data = station, adapt = bw, fit.points =
> dem, :
> new data matrix rows mismatch
>
>
> If I wrote 'predict=F' then gwr() works but gives only sum.w, coefficients
> and localR2.
>
> I tried to run gwr() under debug but I didn't understand the output.
>
> I really don't understand the problem and need help.
>
> Best regards,
> Pinar
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
--
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