[R-sig-Geo] Geographically weighted regression

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Sat Feb 23 12:18:38 CET 2019


On Sat, 23 Feb 2019, binbinlu using whu.edu.cn wrote:

> Hi,

> The formula is wrongly specified, Ziel~ as.factor(Var1) + log(Var2, base 
> = exp(1)) + Var3, use the corresponding var-names only.
>
> As I understand, you want to do some calculations with the variables, 
> and you can process them in the data frame before using it in this 
> command, not in the formula.

Correct, not in the formula in the way that these functions handle the 
names made by formula() and model.matrix(). lm() and its prediction 
function do seem to handle them correctly, but it is very hard in more 
complicated fitting/prediction functions to get this right. Pre-compute 
the modified variables so that the package functions just see simple 
variables.

Roger

>
> Binbin
>
>
>
>
> Dr Binbin Lu
> Lecturer in School of Remote Sensing and Information Engineering, Wuhan University
> Email: binbinlu using whu.edu.cn
>
> From: f-c-b
> Date: 2019-02-22 20:37
> To: r-sig-geo
> Subject: [R-sig-Geo] Geographically weighted regression
> Dear all,
>
> I am currently working out a geographically weighted regression, in which 90% of the data set the model should be calculated and for 10% of the values to be predicted. For the prediction I use the function gwr.predict from the package GWModel:
>
> Erg<-gwr.predict(formula=Ziel~ as.factor(Var1) + log(Var2, base = exp(1)) + Var3, data = Daten90,predictdata = Daten10,bw = bwG, kernel = "gaussian",adaptive = FALSE, p = 2, theta = 0, longlat = FALSE)
>
> I always get this error, although Daten10 and Daten90 have the same structure:
> Error in gwr.predict(formula = Ziel~ as.factor(Var1) + log(Var2, base = exp(1)) + Var3, :
> All the independent variables should be included in the predictdata.
>
> Can you tell me what the problem with this code is?
> Or is there any other way for a GWR and the prediction?
>
> Thank you,
> Christoph
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



More information about the R-sig-Geo mailing list