On Fri, 11 Jun 2010, Pinar Aslantas Bostan wrote:
Dear Roger,
I tried with data frames instead of SPDF. I gave some details of names
and class types of datasets. Grid data has 31204 rows (first row is
column names) and 5 columns (Z,X,Y,V1,V2). Station data has 226 rows
(first row is column names) and 6 columns (PREC,Z,X,Y,V1,V2). I gave an
example about datasets below.
Please do try to read up on what is going on. Find out how variables may
be treated as string not numeric on input, and converted into factors. Do
report str() of the imported objects as I said last time. This will show
if some numeric are really factors - this may happen for example if the
locale thinks that ",", not "." is the decimal sign, or if there is any
non-numeric character in a column. If need be put your data (or a subset
with the same problem on a website and post the link. Please do try to use
lm() and predict() on the lm output object to see whether the problem is
reproduced there too.
Please also be aware that using GWR for prediction has no good basis
anywhere for anything - and the standard errors should not be given any
credibility. This is not what GWR is for at all.
Roger
Grid data
Z X Y V1 V2
495 259725.32564500000 5010656.22353999000 44.15584946 53525.25605680000
621 264725.32564499800 5010656.22353999000 50.67575455 50139.84515760000
432 274725.32564499800 5010656.22353999000 58.62472534 44295.66734330000
418 279725.32564499800 5010656.22353999000 45.05175400 41966.14328090000
361 254725.32564500000 5005656.22353999000 37.61386871 60596.18505359990
Station data
PREC Z X Y V1 V2
514.3522848 1039 410428.05168500000 4478786.07400999000 100.69618225
81321.18533050000
650.6115948 29 942127.25593400000 4409537.10120000000 7.64556551
34796.24442280000
690.1826088 614 1201166.68404000000 4496907.09750000000 39.14785004
212666.95252600000
427.7718516 1213 1080214.69930000000 4550293.99677000000 53.82775879
164788.61213900000
402.9552240 1197 525196.23761299900 4619486.48904000000 69.23021698
206901.35695100000
And from the list Binbin lu send me a message, according to his advice I
don't write "station$" term while performing gwr.sel and gwr functions.
In this way gwr function has worked but gave a warning message. And when
I plot the predicted precipitation values of the grid there are some
negative values which should't be occur! It didn't calculate predicted
errors also.
What do you mean with 'factor' and I don't know how to run the function
under debug.
Thanks for your help.
Pinar
###########################################################################
grid<-read.table("D:\\R\\dem.txt", header=TRUE)
station<-read.table("D:\\R\\station.txt", header=TRUE)
class(grid)
[1] "data.frame"
class(station)
[1] "data.frame"
names(grid)
[1] "Z" "X" "Y" "V1" "V2"
names(station)
[1] "PREC" "Z" "X" "Y" "V1" "V2"
coordinates(station) <- c("X", "Y")
coordinates(grid) <- c("X", "Y")
bw=gwr.sel(PREC~Z+V1+V2,data=station,adapt=T)
gwr <-gwr(PREC~Z+V1+V2,data=station,adapt=bw, fit.points = grid, predict=T,
se.fit=T, hatmatrix=T)
Warning message:
In gwr(PREC ~ Z + V1 + V2, data = station, adapt = bw, fit.points = grid, :
standard errors set to NA, normalised RSS not available
Alinti Roger Bivand <roger.biv...@nhh.no>
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@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.biv...@nhh.no
----------------------------------------------------------------
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.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo