Constanza Avalos
Constanza Avalos

Reputation: 1

Error in `choicemodelr()`: ! argument "directory" is missing, with no default

I hope your are well. I am estimating a hierarchical bayes choice model with ChoiceModelR. This is a long code that works perfectly except this chunck. Every time I run this chunck I get the error: Error in 'choicemodel()': ! argument "directory" is missing, with no default. To be precise, the problem is hb.post. That line generates the chaos! Help me please.

choice <- rep(0, nrow(cbc.df))
choice[cbc.df[,"alt"]==1] <- cbc.df[cbc.df[,"choice"]==1,"alt"]
head(choice)

cbc.coded <- model.matrix(~ cereal_label + bill + quantity + price, data = cbc.df)
cbc.coded <- cbc.coded[, -1] # remove the intercept

choicemodelr.data <- cbind(cbc.df[,1:3], cbc.coded, choice)
head(choicemodelr.data)

cerealpool <- cbc.df$cerealpool[cbc.df$ques==1 & cbc.df$alt==1]=="yes"
cerealpool <- as.numeric(cerealpool)
choicemodelr.demos <- as.matrix(cerealpool, nrow=length(cerealpool))
str(choicemodelr.demos)

library(ChoiceModelR)
hb.post <- choicemodelr(data=choicemodelr.data, xcoding=rep(1, 7), 
                        demos=choicemodelr.demos, 
                        mcmc=list(R=20000, use=10000),
                        options=list(save=TRUE))

names(hb.post)

Error in `choicemodelr()`:
! argument "directory" is missing, with no default
Backtrace:
 1. ChoiceModelR::choicemodelr(...)
 3. base::paste(directory, "/", "RLog.txt", sep = "")
Execution halted
Warning message:
In sink() : no sink to remove

Upvotes: 0

Views: 65

Answers (1)

user27013718
user27013718

Reputation: 1

pls try it

hb.post <- choicemodelr(data=choicemodelr.data, xcoding=rep(1, 7), 
                        demos=choicemodelr.demos, 
                        mcmc=list(R=20000, use=10000),
                        options=list(save=TRUE),
                        directory=getwd())

Upvotes: 0

Related Questions