如何转换参数以适应向量矩阵乘法

时间:2016-02-10 13:16:22

标签: r matrix vector

我有三个参数需要是向量和矩阵以适应乘法过程。我在其他问题中尝试了所有建议,但都没有效果。

LogLik=function(theta, r_t)
{
input=GARCH(theta, r_t)
error=input[,(1:4)]  #=e
Sigma=as.matrix(input[,(5:8)])
d=4 #combining 4 distributions
n= seq(from=1, to=((length(r_t$log_r1))*4)-3, by=4)
o= seq(from=4, to=(length(r_t$log_r1))*4, by=4)
for(i in 1:length(r_t$log_r1))
{
LLik=-(d/2)*log(2*pi)-(d/2)*log(det(Sigma[(n[i]:o[i]),]))-  (d/2)*t(error[i,])%*%solve(Sigma[(n[i]:o[i]),])%*%(error[i,])   #log-likelihoodfunction, multivariate
}
}  

问题在于错误和Sigma来自上面一个函数之前的data.frame(e,H_t)。现在我想要一个来自

的标量
t(error[i,])%*%solve(Sigma[(n[i]:o[i]),])%*%(error[i,])

但也不是错误是一个向量参数niether Sigma是一个矩阵参数。我试过as.matrix和as.vector等等。有没有办法不写另一个函数来改变它?

0 个答案:

没有答案