Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input data matrix causes errors #2

Open
cwliu007 opened this issue Jun 5, 2024 · 2 comments
Open

Input data matrix causes errors #2

cwliu007 opened this issue Jun 5, 2024 · 2 comments

Comments

@cwliu007
Copy link

cwliu007 commented Jun 5, 2024

Hi Pablo,

I found the following two situations causing different errors for estQ.

(1) first

library("randcorr")
r = randcorr(20)

library("cdmTools")
out1 = estQ(
r = r,
K = 3,
n.obs = NULL,
criterion = "loaddiff",
boot = TRUE,
efa.args = list(cor = "tet", rotation = "oblimin", fm = "uls"),
boot.args = list(N = 0.8, R = 100, verbose = FALSE, seed = 1)
)

Error in colnames<-(*tmp*, value = paste0("Cat", 1:maxK)) :
attempt to set 'colnames' on an object with less than two dimensions

(1) second

values <- c(
1.00000000, 0.2605664, 0.1858627, 0.1399712, 0.09735522,
0.26056643, 1.0000000, 0.1443643, 0.1962672, 0.20538981,
0.18586268, 0.1443643, 1.0000000, 0.1765424, 0.23795236,
0.13997122, 0.1962672, 0.1765424, 1.0000000, 0.17226901,
0.09735522, 0.2053898, 0.2379524, 0.1722690, 1.00000000
)
matrix_var <- matrix(values, nrow = 5, byrow = TRUE)

out1 = estQ(
r = matrix_var,
K = 3,
n.obs = NULL,
criterion = "loaddiff",
boot = TRUE,
efa.args = list(cor = "tet", rotation = "oblimin", fm = "uls"),
boot.args = list(N = 0.8, R = 100, verbose = FALSE, seed = 1)
)

Error in polychoric2(dat = dat, cor.smooth = cor.smooth, maxiter = maxit) :
Minimum value must always zero.

Thanks a lot for this useful package!
Chen-Wei

@Pablo-Najera
Copy link
Owner

Hi Chen-Wei,

Please note the documentation of the package, which states the following regarding the arguments of the estQ function:
n.obs: Number of individuals if r is a correlation matrix. If n.obs is provided, r will be treated as a correlation matrix. Use NULL if r is raw data. The default is NULL.
Since you are using a correlation matrix as input data for r in the function, you must specify the number of individuals. For instance, if you use n.obs = 100, it works.

In the second example, please note that matrix_var is not a correlation matrix, since it is not perfectly symmetrical. This is causing the code to think that it is not a correlation matrix, but a response matrix.

Kind regards,
Pablo

@cwliu007
Copy link
Author

cwliu007 commented Jun 5, 2024

Thank you for pointing out this, Pablo. Now it works on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants