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
Related
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
Hi, i have 2 categorical variables and i was told to perform t-test between these 2.
so i key in my R code as
> t.test(BPMeds ~ TenYearCHD, data=data_no_na)
And i am getting a error
Error in var(x) : Calling var(x) on a factor x is defunct. Use
something like 'all(duplicated(x)[-1L])' to test for a constant
vector. In addition: Warning message: In mean.default(x) : argument is
not numeric or logical: returning NA
I was told to Print out my results for t, p-values and mean for this group
T_T
anyone can help?
I was about test the coefficients with lht command in the following model:
fashion.lm<-lm(LOGS~D2+D3+D4+I(D1*LOGA)+I(D2*LOGA)+I(D3*LOGA)+I(D4*LOGA)+I(D1*LOGC)+I(D2*LOGC)+I(D3*LOGC)+I(D4*LOGC))
However, when I try to put I(D1*LOGA) into lht() function, it generates errors:
library(car)
lht(fashion.lm,c("I(D1*LOGA)"))
> lht(fashion.lm,c("I(D1*LOGA)"))
Error in constants(lhs, cnames_symb) :
The hypothesis "I(D1*LOGA)" is not well formed: contains bad coefficient/variable names.
In addition: Warning message:
In constants(lhs, cnames_symb) : NAs introduced by coercion
I was wondering how to properly do the test in the model? I know one (not so smart method) is to create a variable with the values equal to D1*LOGA before I run the regression. But is there a more convenient way or doing it?
Function lht() treats I(D1*LOGA) as an invalid character. It does not perform operation inside of I()
Here is a solution which uses indirect coefficient specification:
mod.davis <- lm(weight ~ repwt + I(log(repwt)), data=Davis)
lht(mod.davis, hypothesis.matrix = names(coef(mod.davis)[3]))
I'm trying to run a multinomial logistic regression using the mlogit package in R.
I've uploaded the data here https://drive.google.com/file/d/0B_o3xTWAYdbuRGw0dzNFRzd2NEk/view?usp=sharing.
The data contains two different choice variables which I want to run the same model on. I run the first model like so:
lfsm1 <- mlogit.data(lfs.models, shape="wide", choice="PWK")
f1 <- mFormula(PWK~1 | MIGGRP+SEX+AGE+EDU)
m1 <- mlogit(f1, lfsm1, weights=PWT14)
summary(m1)
This model runs without issues. Then I run the same exact model on the other choice variable:
lfsm2 <- mlogit.data(lfs.models, shape="wide", choice="multi")
f2 <- mFormula(multi~1 | MIGGRP+SEX+AGE+EDU)
m2 <- mlogit(f1, lfsm2, weights=PWT14)
I get the following errors:
Error in if (is.null(initial.value) || lnl <= initial.value) break :
missing value where TRUE/FALSE needed
In addition: There were 20 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In `[<-.factor`(`*tmp*`, is.na(x), value = FALSE) :
invalid factor level, NA generated
And that warning message repeats 20x.
I'm not sure what either of these errors mean in the context of my model. A previous post (mlogit: missing value where TRUE/FALSE needed) suggests that my first error occurs because my data are not in wide format, or because there are some individuals who do not select any of the alternatives. In my case neither of these explanations can be right. What I've seen about the warning messages suggest mlogit is reacting badly to variables being factors or numeric. But I don't quite understand why this would matter in a multinomial regression context, or how the problem only occurred twenty times in such a large dataset.
Any suggestions would be most appreciated!
Try
m2 <- mlogit(f2, lfsm2, weights=PWT14)
Note the f2 in the call to mlogit.
In your second call to mlogit.data, you have specified that multi is the choice variable, and the data are prepared accordingly. Yet, in the formula that you are using, f1, the dependent variable is specified as PWK, so that mlogit is expecting a dataframe with one row for each alternative as defined by PMK, not multi.
I'm trying to run a factor analysis on a set of 80 dichotomous variables (1440 cases) using the hector function from the polycor package and the instructions I found here: http://researchsupport.unt.edu/class/Jon/Benchmarks/BinaryFA_L_JDS_Sep2014.pdf
Sadly, after I select just the variables interest from the rest of my dataset and run the factor analysis on them, I seem to consistently get the following error and warnings
Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
non-finite finite-difference value [1]
In addition: Warning messages:
1: In log(P) : NaNs produced
2: In log(P) : NaNs produced
This is with the command/when I hit the step described in the above PDF:
testMat <- hetcor(data)$cor
No idea what this means or how to proceed... Your thoughts are appreciated. Thank you!