[英]Error in readRDS(file.rds)
摘要:
我安裝了rstan軟件包,現在遇到此錯誤:
readRDS(file.rds)中的錯誤:未知的輸入格式
描述:
> traceback()
5: readRDS(file.rds)
4: is(obj <- readRDS(file.rds), "stanmodel")
3: stan_model(file, model_name = model_name, model_code = model_code,
stanc_ret = NULL, boost_lib = boost_lib, eigen_lib = eigen_lib,
save_dso = save_dso, verbose = verbose)
2: stan(file = fName, data = datalist, init = list(inlist), chains = 1,
iter = n.it, pars = c("f", "tau"), warmup = n.warm, seed = computerID +
1000) at functions.r#131
1: RunModel(11, myT, nu, lambda, rho, BDRi, Pars, computerID, n.it,
n.warm, getwd())
環境:
請測試是否可行:
install.packages('rstan')
library(rstan)
saveRDS(mtcars, file = 'test.rds')
readRDS('test.rds')
對我來說很好
我的問題解決了。 我使用writeLines命令。
library(rstan)
scode <- "
parameters {
real y[2];
}
model {
y[1] ~ normal(0, 1);
y[2] ~ double_exponential(0, 2);
}
"
writeLines(scode, "mymodel.stan")
mymodel <- stan("mymodel.stan", iter = 10, verbose = FALSE)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.