0

I am trying to pass the cubist model parameters to the quantregForest and using the clusterR function to calculate the cubist model uncertainty. When running the code, I encounter some trouble. I don't know where this problem comes from. Strangely, when running clusterR to compute unc, the code runs successfully with no errors. However, when running clusterR to calculate mean, I get an error:

"Error in clusterR(covs, predict, args = list(model = model, what = mean)) : cluster error". 

So I run the code that computes unc again and get a new error:

"Error in checkForRemoteErrors(lapply(cl, recvResult)): 3 nodes produced errors; first error:`what' needs to be either a function or a vector with quantiles"

These errors occur at the ####ERROR HERE#### marker below,where the code is attempting to run clusterR to calculate sd and mean. How can I rewrite this code? Here is a basic version of my code:

# Load the covariates from the raster *.tif files
files <- list.files(path = "raster", pattern = "tif$",
                full.names = TRUE)

# Stack all the files in one RasterStack
covs <- stack(files)

vali <- read.csv("validation.csv")

library(quantregForest)

model <- quantregForest(y=vali$flux_cubist, x=vali[,4:10])

# Estimate the probability distribution function for each pixel
library(snow)

# Estimate model uncertainty at the pixel level using parallel computing

# Define number of cores to use
beginCluster(n=4)

# Estimate model uncertainty
##### ERROR HERE #####
*unc* <- clusterR(covs, predict, args=list(model=model,what=sd))

# Estimate model predicted mean
##### ERROR HERE #####
*mean* <- clusterR(covs, predict,args=list(model=model, what=mean))

# Express the uncertainty in percent % (divide by the mean)
unc_Percent <- unc/mean*100

endCluster()
Phil
  • 7,287
  • 3
  • 36
  • 66
petrel
  • 1
  • 2

0 Answers0