Reputation: 11
FYI: modelQ2_1 is a mixed logit model #Edited - Sorry for not providing the staging ground to reproduce the problem.
library(mlogit)
library(dfidx)
data("Electricity", package = "mlogit")
Electricity$chid <- 1:nrow(Electricity)
str(Electricity)
#there are 27 variables - 3:26 would be predictor variables for the model
Electr <- dfidx(Electricity, idx = list(c("chid", "id")),
choice = "choice", varying = 3:26, sep = "")
mxl <-mlogit(choice~ pf + cl + loc + wk + tod +seas -1, data = Electr,
rpar = c(pf='n', cl='n', loc = 'n',wk = 'n', tod = 'n', seas = 'n'), panel = TRUE)
summary(mxl)
coef(mxl)[c("cl","sd.cl")]
pnorm(0,mean = (coef(mxl)["cl"]), sd= (coef(mxl["sd.cl"])))
# Error in pnorm(0, mean = (coef(modelQ2_1)\["cl"\]), sd = (coef(modelQ2_1\["sd.cl"\]))) :
# Non-numeric argument to mathematical function
However, when I check the class for the argument , both arguments are numeric.
When i try this due to the error:
pnorm(0,mean = as.numeric(coef(modelQ2_1)["cl"]), sd= as.numeric(coef(modelQ2_1["sd.cl"])))
The output is
numeric(0)
instead of an answer.
Instead I have to resort to this code:
pnorm(0, mean = (modelQ2_1$coefficients\["cl"\]), sd = (modelQ2_1$coefficients\["sd.cl"\]))
The above code works fine. However, they are the same, aren't it?
Upvotes: 1
Views: 34