jenfb / bkmr

Bayesian kernel machine regression
50 stars 19 forks source link

InvestigatePrior() function not working with or without covariates (X = NULL) #19

Open davidrjohnson4 opened 3 years ago

davidrjohnson4 commented 3 years ago

In the InvestigatePriors() function, it looks like the default for X used to be X = NULL, but now the function requires a specified X (the matrix of covariate data). I can't get it to work, with or without an X, and it throws different errors when I put X = NULL (' Error in model.frame.default(formula = ~U + y + X + group, data = , : invalid type (NULL) for variable 'X' '), or dummy X covariate data (' Error in X %*% fief(fit) : non-conformable arguments '). Any ideas what might be happening, or fixes/workarounds?

Thanks!

jenfb commented 2 years ago

Could you please provide a reproducible example that throws that error? I am not getting an error with this code from the vignette:

library(bkmr) set.seed(111) dat <- SimData(n = 50, M = 4) y <- dat$y Z <- dat$Z X <- dat$X

With covariates

priorfits <- InvestigatePrior(y = y, Z = Z, X = X, q.seq = c(2, 1/2, 1/4, 1/16)) PlotPriorFits(y = y, Z = Z, X = X, fits = priorfits)

Without covariates: set X to be a matrix with the intercept only

X_intercept <- matrix(1, length(y), 1) priorfits2 <- InvestigatePrior(y = y, Z = Z, X = X_intercept, q.seq = c(2, 1/2, 1/4, 1/16)) PlotPriorFits(y = y, Z = Z, X = X_intercept, fits = priorfits2)