Displaying 1 result from an estimated 1 matches for "sumagr".
Did you mean:
kumar
2011 Nov 28
1
code problem with the optim() function
...v)]
r1 <- factor(ratings[, 1], levels = lev)
r2 <- factor(ratings[, 2], levels = lev)
ttab <- table(r1, r2)
total<-margin.table(ttab)
pa<-(margin.table(ttab,1)/total)
pb<-(margin.table(ttab,2)/total)
ncate<-length(levels(as.factor(as.matrix(ratings))))
pp<-prop.table(ttab)
sumagr<-sum(diag(ttab))/ns
alpha<-(sumagr-sum(pa*pb))/(1-sum(pa*pb))
aickin <- function(theta,ratings) {
alphanew<-theta[1]
pah<-theta[2:3]
pbh<-theta[4:5]
ratings <- as.matrix(na.omit(ratings))
ns <- nrow(ratings)
nr <- ncol(ratings)
r1 <- ratings[, 1]
r2 <- ratings[...