Dear R users,
After I ran the following code, I got the error message as the following.
 
Error in asMethod(object) : matrix is not symmetric [1,2]
 
My code is presented as the following.
 
 
library(MASS)
library(rmutil)
library(repeated)
library(lme4)
library(arm)
#install.packages("Zelig", repos = "http://gking.harvard.edu")
library(Zelig)

rm(list = ls())
beta0<-2.5
beta1<--0.3
sigs2<-0.5
I<-4
numberpatients<-c(1000)
#numberpatients<-3
times<-1
MSE_eBLP_quad<-NULL
for (i3 in 1:length(numberpatients)) {
n<-numberpatients[i3]

b0<-NULL
b1<-NULL
sigma2<-NULL
eBLP_glimmix_quad<-NULL
for (kk in 1:times) {
s<-rnorm(I,0,sqrt(sigs2))
y<-NULL
u<-NULL
center<-NULL
for (i in 1:I) {
for (k in 1:n) {
   u<-c(u,0)
   center<-c(center,i)
   lam<-exp(beta0+s[i])
   obs<-rpois(1,lam)
   y<-c(y,obs)
}
for (k in 1:n) {
   u<-c(u,1)
   center<-c(center,i)
   lam<-exp(beta0+beta1+s[i])
   obs<-rpois(1,lam)
   y<-c(y,obs)
}
}
df<-data.frame(y,u,center)

##method1##############
#dan<-glmm(y~u,family=poisson,nest=center,points=3,data=df,print.level=2)
#names(dan)
#b0<-dan$coef[1]
#b1<-dan$coef[2]
#sigma2<-dan$coef[3]
yi1<-NULL
yi2<-NULL
for (i2 in 1:I){
yi1<-c(yi1,sum(y[u==0 & center==i2]))
yi2<-c(yi2,sum(y[u==1 & center==i2]))
}

##method2##############
#fit2 <- glmer(y ~ u + (1|center), family=poisson, data=df,nAGQ=3,verbose = TRUE, REML = FALSE  )
fit2 <- glmer(y ~ u + (1|center), family=poisson, data=df,nAGQ=3)
fit3<-zelig(y ~ u + (1|center), model="poisson", data=df)
estimate_sigma2<-sigma.hat(fit2)$sigma$center
b_estimate<-fit2@fixef
#fit2@A@x[1]
#sqrt(diag(vcov(fit2)))
#print(fit2)

alpha1=b_estimate[1]
alpha2=b_estimate[1]+b_estimate[2]
T1=exp(alpha1+estimate_sigma2/2) 
T2=exp(alpha2+estimate_sigma2/2) 
T3=exp(estimate_sigma2)-1
T4=exp(0.5*estimate_sigma2)
w=exp(s)
eBLP_glimmix_quad[kk]=mean((T4+n*T3*T4*(yi1/n+yi2/n-T1-T2)/(1+T3*n*(T1+T2))-w)^2)
 
}

MSE_eBLP_quad[i3]<-mean(eBLP_glimmix_quad)
}
print(fit2)
 
#####################
Does anyone can solve this error for me?
Thanks!
 


      
	[[alternative HTML version deleted]]


