jasp-stats / jasp-issues

This repository is solely meant for reporting of bugs, feature requests and other issues in JASP.
59 stars 29 forks source link

Error in dimnamesGets(x, value): invalid dimnames given for “dgCMatrix” object #899

Closed jubera closed 4 years ago

jubera commented 4 years ago

I run classic LMMs in my data file and it run correctly. However, when I've tried to run Bayesian LMMs... "This analysis terminated unexpectedly."

I would really appreciate if you could help me to solve this bug. Thanks in advance.

threshold_for_LMM_JASP.csv.zip

This is the message that accompanies the error:

Stack trace .mmFitModelB(jaspResults, dataset, options, type)

stanova::stanova_lmer(formula = as.formula(model_formula$model_formula), check_contrasts = 'contr.bayes', data = dataset, chains = options$chains, iter = options$iteration, warmup = options$warmup, adapt_delta = options$adapt_delta, control = list(max_treedepth = options$max_treedepth), seed = if (isTRUE(options[['setSeed']])) options[['seed']])

stanova(formula = formula, data = data, model_fun = 'glmer', family = 'gaussian', ..., check_contrasts = check_contrasts)

do.call(what = getExportedValue('rstanarm', paste0('stan_', model_fun)), args = c(formula = formula, data = list(data), list(...)))

