R: error with jags - r

library(rjags)
library(pcnetmeta)
data(smoke)
set.seed(1234)
hom.eqcor.out <- nma.ab.bin(s.id, t.id, r, n, data = smoke,
param = c("AR"), model = "het_cor", prior.type = "chol", c = 10,
higher.better = TRUE, n.adapt = 5000, n.iter = 100000, n.chains = 2)
I'm using the nma.ab.bin function in pcnetmet. However, I get the following error:
"Error in update.default(jags.m, n.iter = n.burnin) :
need an object with call component"
I've tried playing around with the n.adapt, and n.iter. Using n.adapt = 400 and n.iter = 1000 has no problem. But increasing those values seems to lead to the above error?

Related

Error when running multiscale GWR: Error in gw_weight_vec: Not compatible > with requested type: [type=NULL; target=double]

I am trying to run multiscale geographically weighted regression (MGWR) using the GWmodel package in R. When running the function gwr.multiscale this error is shown:
Error in gw_weight_vec(vdist, bw, kernel, adaptive): Not compatible
with requested type: [type=NULL; target=double].
An example:
library(GWmodel)
data(LondonHP)
dist <- gw.dist(coordinates(londonhp))
ab_gwr <- gwr.multiscale(PURCHASE ~ FLOORSZ + PROF,
data = londonhp,
criterion = "dCVR",
kernel = "gaussian",
adaptive = FALSE,
var.dMat.indx = 2,
bws0 = c(100,
100,
100),
bw.seled = rep(T, 3),
dMats = list(dist,
dist,
dist),
parallel.method = "omp",
parallel.arg = "omp")
I have tried other parameters as well, like adaptive bandwidth, to include fewer covariates, to change the bws0 parameter etc etc. Other kinds of errors occur depending on what I have tried.
I am following the example from the package's PDF.
The parameter var.dMat.indx is defined for the usage of distance matrix for each variable, and was used wrongly in my code. The solution:
library(GWmodel)
data(LondonHP)
dist <- gw.dist(coordinates(londonhp))
ab_gwr <- gwr.multiscale(PURCHASE ~ FLOORSZ + PROF,
data = londonhp,
criterion = "dCVR",
kernel = "gaussian",
adaptive = FALSE,
var.dMat.indx = 1:3,
bws0 = c(100,
100,
100),
bw.seled = rep(TRUE, 3),
dMats = list(dist,
dist,
dist),
parallel.method = "omp",
parallel.arg = "omp")

incorrect number of probabilities in R" ERROR

