#x1<-rnorm(10,0,1) x1<-c(0.941,-0.007,-1.660,-0.713,-2.311,0.956,0.215,0.347,-0.412,-0.494) #[1] 0.941420501 -0.006570378 -1.659617475 -0.713084619 -2.311091870 # [6] 0.955634729 0.214630869 0.347359396 -0.411664170 -0.494051406 mx1<-mean(x1) #x2<-rnorm(10,0,1) x2<-c(2.253,-0.039,-1.304,2.732,-2.027,0.556,-0.173,-1.792,-1.242,-0.615) #[1] 2.25288125 -0.03872519 -1.30422579 2.73273153 -2.02963616 0.55574747 # [7] -0.17270893 -1.79212356 -1.24162188 -0.61493527 mx2<-mean(x2) xw<-matrix(c(x1-mx1,x2-mx2),10,2) sum(x1-mx1) w<-t(xw)%*%xw rho<-w[1,2]/(sqrt(w[1,1]*w[2,2])) rho #> rho #[1] 0.4687826 mle<-w/10 mle #> mle # [,1] [,2] #[1,] 0.9999700 0.7195707 #[2,] 0.7195707 2.3562270 unbiased<-w/9 unbiased #> unbiased # [,1] [,2] #[1,] 1.111078 0.799523 #[2,] 0.799523 2.618030 eigen.w<-eigen(w) #eigen.w lam<-c(eigen.w$values) lam #> lam #[1] 26.668554 6.893415 hmat<-matrix(eigen.w$vectors,2,2) #lam; hmat lam/10;lam/9 mx1;mx2