sujit-sahu / bmstdr

This is the repository for the R package bmstdr.

Home Page:https://www.sujitsahu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in spTimer model with truncated GPP and validrows

Hallo951 opened this issue · comments

I have unfortunately encountered another error. If you want to create a truncatedGPP spTimer model with a validation you get the following error (see screenshot):

Error in if (length(yval) != nrow(yits)) { : argument is of length zero

image

The error does not occur without a validation for the same model!

image

The named error comes from the function 'calculate_validation_statistics' which is accessed in Bsptime/BspTimer_sptime'. The original error however originates from the fact that further above in the function 'Bsptime/BspTimer_sptime' a reference (op = MCMC samples for the true observations) is accessed which in a truncated GPP model does not exist. The result of this access is NULL! In the following screenshot I have marked the line with the faulty reference.

image

Here still the existing objects in gp_fit.

image

Please fix quickly... ;)

I just took another look at their code. As I said, I have no idea about Bayesian statistics but could the error be a simple typo?

According to the description in the spTimer package, the non-existent variable op stands for the MCMC samples for the true observations within a truncated GP model. The only variable similar to this in the truncated GPP model is the rhop variable, which stands for the MCMC samples for rho for the AR or GPP model. Could this be simply replaced or is rhop something entirely different from op?

Thanks again. Please can you give me code and data to reproduce this error. I will have a look then.

I suggest that you please look at the precipitation modelling example and run the code I have published on my website:
https://www.sujitsahu.com/bookbmstdr/rcode/chap8_rainfall

I have performed validation using the code below:

nItr <- 6000 # number of MCMC samples for each model
nBurn <- 1000 # number of burn-in from the MCMC samples

Select phis

phis <- seq(from=0.01, to=1.5, by=0.03)
k <- length(phis)
u2 <- matrix(NA, nrow=k, ncol=4)
vs <- getvalidrows(sn=sn, tn=tn, valids=c(21), allt=T)
for (i in 1:k) {
cat("i=", i, "to go to", k)
b3 <- Bsptime(data=ds3, formula=f2, package="spTimer", scale.transform ="NONE",
time.data=time.data, prior.phi = "FIXED", prior.phi.param =phis[i],
truncation.para = list(at = 0,lambda =2), validrows=vs,
model="truncatedGP", coordtype="utm", coords=3:4, n.report= 1,
N=nItr, burn.in = nBurn, mchoice = FALSE)
u2[i, ] <- unlist(b3$stats)
}
phiselect <- cbind.data.frame(phis=phis, u2)

I tried your example and it works for me but your example is a model with truncatedGP and not with truncatedGPP! The error I pointed out refers only to the truncatedGPP model. If you test the same example with a truncatedGPP distribution and different nodes, you will see the error.

As I wrote before, a truncatedGPP model from the spTimer package does not have the variable "op" which you want to access to validate the truncatedGPP model.

Please test again your example with a truncatedGPP distribution...

Okay, thanks for finding the source of the problem. I am not yet sure how best to resolve this. I tried to reconstruct the op values for truncatedGPP but I could not. In the next version will try to find a solution or disable this modelling option. But that would require time for me.

May I suggest that you please contact the spTimer maintainer Prof Shuvo Bakar for spTimer issues as well. We may find a better/quicker solution that way.