How to fix 'unused argument' with rasch model in R - r

I'm using the rasch model found in the ltm library and it asks for a constraint as one of it's arguments, i try to define that my constraint is 1 (which i assume means that my discriminant is 1) and when i run the code i get an "unused argument" error which shows the whole constraint.
rasch(dep, constraint = cbind(ncol(dep) + 1, 1))
I've tried moving the argument into a new variable
disc <- cbind(ncol(LSAT) + 1, 1)
which only causes a new error after just one run
cycle k= 1
Error in if (abs(deltab) < convb) { :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(b) : argument is not numeric or logical: returning
NA
2: In if (abs(deltab) < convb) { :
the condition has length > 1 and only the first element will be used

Related

How do I fix a dissimilarities error in an adonis2 test in r?

I've just tried to carry out an adonis2 test using the following code
adonis2(abundance.data~Site, data=df, method="bray") as in a previous post How can I fix an error with adonis2 test?
However I keep getting this error message
Error in if (any(lhs < -TOL)) stop("dissimilarities must be non-negative") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In vegdist(as.matrix(lhs), method = method, ...) :
you have empty rows: their dissimilarities may be
meaningless in method “bray”
2: In vegdist(as.matrix(lhs), method = method, ...) :
missing values in results
Just wondering why this may be and how I can fix this issue

Error with micombine.cor with miceadds

I do not have a reproducible example here but I am hoping to see if the following error is diagnostic of an obvious problem.
Using miceadds, I am running correlations on data that has been imputed with MICE. I receive the following error when a continuous variable ("6") (-0.5 to 1.4) is added to the model.
micombine.cor(imp, variables=c(3:4:5:6))
Above results in the following error
Error in stats::cor(dat_ii, dat_jj, method = method, use =
"pairwise.complete.obs") :
'y' must be numeric
In addition: Warning messages:
1: In 3:4:5 : numerical expression has 2 elements: only the first used
2: In 3:4:5:6 :
numerical expression has 3 elements: only the first used

Error in plotting a C5.0 decision tree in R

I'm trying to plot my decision tree model.
cnt_c50 <- C5.0Control(CF=0.25,minCases=30,sample=0.7)
myTree <- C5.0(Y ~ X1+X2+X3+....+X30, data=data, control= cnt_c50,trials=100)
summary(myTree)
When I run summary(myTree) there is no warning, no error, everything is fine.
But when I want to visualize it : plot(myTree) , I have this error message :
Error in partysplit(varid = as.integer(i), index = index, info = k,
prob = NULL) : minimum of ‘index’ is not equal to 1 In addition:
Warning message: In min(index, na.rm = TRUE) : no non-missing
arguments to min; returning Inf
I tried to define which tree I want to visualize with plot(myTree,trial=9), and it returns this message :
Error in !all.equal(diff(sort(unique(index))), rep(1, max(index, na.rm
= TRUE) - : invalid argument type
When I try with trials=1 instead of trials=100, I have this message :
Error in if (!n.cat[i]) { : missing value where TRUE/FALSE needed
I also tried this because I saw it in a response on this website but it seems to be for CART Trees :
library(rattle)
fancyRpartplot(myTree)
and I have this error :
Error in if (model$method == "class") { : argument is of length zero
I read that it could be due to a lack of values in a category (for example a category with only 1 or 2 people) so I ran without some variables with small categories but it was the same.
I also tried this function http://r-project-thanos.blogspot.fr/2014/09/plot-c50-decision-trees-in-r.html but I am not a good programmer and I had errors too...
Did anyone have the same problem and can help me ?
Thanks a lot

error with predict() with betareg

I used the betareg() function to determine the dynamic of my dependent variables by using a data set with 19083 rows.
M_Beta_F1 <- betareg(Y ~ X1+X2|1, data = data1)
summary(M_Beta_F1)
The fitted values are extracted via:
in_Y <- fitted(M_Beta_F1)
I wanted to determine the predicted values by using a new data set (data2) having 28779 rows.
out_Y_response <- predict.glm(M_Beta_F1, data2, type=c("response"))
I got the following message
Error in seq_len(p) : argument must be coercible to non-negative integer
In addition: Warning messages:
1: In predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == :
calling predict.lm(<fake-lm-object>) ...
2: 'newdata' had 28779 rows but variables found have 19083 rows
3: In model.matrix.default(Terms, m, contrasts.arg = object$contrasts) :
variable 'mean' is absent, its contrast will be ignored
4: In model.matrix.default(Terms, m, contrasts.arg = object$contrasts) :
variable 'precision' is absent, its contrast will be ignored
5: In seq_len(p) : first element used of 'length.out' argument
How can I fix this problem?

Plotting C5.0 Tree in R

I am trying to plot a C5.0 object tree in R but it is giving the following error and I can't seem to find out how to fix it.
plot(model)
Error in partysplit(varid = as.integer(i), index = index, info = k, prob = NULL) :
minimum of ‘index’ is not equal to 1
In addition: Warning message:
In min(index, na.rm = TRUE) :
no non-missing arguments to min; returning Inf
It seems that the factors in your data frame contain spaces. I was facing the same issue, then I removed spaces from them and now it works.
for example, if a variable has factors " bad" and " good" then change them to "bad" and "good".
"The error itself is due to NA values being passed in the index vector. The root cause is probably that the factor levels are being split on spaces" Found here https://github.com/topepo/C5.0/issues/10
try this
library(rattle)
fancyRpartPlot(model)

Resources