- This topic has 6 replies, 5 voices, and was last updated 1 year, 2 months ago by  Nichcha Subdee. Nichcha Subdee.
- 
		AuthorPosts
- 
		
			- 
2024-08-12 at 12:03 am #45240Ching To Chung ParticipantHi. I have downloaded the code from week 4. All parts worked fine except the Exceedance probability section. At line 74, exc1 <- sapply(mod.eco.reg$marginals.fitted.values,FUN = function(marg){1 – inla.pmarginal(q = 1, marginal = marg)}) returned an empty list. This caused the subsequent lines to fail. I have spent a long time attempting to debug but I still don’t know where the problem is. I have not amended the code in any way and it is run as-is after the data directory is properly set. I am sure that all libraries, including INLA and its dependencies such as terra and sf are all properly installed. I am using INLA build 24.06.27. 
- 
2024-08-12 at 10:18 pm #45242 Soe HtikeParticipant Soe HtikeParticipantI’m also stuck with an error message in Exceedence 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 numericI can move on the the later steps, but because of this error, I cannot combine plots in the final step. 
- 
2024-08-13 at 11:40 pm #45244 Pyae Thu TunParticipant Pyae Thu TunParticipantHello friends, 
 I also faced the same error by running the original code and it took me a long time to search for different options online.
 Here comes the solution for me and you can try it too.## showing error after running the code 
 > 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## check the type and structure of exc1 
 > str(exc1_numeric)
 Error: object ‘exc1_numeric’ not found
 ## it seems the variable was not successfully created## check the content of exc1 after the ‘sapply()’ 
 > str(exc1)
 list()
 ## exc1 is empty## check the data of previous object 
 > str(mod.eco.reg$marginals.fitted.values)
 NULL
 ## it was not generated by the model## solution is to add options at the last part of the code 
 ## instead of
 mod.eco.reg <- inla(formula.eco.reg, family=”poisson”,
 data=data.suicides, E=E,
 control.compute=list(dic=TRUE))## use the following 
 mod.eco.reg <- inla(formula.eco.reg, family=”poisson”,
 data = data.suicides, E = E,
 control.compute = list(dic = TRUE, cpo = TRUE, waic = TRUE, return.marginals.predictor = TRUE))
 ## after editing, all the lines running smoothly for me and hope you can solve this too 🙂- 
2024-08-14 at 11:33 am #45249Ching To Chung ParticipantThank you so much! You’re a genius! I have also just noticed that the code generates an incorrect map of the local Moran’s I. I am opening another thread for it. Do you have any ideas why? - 
2024-08-14 at 7:27 pm #45252 Pyae Thu TunParticipant Pyae Thu TunParticipantOh, you’re right, Toby. I missed checking the output file and the saved JPG file shows the same as you . Currently, I am traveling and cannot run the code. Please do let us know when you have solved it. Thanks 👍 
 
- 
- 
2024-08-18 at 2:24 pm #45302 Nichcha SubdeeParticipant Nichcha SubdeeParticipantThank you so much, Pyae! I followed your suggestion and it worked for me as well! ^O^ 
 
- 
- 
2024-08-17 at 1:51 pm #45294 Myat Htoo LinnParticipant Myat Htoo LinnParticipantThanks all bros!! 
 You are life saviours.
 I am also resolved.
 
- 
- 
		AuthorPosts
The topic ‘Week 4: Error in Running “Exceed Probability” Section’ is closed to new replies.

