全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 经管百科 爱问频道
1005 1
2013-12-29
我在用R做一个MLE, 写的code是> test<-function(theta,da){
+ c1<-theta[1]
+ c2<-theta[2]
+ c3<-theta[3]
+ k<-nrow(da)
+ logl<- -.5*k*log(2*pi)-0.5*sum((c1*da[,1]+c2*da[,2]+c3*da[,3])**2)
+ return(-logl)
+ }
> optim(theta <- c(0,1,2), test,da, hessian=TRUE)
但是显示的错误是
错误于nrow(da) : 缺少参数"da",也没有缺省值

注:da是一个矩阵,类似于
10-1
01-1
101
1-10
1-10
-110
1-10
1-10
10-1
10-1
10-1
101
01-1
01-1
0-11
0-11
0-11
01-1




求大神指点,究竟是哪里写错了?
如果要估计的参数从3个扩展到300个,有没有更好的写法,求给一个loop!
谢各位大神!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-12-31 00:16:57
It seems the inputs for the function to be optimized ( here it refers to "test") should be one dimension.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群