[R-sig-Geo] Forcing GWR to the origin
Nicholas N Nagle
Nicholas.Nagle at Colorado.EDU
Mon Jun 1 18:55:45 CEST 2009
Jean-Paul-
I am not sure why you would want to force the intercept to 0, unless perhaps you can explain near 100% of the variance. If there is any error, then leaving out an intercept forces the expected error to be zero. I don't know what is in the error term in your model, but why should it have exactly mean zero?
But, moving forward...
I don't know if gwr can do this, but you should be able to get the same effect with the gam function in the mgcv package.
If the linear model you want is:
datalm<- lm(y~x1 + x2 -1, data=data)
Then the gam model would be something like:
library(mgcv)
datagam <- gam(y~s(x,y)*x1+s(x,y)*x2,data=data,family='gaussian')
where x,y are spatial coordinates
The smooth terms are the spatially-varying coeffients, and, with a little effort, they can be mapped just as in gwr.
The model with intercept is
datagam2 <- gam(y~s(x,y)+s(x,y)*x1+s(x,y)*x2,data=data,family='gaussian')
One additional advantage of gam over gwr is that you have the flexibility to let some coefficients be spatially varying and others be fixed: for example
datagam3 <- gam(y~s(x,y)+x1+s(x,y)*x2,data=data,family='gaussian')
Hope this helps.
Nicholas
Nicholas N. Nagle, Assistant Professor
University of Colorado
Department of Geography
UCB 260, Guggenheim 110
Boulder, CO 80309-0260
phone: 303-492-4794
---- Original message ----
>Date: Mon, 01 Jun 2009 12:00:04 +0200
>From: r-sig-geo-bounces at stat.math.ethz.ch (on behalf of r-sig-geo-request at stat.math.ethz.ch)
>Subject: R-sig-Geo Digest, Vol 70, Issue 1
>To: r-sig-geo at stat.math.ethz.ch
>
>Send R-sig-Geo mailing list submissions to
> r-sig-geo at stat.math.ethz.ch
>
>To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>or, via email, send a message with subject or body 'help' to
> r-sig-geo-request at stat.math.ethz.ch
>
>You can reach the person managing the list at
> r-sig-geo-owner at stat.math.ethz.ch
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of R-sig-Geo digest..."
>
>
>Today's Topics:
>
> 1. Forcing GWR to the origin (Jean-Paul Kibambe Lubamba)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Mon, 1 Jun 2009 11:16:45 +0200 (CEST)
>From: "Jean-Paul Kibambe Lubamba" <jean-paul.kibambe at uclouvain.be>
>Subject: [R-sig-Geo] Forcing GWR to the origin
>To: r-sig-geo at stat.math.ethz.ch
>Message-ID:
> <e3b95ebcb3e3f766e00a9b83fc3afdbe.squirrel at mmp.sipr-dc.ucl.ac.be>
>Content-Type: text/plain;charset=iso-8859-1
>
>Hi all,
>
>I am running the following which is meaningfull for my purposes than an
>OLS with Intercept and gives me better results:
>
>datalm<- lm(y~x1 + x2 + x3 + x4 -1, data=data)
>
>I know wonder if I can run a gwr of the model above, forcing the Intercept
>coefficients to be zero at all locations. That is to say:
>
>data.bw <- gwr.sel(y ~ x1 + x2 + x3 + x4 -1 , data=data,
>coords=cbind(data$x, data$y))
>
>data.gwr <- gwr(y ~ x1 + x2 + x3 + x4 -1, data=data, coords=cbind(data$x,
>data$y), bandwidth=data.bw, longlat=FALSE, hatmatrix=TRUE)
>
>Does GWR still meaningfull when it ran with 0 as the Intercept?
>
>Any comment is welcome and thanks in advance!
>
>
>Jean-Paul Kibambe
>
>
>
>------------------------------
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo at stat.math.ethz.ch
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>End of R-sig-Geo Digest, Vol 70, Issue 1
>****************************************
More information about the R-sig-Geo
mailing list