我正在尝试使用bayesglm 拟合以下模型。由于我对参数的先验分布有所了解,因此我指定了prior.mean、prior.scale、prior.mean.for.intercept 和prior.scale.for.intercept:
prior.mean <- c(0,0.5,0.75) #treated and untreated, assay1, assay2 and assay3
prior.scale <- c(1,0.5,0.5)
prior.mean.for.intercept <- 0
prior.scale.for.intercept <- 1
offsetvalue <- c(0.1703984, -0.6958495, 0.3079694, -0.5582785, 0.2251210, -0.6411269)
form = y ~ offset(ofsetvalue) + 1 + treatment + assay
modelOutput <- bayesglm(formula=form, family="gaussian", data=input, prior.mean=prior.mean,
prior.scale=prior.scale, prior.df=Inf, prior.mean.for.intercept=prior.mean.for.intercept,
prior.scale.for.intercept=prior.scale.for.intercept, prior.df.for.intercept=Inf)
当我尝试适应此错误时,会显示以下错误:
Error in bayesglm.fit(x = X[, "(Intercept)", drop = FALSE], y = Y, weights = weights, :
invalid length for prior.mean
该错误来自bayesglm中的以下行:
if (length(offset) && attr(mt, "intercept") > 0L) {
fit2 <- bayesglm.fit(x = X[, "(Intercept)", drop = FALSE],
y = Y, weights = weights, offset = offset, family = family,
control = control, intercept = TRUE, prior.mean = prior.mean,
prior.scale = prior.scale, prior.df = prior.df,
prior.mean.for.intercept = prior.mean.for.intercept,
prior.scale.for.intercept = prior.scale.for.intercept,
prior.df.for.intercept = prior.df.for.intercept,
min.prior.scale = min.prior.scale, print.unnormalized.log.posterior = print.unnormalized.log.posterior,
scaled = scaled, Warning = Warning)
我想知道为什么需要安装适合拦截的个人,而 bayesglm 已经安装了一次模型?有没有办法绕过这个?
谢谢,
于尔根