Displaying 1 result from an estimated 1 matches for "e_step".
Did you mean:
x_step
2007 May 11
0
EM covergence problem
...= c(2,3)
Beta = t(Beta)
probs = matrix(,nrow = 1000, ncol = 3)
for(i in 1:3){
v1 = X%*%Beta[(i-1)*2+1:2]
v2 = Y%*%Beta[(i-1)*2+1:2]
p1 = exp(v1)/(exp(v1)+exp(v2))
p2 = exp(v2)/(exp(v1)+exp(v2))
probs[,i] = ifelse (D==0,log(p1),log(p2))
}
return (probs)
}
#H [individuals][class]
E_step = function(alpha,Beta){#calc posterior of H
tmpH = matrix(,nrow = 1000,ncol =3)
lprobs = logProbInd(Beta)
for(i in 1:3){#classes
tmpH[,i] = alpha[i]*exp(lprobs[,i])
}
H = tmpH /apply(tmpH,1,sum)
return( H)
}
M_step = function(H,Beta){
#first part use direct estimation
aita = apply(H,2,...