INLA problem with slm and spatial eco model

324 views
Skip to first unread message

li...@mail2.sysu.edu.cn

unread,
Jan 31, 2018, 4:42:45 AM1/31/18
to R-inla discussion group

Hello INLA group,

 

Sorry to be a bother.

I am a student. My major is GIS. Presently, I am researching on analyze the influencing factors of a particular crime event (spatial data). I am learning to use spatial eco model in INLA. However, I faced many problems, I also checked a lot of information but can not solve these problems, hoping to get help.


Next is my steps and the problems I faced 

1)     I first tried the linear model (LM and GLM) and lagsarlm and other sp model (spdep packages). the spaeco model result was better than the linear model, with Moran index of the residual  falling from 0.4 to 0.07, rrme from 2k to 1k, We think this conclusion is appropriate

 

2)     Next we tried inla about model=’slm’, but it annoys us very much. When we use the default parameters or small changes or even delete some para setting, always produce a variety of errors on the verbose.

For example we use

zero.variance = list(prec=list(initial = 25, fixed=TRUE))
#SLM model

slm_1<-inla( SMS_all ~ -1 +

              f(idx, model="slm",

                args.slm=list(rho.min = rho.min, rho.max = rho.max, W=W, X=mmatrix,

                              Q.beta=Q.beta),

                hyper=hyper.slm),

            data=inputdata, family="gaussian",

            control.family = list(hyper=zero.variance),

            control.compute=list(dic=TRUE, cpo=TRUE),

            control.inla=list(print.joint.hyper=TRUE, strategy = "gaussian"),

            verbose = TRUE

then we get error

Error in inla.inlaprogram.has.crashed() :
The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully.

the verbose always be

file: smtp-taucs.c  hgid: 3aa3dd2925a9  date: Fri Jan 26 17:55:19 2018 +0300
Function: GMRFLib_factorise_sparse_matrix_TAUCS(), Line: 859, Thread: 0

     Fail to factorize Q. I will try to fix it...


When we give the parameters to a larger changes: initial = -50 and control.inla=list(cmin=-20),

although the results can be obtained, but the results are very very poor and stupid (rho is completely different from larsarlm, Moran index of the residual is much bigger), there also be many message in verbose.

Fail to factorize Q. I will try to fix it...

Although the algorithm is different, but according to the papers as I know, the results of inla and larsarml should not be similar? We have tried the parameters that we know how to change, and we can never get similar result.

 

3)     We also tried inlabma R-packages, basically the same as inla error. If you do not modify the parameters then got error; modify the parameters then got the result is very stupid

 

4)     Our final research goal is to applied the "slm" model to the nbinomial distribution. So we also tried it. Although the results can be obtained, but the results also do not meet expectations. The regression indicator is worse than glm.nb and even larsarlm. However, in our expectation, the result of the regression considering both negative binomial distribution and spatial effect should not be better?


The process is also quite slow, and eventually get crushed... May I ask for any suggestions to tackle these problem?  If anyone can give advice or help give pointers about how th change the parameters, we will be very grateful. We have attached our shpfile(not necessary), Rdata and Rcode, data sms_all as dependent variable, other column as independent variable

The parameters we have tried to change including strategy="", cmin=-100~0, zero.variance=()

 

Sincerely yours,

Li Xuliang

 

input_inla.RData
shpinput.rar
test.R

Virgilio Gómez Rubio

unread,
Jan 31, 2018, 8:26:01 AM1/31/18
to li...@mail2.sysu.edu.cn, R-inla discussion group
Hi,

I have just tried your code and I think that the problem is in the scale of your reponse, that produces some numerical instability. In a nutshell, the range of the response is too wide.

Also, I think that you need to use a Poisson family instead of a Gaussian one because you have counts (i.e., the response variable is an integer). Your code works for me when I set family ="poisson" and I remove the 'zero.variance' setting. But then you cannot compare this model to the ones fitted with the functions in the spdep package.

Alternatively, you can re-scale SMS_all right at the beginning by doing:

#Re-scale SMS_all
BJ$SMS_all <- BJ$SMS_all / max(BJ$SMS_all)

Then you could use (I guess...) a Gaussian family with INLA (with the zero.variance setting) and then you will have results that are comparable to the one obtained with the SLM model in 'slmml'.

Hope this helps.

Virgilio

P.S: I would avoid using expressions such as `it annoys us very much', 'the results are very very poor and stupid' when asking for help about free software made on public forums.


--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
To post to this group, send email to r-inla-discussion-group@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.

li...@mail2.sysu.edu.cn

unread,
Jan 31, 2018, 8:40:56 AM1/31/18
to R-inla discussion group
You are right. Our data is crime count data, so we would like to try to combine the spatial lag model with negative binomial regression (dependent variables are more in line with negative binomial distribution, we have already pass some math test). Because of this, we did not want to normalize the dependent variable in the past, as we thought that may be some missing, but then we will try your suggestion.

it is ture that if we can not compare with the general spatial econometric model, we may not be able to explain that the combination of speco and negative binomial models is better than the result of considering only one of them

However, anyway, we are very grateful for your attention. We read a lot of your papers, gave us a great help to learning in this field.

PS, I am very sorry for my wrong expressions, I just want to express the result does not meet our expectations, the language is not appropriate, I am very sorry, my English is really bad. Hope you can forgive me

在 2018年1月31日星期三 UTC+8下午9:26:01,Virgilio Gómez-Rubio写道:
To post to this group, send email to r-inla-disc...@googlegroups.com.

Virgilio Gómez Rubio

unread,
Jan 31, 2018, 1:49:20 PM1/31/18
to li...@mail2.sysu.edu.cn, R-inla discussion group
Hi there,

2018-01-31 14:40 GMT+01:00 <li...@mail2.sysu.edu.cn>:
You are right. Our data is crime count data, so we would like to try to combine the spatial lag model with negative binomial regression (dependent variables are more in line with negative binomial distribution, we have already pass some math test). Because of this, we did not want to normalize the dependent variable in the past, as we thought that may be some missing, but then we will try your suggestion.

A Poisson distribution with iid random effects may be enough to account to over-dispersion, which is probably why you use a Negative Binomial. I assume that you do not want to use a Gaussian model and that you just used the functions in the sped for convenience. Also, you may test for over dispersion used Dean's Test implemented in the DCluster package.
 

it is ture that if we can not compare with the general spatial econometric model, we may not be able to explain that the combination of speco and negative binomial models is better than the result of considering only one of them

I think that a Poisson model with spatial and iid random effects will be what you need for your model. You can also use other spatial random effects available in INLA. The 'slm' is a option (and I think that it works well) but it is still experimental.

Best,

Virgilio
Reply all
Reply to author
Forward
0 new messages