when using gafs() (feature selection in caret), I always get the error when I apply the following codes to the dataset. My dataset is a large dataset. I don't get this error when I apply only 500 of them. This error comes up when I apply it all.
CODES:
x_chembl_R_gafs_cont <- gafsControl(
functions = rfGA,
method = "cv",
repeats = 5,
number = 5,
verbose = TRUE,
genParallel = TRUE,
allowParallel = TRUE
)
x_chembl_r_gafs <- system.time(
x_chembl_r_result <- gafs(
x = x_chembl_R_tr_data,
y = y_chembl_R_tr_data,
iters = 25,
method = "lm",
gafsControl = x_chembl_R_gafs_cont
)
)
ERROR:
Fold03 1 8875.134 (116)
Error in { : task 1 failed - "incorrect number of probabilities"
How can I solve this problem?

Error in data$update_params(params = params) : [LightGBM] [Fatal] Cannot change max_bin after constructed Dataset handle

I downloaded lightgbm package on RStudio and trying to run a model with it.
The script based on the Retip.
The function is this :
> fit.lightgbm
function (training, testing)
{
train <- as.matrix(training)
test <- as.matrix(testing)
coltrain <- ncol(train)
coltest <- ncol(test)
dtrain <- lightgbm::lgb.Dataset(train[, 2:coltrain], label = train[,
1])
lightgbm::lgb.Dataset.construct(dtrain)
dtest <- lightgbm::lgb.Dataset.create.valid(dtrain, test[,2:coltest], label = test[, 1])
valids <- list(test = dtest)
params <- list(objective = "regression", metric = "rmse")
modelcv <- lightgbm::lgb.cv(params, dtrain, nrounds = 5000,
nfold = 10, valids, verbose = 1, early_stopping_rounds = 1000,
record = TRUE, eval_freq = 1L, stratified = TRUE, max_depth = 4,
max_leaf = 20, max_bin = 50)
best.iter <- modelcv$best_iter
params <- list(objective = "regression_l2", metric = "rmse")
model <- lightgbm::lgb.train(params, dtrain, nrounds = best.iter,
valids, verbose = 0, early_stopping_rounds = 1000, record = TRUE,
eval_freq = 1L, max_depth = 4, max_leaf = 20, max_bin = 50)
print(paste0("End training"))
return(model)
}
However when I'm trying to run the function as in the Retip
lightgbm <- fit.lightgbm(training,testing)
There is this Fatal Error:
Error in data$update_params(params = params) :
[LightGBM] [Fatal] Cannot change max_bin after constructed Dataset handle.
Only when changing max_bin to max_bin=255 there is no error.
Went through documentation:
What is the right way for hyper parameter tuning for LightGBM classification? #1339
[Python] max_bin weird behaviour #1053
Any ideas\suggestions to what should be done?
This was cross-posted to https://github.com/microsoft/LightGBM/issues/4019 and has been answered there.
Construction of the Dataset object in LightGBM handles some important pre-processing steps (see this prior answer) that happen before training, and none of the Dataset parameters can be changed after construction.
Passing max_bin=50 into lgb.Dataset() instead of lgb.cv() / lgb.train() in the original post's code will result in successful training without this error.

ensemble_glmnet: could not find function "predict.cv.glmnet"

I am trying to run the ensemble_glmnet program, but receiving an error that it cannot find predict.cv.glmnet. I have loaded the glmnet and glmnetUtils libraries.
I'm running RStudio 1.2.5033 and R version 3.6.2
library(BuenaVista)
library(glmnet)
library(glmnetUtils)
data<-iris[sample(1:150, size = 150, replace = FALSE),]
data <- derive_variables(dataset=data, type = "dummy", integer = TRUE, return_dataset=TRUE)
data$Species_setosa<-as.factor(data$Species_setosa)
test <-data[101:50,c(1,2,3,4,6,7)]
data<-data[,c(5,1,2,3,4,6,7)]
ensemble_glmnet(y_index = 1, train = data, valid_size = 50, n = 10, alpha = 1, family = "binomial", type = "class")
Error in predict.cv.glmnet(object = cv.glmnet(x = X, y = Y, nfolds =
nfolds, : could not find function "predict.cv.glmnet"

What causes undefined column selected in rfe?

I am using the rfe function in the caret package to do feature selection. I frequently get the following error:
'Error in { :
task 1 failed - "error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': Error in [.data.frame(x, , retained, drop = FALSE) :
undefined columns selected`
I'm doing 100 samples and it runs for about 60 samples or so before producing the error I'm executing the following:
folds=100
validmethod='boot'
subsets=c(5,10,15,20,25)
ctrl <- rfeControl(functions = funcs,
method = validmethod,
rerank=TRUE,
saveDetails=TRUE,
verbose = TRUE,
returnResamp = "all",
number=folds)
rfe(df.preds,df.depend, metric=smetric,sizes=subsets, rfeControl=ctrl)
Can someone help me understand the types of things which would cause this error?
MWE:
df <- cbind(rbinom(100, 1, 0.5), rnorm(100, 0, 1),
rnorm(100, 5, 5), rnorm(100, 12, 4), rnorm(100, 100, 0.1))
colnames(df) <- c("response", "f1", "f2", "f3", "f4")
rfe(x=df[,-1], y=as.factor(df[,1]), sizes = 1:3,
rfeControl = rfeControl(functions = caretFuncs,
number = 2, method = "cv"),method = "svmRadial")
How to choose sizes?

Resources