Displaying 1 result from an estimated 1 matches for "p_tild".
Did you mean:
p_tilde
2011 May 19
3
problem with optim()
...or (i in 1:nrow(X))
{
res1[i]=1/(1+exp(-t(x1)%*%X[i,]-x2))
for (t in 1:ncol(Y))
{
res2[i,t] = ((1-(1+exp(-t(x3[,t])%*%X[i,]-x4[t]))^(-1))^(abs(Y[i,t]-Yb[i])))*(((1+exp(-t(x3[,t])%*%X[i,]-x4[t]))^(-1))^(1-abs(Y[i,t]-Yb[i])))
log.res2[i,t]=log(res2[i,t])
res2.b[i]=res2.b[i]+log.res2[i,t]
}
res3[i] = p_tilde[i]*log(res1[i])
res3.b[i] = p_tilde[i]*(res2.b[i])
}
-(ncol(Y)*sum(res3)+sum(res3.b))
}
$B!!(B
##### Gradiants:
gr=function(x)
{
x1 = x[1:ncol(X)]
x2 = x[(ncol(X)+1)]
x3 = matrix(x[(ncol(X)+2):(ncol(X)+1+ncol(X)*ncol(Y))],nrow=ncol(X),ncol=ncol(Y))
x4 = x[(ncol(X)+1+ncol(X)*ncol(Y)+1):length(x)...