Hello all, I am wondering if there is a way to do a spatial error probit/logit model in R? I can't seem to find it in any of the packages. I can do it in MATLAB with Gibbs sampling, but would like to confirm the results. Ideally I would like to use this model to predict probability of parcel conversion in a future time period. This seems especially difficult in a binary outcome model setting. Does anyone have any guidance on this aspect? Thanks. Robb
Hi Robb, the gamboost() function in package `mboost' may help. The details are described in @article{Kneib+Hothorn+Tutz:2009, author = {Thomas Kneib and Torsten Hothorn and Gerhard Tutz}, title = {Variable Selection and Model Choice in Geoadditive Regression Models}, journal = {Biometrics}, year = {2009}, note = {Accepted} } (preprint available from http://epub.ub.uni-muenchen.de/2063/) Best wishes, Torsten
Freeman, Robert <rfreeman <at> emcc.edu> writes:> I am wondering if there is a way to do a spatial error probit/logit > model in R? I can't seem to find it in any of > the packages. I can do it in MATLAB with Gibbs sampling, but would > like to confirm the results. Ideally I > would like to use this model to predict probability of parcel > conversion in a future time period. This > seems especially difficult in a binary outcome model setting.There are no such functions (as far as I know) in any package on CRAN for a spatial weights matrix based approach based say on contiguities. You could consider asking on the R-sig-geo list, and/or reviewing http://leg.ufpr.br/Rcitrus/, which may prove helpful (especially if you know Portuguese). Roger
Stefan Uhmann
2008-Aug-20 11:36 UTC
[R] centroid of radial.plot differs from centroid.polygon
Dear R-Helpers, I need the centroid of circular data and (because the function used does not provide the centroid coordinates, or did I miss sth.?) tried it via the indirect way and just computed the cartesian coordinates: >>> library(plotrix) library(maps) #generate data data1<-matrix(c(1.8,1.5,1.2,0.9,0.0,-0.9,-0.6,0.3)+1.2,nrow=1) #radial plot radial.plot(data1,labels=paste("Dim",1:8,sep=""),rp.type="s", main="test",show.grid=TRUE, radial.lim=c(0,3.5), show.centroid=TRUE, clockwise=T) #compute cartesian coordinates deg1<-seq(from=0,to=7,by=1)*pi/4 x=(data1)*cos(2*pi-deg1) y=(data1)*sin(2*pi-deg1) #print cartesian points (of polygon) points(x,y,pch=18) #print cartesian centroid points(matrix(centroid.polygon(cbind(as.vector(x),as.vector(y))), nrow=1), pch=17) >>> My problem is, that the centroid computed by the radial.plot-function (big unfilled circle) is somewhat different from the one computed 'by hand' using cartesian coordiantes and centroid.polygon (small triangle). I would really appreciate any suggestions how to obtain the correct centroid and what is wrong here. Thanks, Stefan
Stefan Uhmann
2008-Aug-21 07:39 UTC
[R] centroid of radial.plot differs from centroid.polygon
Jim Lemon schrieb:> On Wed, 2008-08-20 at 13:36 +0200, Stefan Uhmann wrote: >> Dear R-Helpers, >> >> I need the centroid of circular data and (because the function used does >> not provide the centroid coordinates, or did I miss sth.?) tried it via >> the indirect way and just computed the cartesian coordinates: >> >> >>> >> library(plotrix) >> library(maps) >> >> #generate data >> data1<-matrix(c(1.8,1.5,1.2,0.9,0.0,-0.9,-0.6,0.3)+1.2,nrow=1) >> #radial plot >> radial.plot(data1,labels=paste("Dim",1:8,sep=""),rp.type="s", >> main="test",show.grid=TRUE, radial.lim=c(0,3.5), show.centroid=TRUE, >> clockwise=T) >> #compute cartesian coordinates >> deg1<-seq(from=0,to=7,by=1)*pi/4 >> x=(data1)*cos(2*pi-deg1) >> y=(data1)*sin(2*pi-deg1) >> #print cartesian points (of polygon) >> points(x,y,pch=18) >> #print cartesian centroid >> points(matrix(centroid.polygon(cbind(as.vector(x),as.vector(y))), >> nrow=1), pch=17) >> >>> >> >> My problem is, that the centroid computed by the radial.plot-function >> (big unfilled circle) is somewhat different from the one computed 'by >> hand' using cartesian coordiantes and centroid.polygon (small triangle). >> I would really appreciate any suggestions how to obtain the correct >> centroid and what is wrong here. >> > Hi Stefan, > The radial.plot function just takes the mean of the x and y positions > for the centroid (see line 119). If this is incorrect, I would greatly > appreciate a pointer to the correct function for this so that I can > modify the code. > > Jim >Dear Jim, first of all, great work! The radial.plot function was the best and most flexible one for me and my purposes. I'm not into maths, but to me it appears that the centroid of a polygon is sth. complicated - my only source is wikipedia, btw. - and not just the mean of the x- and y-coordinates. A short glance brought up the result, that various math packs (matlab, maple) have functions to compute the centroid of a polygon. But I have to admit that I can not be of any further help - the formulas found in wikipedia are greek for me. However, it would be great if you could implement the centroid - and maybe even let the function give it back - and just rename the current function to sth. else. /Stefan