allogamous / EnvRtype

Provide tools for collecting environmental data from GIS-based platforms,enabling environmental characterization studies, providing environmental relatedness kinships and kernels for genomic prediction of reaction norms
24 stars 17 forks source link

Error in { : task 1 failed - "There is no "kernel_model" function." #14

Open kuaileyuandi opened 10 months ago

kuaileyuandi commented 10 months ago

require(foreach) results <-foreach(REP = 1:rep, .combine = "rbind")%:% foreach(MODEL = 1:length(model), .combine = "rbind")%dopar% {

yNA      <- Y
tr       <- TS[[REP]]
yNA$value[-tr] <- NA

Z_E = model.matrix(~0+env,data=yNA) # fixed environmental effects

fit <- kernel_model(data = yNA,y = y,env = env,gid = gid,
                    random = Models[[MODEL]],fixed = Z_E,
                    iterations = iter,burnin = burn,thining = thin)

df<-data.frame(Model = model[MODEL],rep=REP,
               rTr=cor(Y$value[tr ], fit$fitted$yHat[tr ],use = 'complete.obs'),
               rTs=cor(Y$value[-tr], fit$fitted$yHat[-tr],use = 'complete.obs'))

write.table(x = df,file = 'PA_models.txt',sep=',',append = T,row.names=T)
return(df)

}

saveRDS(object = results, file = 'PA_cv1_2' ) require(plyr)

predictive ability

ddply(results,.(Model),summarise, pa = round(mean(rTs),3),sd = round(sd(rTs),4)) Error in { : task 1 failed - "There is no "kernel_model" function."

However, it works fine when only the following code is run REP=1 yNA <- Y tr <- TS[[REP]] yNA$value[-tr] <- NA

Z_E = model.matrix(~0+env,data=yNA) # fixed environmental effects

fit <- kernel_model(data = yNA,y = y,env = env,gid = gid,
                    random = Models[[MODEL]],fixed = Z_E,
                    iterations = iter,burnin = burn,thining = thin)

What is the cause and how can I fix it?