- This topic has 6 replies, 3 voices, and was last updated 1 year, 3 months ago by Chawarat Rotejanaprasert.
-
AuthorPosts
-
-
2023-08-25 at 2:15 pm #41554Boonyarat KanjanapongpornParticipant
Hello everyone,
I am not sure if others have experienced the same results after running R code for week 4.
I had to add some code to the original R downloaded file to get some of the results.First, mod.eco.reg$marginals.fitted.values returned NA.
Therefore, I added control.compute=list(return.marginals.predictor=TRUE) and control.predictor=list(compute=TRUE) into inla() to compute mod.eco.reg$marginals.fitted.values.Secondly, calculating the local moran’s I.
I set alternative argument to “greater” instead of using the default value to generate quite similar Local Moran’s I map in the lecture.Are there others that have experienced the same or is it because of my R version?
-
2023-08-27 at 1:47 pm #41571Chawarat RotejanaprasertKeymaster
Hi class,
I would like to note that calculating fitted values in INLA can be approached differently based on the specific context. Departing from the class example, you might find it beneficial to explore the utilization of the ‘summary.fixed’ command, which offers an alternative method to determine the fitted values of relative risks. In regard to Moran’s I, both the default ‘equal’ hypothesis and the ‘greater’ hypothesis are valid options, as long as you explain your findings effectively to correspond with the selected approach. Please let me know if you have any questions!
-
2023-09-03 at 3:03 pm #41629Boonyarat KanjanapongpornParticipant
Thanks for the comment ka Ajarn.
-
-
2023-09-03 at 12:59 pm #41627Tippa WongstitwilairoongParticipant
Dear Aj, and Boonyarat,
When I run R code, I found problen in exceedance probability part:
> #####################################################
> # Exceedance probability
> #####################################################
> exc1 <- sapply(mod.eco.reg$marginals.fitted.values,FUN = function(marg){1 – inla.pmarginal(q = 1, marginal = marg)})
> summary(exc1)
Length Class Mode
0 list list
> exc1.cutoff <- c(0, 0.8, 0.9, 0.95, 1)
> cat.exc1<- cut(unlist(exc1),breaks=exc1.cutoff,include.lowest=TRUE)
Error in cut.default(unlist(exc1), breaks = exc1.cutoff, include.lowest = TRUE) :
‘x’ must be numeric
> maps.cat.exc1 <- data.frame(ID=data.suicides$ID, cat.exc1=cat.exc1)
Error in data.frame(ID = data.suicides$ID, cat.exc1 = cat.exc1) :
object ‘cat.exc1’ not found
> data.boroughs <- attr(london.gen, “data”)
> attr(london.gen, “data”) <- merge(data.boroughs, maps.cat.exc1, by=”ID”)
Error in h(simpleError(msg, call)) :
error in evaluating the argument ‘y’ in selecting a method for function ‘merge’: object ‘maps.cat.exc1’ not found
> #spplot(obj=london.gen, zcol= “cat.exc1″, main=list(label=”Exceedance”,cex=1), col.regions=gray(seq(0.9,0.1,length=4)))Then I run continue but in last lain after combine plots: it show “Error in
[.data.frame
(obj@data, zcol) : undefined columns selected”So, It isn’t showed plots. How to solve this problem?
-
2023-09-03 at 3:01 pm #41628Boonyarat KanjanapongpornParticipant
Dear, K.Tippa.
Yours ‘exc1’ has no data inside.
> summary(exc1)
Length Class Mode
0 list listIf it was the same issue which the ‘exc1’ contains no data from the NA of mod.eco.reg$marginals.fitted.values.
I did added control.compute=list(return.marginals.predictor=TRUE) and control.predictor=list(compute=TRUE) into inla() function.
(under Model with covariates section, what i did is in the photo below)
Because by default,mod.eco.reg$marginals.fitted.values wouldn’t be produced without the command.Hope it work for yours.
-
-
2023-09-03 at 4:03 pm #41630Tippa WongstitwilairoongParticipant
Dear Khun Boonyarat,
Thanks to your guidance, the code is now operating flawlessly. I spent two days searching the internet for a solution to no avail, and prior to this, I had no prior experience with R, and I encountered numerous difficulties while using it in this class when original code isn’t working. Once again, I want to extend my heartfelt thanks. If you hadn’t shared the code in the picture, I would have been unable to resolve these issues. You’ve made a positive difference in my life. 🙂 🙂
Dear Aj,
During the class presentation in web, I noticed that your code remained identical to the original version, yet it did not produce any errors and ran smoothly. Could you please explain why this is the case?
-
2023-09-03 at 9:05 pm #41633Chawarat RotejanaprasertKeymaster
Hello TMHG 517 class…
It’s truly great to see the collaboration and support you’re providing to one another during this course. I hope that these connections will continue to thrive beyond the classroom.
Regarding the recent change in the INLA system, there is a recent change internally within INLA. Specifically, the marginals of the linear predictors, which typically demand a significant amount of storage space, are now omitted by default. Though these marginals are no longer displayed, they are still computed internally. Fortunately, this change doesn’t impact the accessibility or functionality of the summary statistics.
I’d also like to acknowledge the resourcefulness demonstrated by Boonyarat in finding a method to obtain the outcome/risk estimates. Your collective efforts reflect the collaborative spirit of our TMHG 517 class this year. Well done, everyone!
Keep up the excellent work! Cheers! 😀
-
-
AuthorPosts
You must be logged in to reply to this topic. Login here