[R-sig-Geo] GWR Analysis

Roger Bivand Roger.Bivand at nhh.no
Fri Jun 11 14:00:48 CEST 2010


On Fri, 11 Jun 2010, Pinar Aslantas Bostan wrote:

>
>
> Dear all,
>
> I want to make GWR analysis to predict precipitation distribution 
> measured from 225 meteorological stations. I have three independent 
> variables (Z, V1, V2). I want to obtain predictions on the grid dataset 
> which has 31203 number of pixels. I gave some details about my datasets 
> below. While performing GWR, I get error message: "new data matrix rows 
> mismatch"
>
> How can I solve that problem?

You need to provide the detailed output of traceback(), and probably also 
run gwr() under debug() to see whether this is a data problem or a code 
problem. Does gwr() work when predict=FALSE, and/or predict=TRUE, 
se.fit=FALSE? 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. Are 
the variables in both cases stored in the same way? What do 
str(station.grid) and str(station) look like before conversion to SPDF and 
after? Is one variable a factor in one and numeric in the other? Running 
under debug() will let you check what x and predx look like.

If this sounds hard, consider putting your data on a website and posting 
the link.

Hope this helps,

Roger

>
> Thanks, Pinar.
>
> station.grid<-read.table("D:\\R\\dem.txt", header=TRUE)
> station<-read.table("D:\\R\\station.txt", header=TRUE)
>
> grid = SpatialPointsDataFrame(data=station.grid, 
> coords=cbind(station.grid$X, station.grid$Y))

> station = SpatialPointsDataFrame(data=station, coords=cbind(station$X,station$Y))
>
>> names(grid)
> [1] "Z" "X" "Y" "V1" "V2"
>> names(station)
> [1] "PREC" "Z" "X" "Y" "V1" "V2"
>
> bw=gwr.sel(PREC~station$Z+station$V1+station$V2,data=station,adapt=T)

> gwr <-gwr(PREC ~ station$Z + 
station$V1 + station$V2, data=station, adapt=bw, 
fit.points = grid, predict=TRUE, se.fit=T)
>
> Error in gwr(PREC ~ station$Z + station$V1 + station$V2, data = station, :
> NEW DATA MATRiX ROWS MiSMATCH
>
> ----------------------------------------------------------------
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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