[R-sig-Geo] Base correlation larger than alpha (ME - Spdep package
Roger Bivand
Roger.Bivand at nhh.no
Tue Jun 11 10:47:06 CEST 2013
On Tue, 11 Jun 2013, Rodrigo Tardin wrote:
> Hello Roger,
>
> Thanks a lot for your help. I fit a model as you said but with a binomial
> response and I did ok! However, in ME model, I had to increase the alpha
> value to 0.5.
You can only use SpatialFiltering when you could use lm(), not glm() to
fit the model, its results are only valid in that case. If your response
is binomial, only the results of ME are valid. In addition, only ME()
handles the offset correctly as far as I know. Do not use SpatialFiltering
when themodel cannot not be fitted with lm().
Roger
>
> Is it bad to have such a "high" alpha value?
>
>
> The results for ME and Spatial Filtering models were a little bit different:
> anova(glmerr12,test="Chisq")
>
> Analysis of Deviance Table
>
> Model: binomial, link: logit
>
> Response: OCC_BIN
>
> Terms added sequentially (first to last)
>
>
> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
> NULL 81 984.43
> DEPTH 1 322.27 80 662.17 <2e-16 ***
> DISTCOAST 1 114.42 79 547.74 <2e-16 ***
> SLOPE 1 0.00 78 2739.32 1
> fitted(errcol2) 1 360.44 77 2378.88 <2e-16 ***
>
>
> anova(glmerr1,test="Chisq")
> Analysis of Deviance Table
>
> Model: gaussian, link: identity
>
> Response: OCC_BIN
>
> Terms added sequentially (first to last)
>
>
> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
> NULL 81 20189
> DEPTH 1 1916.3 80 18272 0.0006276 ***
> DISTCOAST 1 5093.0 79 13179 2.484e-08 ***
> SLOPE 1 557.4 78 12622 0.0651683 .
> fitted(errcol1) 1 1.7 77 12620 0.9180173
> ---
> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
> Both models showed significant relationship with DEPTH and DISTANCE TO
> COAST and not with SLOPE. However, one model was significant for fitted
> spatial autocorrelation (ME model) and the other did not.
>
>
> When I tried to compare the results via anova (as done in spdep manual -
> pag.118) for these binomial models, I could not obtain the p level. My code:
> ##Anova comparing both models
> anova(glmerr12,glmerr1,test="Chisq")
> Analysis of Deviance Table
>
> Model 1: OCC_BIN ~ DEPTH + DISTCOAST + SLOPE + fitted(errcol2)
> Model 2: OCC_BIN ~ DEPTH + DISTCOAST + SLOPE + fitted(errcol1)
> Resid. Df Resid. Dev Df Deviance Pr(>Chi)
> 1 77 2378.9
> 2 77 12620.3 0 -10241
>
> ##glmerr 12 is the ME model
> ##glmerr1 is the Spatial Filtering model
>
>
> Can you help me (or others in this list) one more time?
>
> Once again thanks a lot for everyone who can help me here.
>
> Rodrigo
>
>
> 2013/6/10 Roger Bivand <Roger.Bivand at nhh.no>
>
>> On Mon, 10 Jun 2013, Rodrigo Tardin wrote:
>>
>> Dear list,
>>>
>>> I am new to this list and I am trying to fit a Spatial Eigenvector GLM to
>>> count data.
>>>
>>> I am trying to fit a ME model in spdep package to investigate
>>> environmental
>>> drivers on Bryde's whale distribution. I have 3 environmental variables
>>> (depth, distance to coast, slope), my response variable is the occurrence
>>> (counts) of whales in 82 km2 grids.
>>>
>>> I used the dnearneigh function to build .nb data using the coordinates
>>> data.
>>>
>>>> nb1 <- dnearneigh(xy, 0, 10) ----
>>>>
>>> and: lw1 <- nb2listw(nb1, style="W")
>>>
>>> x - is latitude coordinates
>>> y - is longitude coordinates
>>>
>>>
>>> Using the glm and Spatial filtering function (as done in spdep manual) I
>>> had no problems. However, when I used the 'ME' it says: base correlation
>>> larger than alpha. My alpha is 0.05.
>>>
>>> Here it is my code:
>>> ##This part works well
>>> glmbase1 <- glm(OCC ~ DEPTH + DISTCOAST+SLOPE, offset=RT,
>>> data=bryde3)
>>>
>>> lagcol1 <- SpatialFiltering(OCC_BIN ~ 1, ~ DEPTH + DISTCOAST+
>>> SLOPE, data=bryde3, style="W", nb=nb1, alpha=0.05, verbose=TRUE)
>>>
>>> glmlag1 <- glm(OCC ~ DEPTH + DISTCOAST+SLOPE + fitted(lagcol1),
>>> offset=RT,data=bryde3)
>>>
>>
>> These are not the same models - lagcol1 is as you know the process in the
>> response (here OCC - RT??), not in the error. In ME, the process is in the
>> error, and it looks as though the covariates mop up much of the spatial
>> dependence (it is also a Poisson model with a default log link).
>> SpatialFiltering() does not handle an offset (as you have realised, I
>> think), so again, this is a possible source of difference. ME is testing
>> slightly diffferently too. Do:
>>
>> errcol1 <- SpatialFiltering(I(OCC-RT) ~ DEPTH + DISTCOAST +
>>
>> SLOPE, data=bryde3, style="W", nb=nb1, alpha=0.05, verbose=TRUE)
>> glmerr1 <- glm(OCC ~ DEPTH + DISTCOAST+SLOPE + fitted(errcol1),
>> offset=RT, data=bryde3)
>>
>> and
>>
>> errcol2 <- ME(OCC ~ DEPTH + DISTCOAST+SLOPE, offset=RT, data=bryde3,
>> family="gaussian", listw=lw1, alpha=0.05, verbose=TRUE)
>> glmerr12 <- glm(OCC ~ DEPTH + DISTCOAST+SLOPE + fitted(errcol2),
>> offset=RT, data=bryde3)
>>
>> give similar results?
>>
>> Hope this helps,
>>
>> Roger
>>
>>
>>
>>
>>
>>> anova(glmlag1)
>>> anova(glmbase1, glmlag1)
>>> set.seed(123)
>>>
>>> ##From here on, it does not
>>> lagcol1 <- ME(OCC ~ DEPTH + DISTCOAST+SLOPE, offset=RT, data=bryde3,
>>> family="poisson",
>>> listw=lw1, alpha=0.05, verbose=TRUE)
>>>
>>> Error in ME(OCC ~ DEPTH + DISTCOAST + SLOPE, data = bryde3, family =
>>> "poisson", :
>>> base correlation larger than alpha
>>>
>>> When I increase alpha to 0.6 (lower values keep saying the same error),
>>> this error message does not appear. However, when I try to rerun GLM with
>>> eigenvectors included as covariates (as done in spdep manual - page 118) I
>>> have the following error message:
>>>
>>> Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, :
>>> NA/NaN/Inf in 'x'
>>> warning message: step size truncated due to divergence
>>>
>>> Can anyone please help me?
>>> Other question, if I may, is there a strong difference between Spatial
>>> Filtering and ME?
>>>
>>> Many thanks in advance,
>>> Rodrigo
>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, NHH Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 95 43
>> e-mail: Roger.Bivand at nhh.no
>>
>>
>
>
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list