An HTML attachment was scrubbed... URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190222/bcc18b4d/attachment.html>
Geographically weighted regression
4 messages · i-c-b m@iii@g oii web@de, Sarah Goslee, bi@bi@iu m@iii@g oii whu@edu@c@ +1 more
The first step should be to look at str(Daten90) str(Daten10) and if that doesn't solve the problem, then consider a reproducible example, or at the very least posting the results of the above to this list. Sarah
On Fri, Feb 22, 2019 at 7:38 AM <f-c-b at web.de> wrote:
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Sarah Goslee (she/her) http://www.numberwright.com
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. Binbin Dr Binbin Lu Lecturer in School of Remote Sensing and Information Engineering, Wuhan University Email: binbinlu at 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
On Sat, 23 Feb 2019, binbinlu at 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 at 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 at 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 at nhh.no https://orcid.org/0000-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en