r - Error message while using h2o.deeplearning - r

ERROR MESSAGE:
Illegal argument(s) for DeepLearning model: dl_model_faster.
Details: ERRR on field: _stopping_metric: Stopping metric cannot be misclassification for regression.
I am getting this error but actually I am using h2o.deeplearning for a classification problem, I don't want to run regression model. How can I specify that?

I had the same error for h2o.deeplearning(). Converting the dependent variable to factor and then feeding the data to h2o.deeplearning() fixed it for me.
dataset$dependent_variable= factor(dataset$dependent_variable,levels = c(0, 1), labels = c(0, 1))

Related

glm package glm.nb() "Error: no valid set of coefficients has been found: please supply starting values"

I am running a negative binomial regression on my dataset using the glm.nb() function.
My model looks something like this:
m_nb= glm.nb(Error_Count ~ TotalWL + Auto_frac +PHONE+JUSTIF_weight + MESSAGE_OTHER_count + Hour+
I(Auto_frac^2)+I(TotalWL^2), data = df)
When I ran it with a dataset of 10,000, the model is able to run, however, when I ran it with a larger dataset (60,000), I got this error:
`Error: no valid set of coefficients has been found: please supply starting values`
I then tried to give it some start values, but still throw the same error
m_nb= glm.nb(Error_Count ~ TotalWL + Auto_frac +PHONE+JUSTIF_weight + MESSAGE_OTHER_count + Hour+
I(Auto_frac^2)+I(TotalWL^2), data = df, start = c(0.02, 0.3,0.2,3,43, 4,13,0.04, 100))
Error: cannot find valid starting values: please specify some
But the model still doesn't converge. How should I set the starting value?
I also tried the same model with the fenebin() function in the fixest pacakage and the model works. However, I need the glm package, since the fixest package does not provide the standard error (S.E.) in the predict().
Thank you.

Error in running Logit model clustered by contry code

I am just starting out in R and am trying to run a logit model with clutered country codes. My attempt is to replicate a model from this paper with the following replication information :
Data available here (data file): https://drive.google.com/file/d/1O2Gvf7sqxYN7IsOI2zTRZANlbLnVQvvw/view
*Model 1: base
logit mk l.wtrivalry mkyear mkyear2 mkyear3, cluster(ccode)
*Model 2: Controls -- no conflict
logit mk l.wtrivalry l.lnrgdppc l.polity2 l.exclid l.lnpopWB l.coupdummy mkyear mkyear2 mkyear3, cluster(ccode)
I have been trying variations of code, but keep failing to cluster correctly (unless I do so, the significance of the variables does not align with that of the paper). My attempts have been:
simp.logit.general. <- glm(mk ~ wtrivalry + mkyear + mkyear2 + mkyear3, data = core.data, family="binomial")
summary(simp.logit.general.)
robcov(simp.logit.general)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'arg' should be one of “deviance”, “pearson”, “working”, “response”, “partial”
I have also tried:
coeftest(simp.logit.general, vcov. = vcovCL(simp.logit.general, cluster = core.data$ccode, type = "HC0"))
IF anyone could help with this, I would really appreciate it.

rstanarm - error when running Bayesian model

EDIT - I have managed to resolve this. See my comment below
I am running a Bayesian regression in R using rstanarm using priors I have set, using the following code:
priors <- rstanarm::normal(location = c(-1, 0.5, 2), scale = c(1, 2, 0.5))
bmd <- stan_glm(s01_1 ~ pc + a03 + l01, data=bes19, prior = priors, iter=1000, seed=6942)
This outputs the following error, which I have no idea how to rectify:
Exception: mismatch in dimension declared and found in context; processing stage=data initialization; variable name=prior_scale; position=0; dims declared=(19); dims found=(3) (in '/data/hyperparameters.stan' at line 2; included from 'model_continuous' at line 56)
failed to create the sampler; sampling not done
Error in check_stanfit(stanfit) :
Invalid stanfit object produced please report bug
I would be grateful for any solutions, please. Thank you.

Error Message when plotting ROC of H2O Model Object in R

Trying to plot ROC curve for H2O Model Object in R, however, I keep receiving the following error message:
"Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'"
My code is as follows:
drf1 <- h2o.randomForest(x=x,y=y,training_frame = train,validation_frame = valid, nfolds = nfolds, fold_assignment = "Modulo",keep_cross_validation_predictions = TRUE,seed = 1)
plot((h2o.performance(drf1,valid = T)), type = "roc")
I followed suggestions found here: How to directly plot ROC of h2o model object in R
Any help would be greatly appreciated!
From the error, I think your response variable is not binary. You can change your response variable to factor before putting it into model. i.e.
df$y <- as.factor(df$y)
"ROC is a graphical plot that illustrates the diagnostic ability of a binary classifier system as its discrimination threshold is varied".
source:
ROC wiki

error in R: Error in model.frame.default.... variable lengths differ (no N/As in my data)

I had this this problem with an error message that I don't understand whilst trying to create a binomial mixed effects model, but I didn't have any N/As in my data which I thought this error message meant... can you help? thanks
formula:
bgmodel<-glmer(c(bare,NotBare)~year*treatment*mix+(1|block),data=bareground,family=binomial)
Error in model.frame.default(data = bareground, drop.unused.levels =
TRUE, : variable lengths differ (found for 'year')
The error is in the Model formula, you have to use the function cbind and not c

Resources