悬赏 10 论坛资金 已解决
R语言中的minxent包可以计算拉格朗日乘子,但从help中了解的信息太少了,不知道怎么代入自己的数据,想寻求大家的帮助,感谢。以下包里的代码:
xi <- 1:6
eta<-c(1,4,19) #expected moment constraints
q<-c(rep(1/6),6) #a priori distribution
G<-matrix(c(rep(1,6),xi,xi^2),byrow=TRUE,nrow=3) #matrix of moment vector function of observed data
minxent.multiple(q=q,G=G,eta=eta,c(0,0)) #estimates of lagrangian multipliers and MinxEnt distribution
q <- c(0.05,0.10,0.15,0.20,0.22,0.28) # a priori distribution
G <- matrix(c(rep(1,6),1:6),byrow=TRUE,nrow=2) # matrix of moment vector function of observed data
eta <- c(1,4.5) # vector of moment constraints
minxent.single(q=q,G=G,eta=eta,c(0)) # estimate of lagrangian multipliers and Kullback minimimum cross entropy distribution