我对R并不熟悉,我试图从我的数据中估计出一个离散的选择模型。我被困在评估我的模型的过程中,我会感谢你的帮助。
我使用'gmnl‘软件包来估计Scale(标度多项式Logit)。有四种运输方式可供选择,其具体变量为“收费”和“时间”。个人的具体变量是收入和性别(它们都输入模型作为虚拟变量,收入变量定义为收入6个收入组)。
我从估计一个S开始,在那里,特定于替代的常数是固定的,而不是缩放的,这是收敛的。
> smnl<- gmnl(choice~time+toll |1, data=u, model="smnl", R=100, notscale=c(1,1,1,0,0))
> summary(smnl)
然后,我允许每个人的收入水平不同(我在“公式”的第五部分中具体说明,比额表中不包括可变收入和常数。
> smnl.het<-gmnl (choice ~ time + toll | 1 | 0 | 0 | Income1 +Income2 + Income3 + Income4 + Income5 + Income6 -1 , data=u, model="smnl", R=100, notscale= c (1,1,1, rep(0,2)))
> Summary (smnl.het)
但是,我得到了以下错误:
错误在Hi,,drop = FALSE :下标超出界限
我不知道为什么会有这个错误。我尝试了下面的论点来找出是什么原因造成的:
options(error=recover)
smnl.het<-gmnl (choice ~ time + toll | 1 | 0 | 0 | Income1 +Income2 + Income3 + Income4 + Income5 + Income6-1 , data=u, model="smnl", R=100, notscale= c (1,1,1, rep(0,2)))
Enter a frame number, or 0 to exit
1: gmnl(choice ~ time + toll | 1 | 0 | 0 | Income - 1, data = u, model = "smnl", R
2: eval(opt, sys.frame(which = nframe))
3: eval(expr, envir, enclos)
4: maxLik(method = "bfgs", start = c(-0.948352323447934, -2.54330549099491, -4.394
5: maxRoutine(fn = logLik, grad = grad, hess = hess, start = start, constraints =
6: maxOptim(fn = fn, grad = grad, hess = hess, start = start, method = "BFGS", fix
7: callWithoutSumt(start, "logLikFunc", fnOrig = fn, gradOrig = grad, hessOrig = h
8: callWithoutArgs(theta, fName = fName, args = names(formals(sumt)), ...)
9: eval(f, sys.frame(sys.parent()))
10: eval(expr, envir, enclos)
11: logLikFunc(theta, fnOrig = ..1, gradOrig = ..2, hessOrig = ..3, X = ..4, y = ..
12: fnOrig(theta, ...)
13: drop(tcrossprod(H[i, , drop = FALSE], t(delta)))
14: tcrossprod(H[i, , drop = FALSE], t(delta))
Selection: 13
Called from: top level
Browse[1]> ls()
[1] "x"
Browse[1]> x
包装过程中的错误:承诺已经在评估:递归默认参数引用还是早期问题?
Selection: 14
Called from: top level
Browse[1]> ls()
[1] "x" "y"
Browse[1]> x
包装过程中的错误:承诺已经在评估:递归默认参数引用还是早期问题?
Browse[1]> y
het.Income2 het.Income3 het.Income4 het.Income5 het.Income6
[1,] 0 0 0 0 0
我不明白问题出在哪里。我认为这可能是因为使用了虚拟变量。请帮我解决这个问题。谢谢!
发布于 2016-01-26 20:58:29
看起来您可能错误地键入了notscale
的命令。
smnl.het<-gmnl(choice ~ time + toll | 1 | 0 | 0 | Income1 +Income2 + Income3 + Income4 + Income5 + Income6 -1 , data=u, model="smnl", R=100, notscale= c (1,1,1, rep(0,2)))
Summary (smnl.het)
我本以为它看上去更像这样:smnl.het<-gmnl(选择时间+收费时间1+ toll 0 x 0 Income1 -1,data=u,model="smnl",R=100,notscale=c(1,1,1,0,0) )
你试过像上面这样的更窄的命令集吗?
https://stackoverflow.com/questions/31644621
复制相似问题