(function (formula, data = NULL, family = gaussian, subset, weights, na.action = getOption('na.action', 'na.omit'), offset, contrasts = NULL, ..., prior = normal(), prior_intercept = normal(), prior_aux = exponential(), prior_covariance = decov(), prior_PD = FALSE, algorithm = c('sampling', 'meanfield', 'fullrank'), adapt_delta = NULL, QR = FALSE, sparse = FALSE) { call <- match.call(expand.dots = TRUE) mc <- match.call(expand.dots = FALSE) data <- validate_data(data) family <- validate_family(family) mc[[1]] <- quote(lme4::glFormula) mc$control <- make_glmerControl(ignore_lhs = prior_PD, ignore_x_scale = prior$autoscale %ORifNULL% FALSE) mc$data <- data mc$prior <- mc$prior_intercept <- mc$prior_covariance <- mc$prior_aux <- mc$prior_PD <- mc$algorithm <- mc$scale <- mc$concentration <- mc$shape <- mc$adapt_delta <- mc$... <- mc$QR <- mc$sparse <- NULL glmod <- eval(mc, parent.frame()) X <- glmod$X if ('b' %in% colnames(X)) { stop('stan_glmer does not allow the name 'b' for predictor variables.', call. = FALSE) } if (prior_PD && !has_outcome_variable(formula)) { y <- NULL } else { y <- glmod$fr[, as.character(glmod$formula[2])] if (is.matrix(y) && ncol(y) = 1) { y <- as.vector(y) } } offset <- model.offset(glmod$fr) %ORifNULL% double(0) weights <- validate_weights(as.vector(model.weights(glmod$fr))) if (binom_y_prop(y, family, weights)) { y1 <- as.integer(as.vector(y) * weights) y <- cbind(y1, y0 = weights - y1) weights <- double(0) } if (is.null(prior)) prior <- list() if (is.null(prior_intercept)) prior_intercept <- list() if (is.null(prior_aux)) prior_aux <- list() if (is.null(prior_covariance)) stop(''prior_covariance' can't be NULL.', call. = FALSE) group <- glmod$reTrms group$decov <- prior_covariance algorithm <- match.arg(algorithm) stanfit <- stan_glm.fit(x = X, y = y, weights = weights, offset = offset, family = family, prior = prior, prior_intercept = prior_intercept, prior_aux = prior_aux, prior_PD = prior_PD, algorithm = algorithm, adapt_delta = adapt_delta, group = group, QR = QR, sparse = sparse, mean_PPD = !prior_PD, ...) add_classes <- 'lmerMod' if (family$family = 'Beta regression') { add_classes <- c(add_classes, 'betareg') family$family <- 'beta' } sel <- apply(X, 2, function(x) !all(x = 1) && length(unique(x)) < 2) X <- X[, !sel, drop = FALSE] Z <- pad_reTrms(Ztlist = group$Ztlist, cnms = group$cnms, flist = group$flist)$Z colnames(Z) <- b_names(names(stanfit), value = TRUE) fit <- nlist(stanfit, family, formula, offset, weights, x = cbind(X, Z), y = y, data, call, terms = NULL, model = NULL, na.action = attr(glmod$fr, 'na.action'), contrasts, algorithm, glmod, stan_function = 'stan_glmer') out <- stanreg(fit) class(out) <- c(class(out), addclasses) return(out) })(formula = JaspColumn.2.Encoded ~ JaspColumn.1.Encoded + (1 | JaspColumn.0.Encoded), data = list(JaspColumn.2.Encoded = c(127.127127127127, 155.655655655656, 178.178178178178, 151.651651651652, 154.154154154154, 398.898898898899, 266.766766766767, 169.169169169169, 219.71971971972, 252.752752752753, 307.307307307307, 252.752752752753, 105.605605605606, 173.673673673674, 191.691691691692, 192.692692692693, 110.11011011011, 179.179179179179, 251.751751751752, 146.146146146146, 28.028028028028, 135.635635635636, 94.03403, 120.12012012012, 180.18018018018, 172.672672672673, 215.715715715716, 135.635635635636, 200.2002002002, 146.646646646647, 150.15015015015, 146.646646646647, 135.135135135135, 132.132132132132, 158.158158158158, 151.651651651652, 161.661661661662, 203.703703703704, 242.742742742743, 202.702702702703, 144.644644644645, 191.691691691692, 144.144144144144, 199.199199199199, 128.128128128128, 181.681681681682, 207.207207207207, 161.161161161161, 172.172172172172, 208.208208208208, 246.246246246246, 172.172172172172, 134.134134134134, 159.65965965966, 160.660660660661, 170.670670670671, 177.177177177177, 180.680680680681, 222.222222222222, 198.698698698699, 218.718718718719, 243.743743743744, 256.256256256256, 238.738738738739, 118.618618618619, 165.165165165165, 196.196196196196, 139.63963963964, 113.613613613614, 184.684684684685, 201.701701701702, 132.632632632633, 118.118118118118, 181.681681681682, 254.254254254254, 139.63963963964, 152.652652652653, 180.680680680681, 212.212212212212, 146.146146146146), JaspColumn.1.Encoded = c(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4), JaspColumn.0._Encoded = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20)), family = 'gaussian', chains = 3, iter = 4000, warmup = 2000, adapt_delta = 0.8, control = list(max_treedepth = 10), seed = NULL)

colnames<-(*tmp*, value = b_names(names(stanfit), value = TRUE))

dimnames<-(*tmp*, value = dn)

dimnames<-(*tmp*, value = dn)

dimnamesGets(x, value)

stop(gettextf('invalid dimnames given for %s object', dQuote(class(x))), domain = NA)

FBartos commented 4 years ago

Hi @jubera and thanks for reporting the issue.

I tried reproducing it and I wanted to check whether this setting corresponds to the one you run the model (or did you change anything in the Model/Options tab?): image.

If that is so, it might be macOS specific. I think that we had a similar issue before and it must have resurfaced.

Best, František

jubera commented 4 years ago

Hi @FBartos, thanks for the quick answer!

I could not get to that screen. So, I did not change anything in the Model/Options tab.

So, as you said, it should be macOS specific. I am going to try to run it in a Windows computer, and see if it works.

Thanks a lot for your help! Esperanza

TimKDJ commented 4 years ago

We actually needed to create two installers for MacOS specifically to deal with this problem, one for versions below Catalina and one for Catalina. If you use http://static.jasp-stats.org/JASP-0.13.1.0-preCatalina.dmg to download JASP 0.13.1 it should run.

jasp_mac_installer

I appreciate that the text is a little tiny and might easily be glossed over :)

jubera commented 4 years ago

Hi @TimKDJ thanks a lot for this! it works now indeed. I'm sorry that I wasn't careful enough to see it. Best wishes!

TimKDJ commented 4 years ago

Glad to hear it works!