

@ Chris:  thanks! I just did spCbind to merge residuals  with my spatial data and the program worked just fine. Thanks :)
Now, how can I add site locations on the plot (like the one Bivand et. al., figure 10.5)?
Milan


________________________________
 From: Chris Fowler <csfowler@psu.edu>

Sent: Thursday, January 10, 2013 6:09 AM
Subject: Re: [R-sig-Geo] Poisson regression spatial residual plot


Milan,
You missed the main point of Edzar's email. You are trying to do a spatial plot on non-spatial data. You need to link the residuals of GLMp to some sort of spatial data. If I recall correctly from an earlier iteration of this email you had loaded some data from wisconsin? Well you need to take the observation id as well as the residuals (Impresid) and join those to your spatial data to make a SpatialPolygonsDataFrame. Once you have done that use the SPDF in place of "data" in spplot and things should come clear.






rote:

Dear all, 
>may be this one is readable.
>I want to plot Poisson regression spatial residual plot, all the codes run but there is a small error  at the end in spplot command, which is shown below. Can someone figure out what is wrong?
>
>##################################
>> GLMp <- glm(Tcrash~X100MVMT+Alcohol+Alignment+PVMT+offset(log(population)), data=data, family="poisson")
>> summary(GLMp)
>
>Call:
>glm(formula = Tcrash ~ X100MVMT + Alcohol + Alignment + PVMT +
>
>    offset(log(population)), family = "poisson", data = data)
>
>Deviance Residuals:
>
>    Min       1Q   Median       3Q     
> Max  
>-19.144   -3.900   -0.500    2.693   24.990
>  
>
>Coefficients:
>              Estimate Std. Error z value Pr(>|z|)    
>(Intercept) -4.456e+00  4.740e-02 -94.012  < 2e-16 ***
>X100MVMT    -5.574e-05  2.457e-06 -22.688  < 2e-16 ***
>Alcohol     -2.378e+00  2.598e-01  -9.153  < 2e-16 ***
>Alignment    2.872e-01  7.207e-02   3.985 6.75e-05 ***
>PVMT         7.467e-01  1.197e-01   6.236 4.48e-10 ***
>---
>Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
>(Dispersion parameter for poisson family taken to be 1)
>
>    Null deviance: 5089.2  on 70  degrees of freedom
>Residual deviance: 3736.1  on 66  degrees of freedom
>
>AIC: 4325.1
>
>Number of
> Fisher Scoring iterations: 4
>
>> lmpresid <- residuals(GLMp, type="deviance")
>> #Display residuals; REMOVE sp.layout=list(TCEpts)
>> spplot(data, "lmpresid",col.regions=grey.colors(9, 0.95, 0.55, 2.2), at=seq(-3,5,length.out=9))
>Error in function (classes, fdef, mtable)  :
>
>  unable to find an inherited method for function "spplot", for signature "data.frame"
>>
>Milan
>        [[alternative HTML version deleted]]
>
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo@r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>


-- 
Christopher S. Fowler PhD.
Assistant Professor
Department of Geography
The Pennsylvania State University
	[[alternative HTML version deleted]]

