Displaying 1 result from an estimated 1 matches for "alphanew".
Did you mean:
alphanet
2011 Nov 28
1
code problem with the optim() function
...)
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[, 2]
if (!is.factor(r1)) r1 <- factor(r1)
if (!is.factor(r2)) r2 <- factor(r2)
ifelse (length(levels(r1)) >=...