- この頃の話題(記事はこちら)のベクトルをRで作る
- カテゴリ数nc(自由度=次元=df)
- 実行はこちらでも
CategoryVector<-function(nc=3){
df<-nc-1
d<-df+1
diagval<-1:d
diagval<-sqrt((df+1)/df)*sqrt((df-diagval+1)/(df-diagval+2))
others<--diagval/(df-(0:(d-1)))
m<-matrix(rep(others,df+1),nrow=df+1,byrow=TRUE)
diag(m)<-diagval
m[upper.tri(m)]<-0
m[,1:df]
}
CategoryVector(3)
df<-4
d<-df+1
diagval<-1:d
diagval<-sqrt((df+1)/df)*sqrt((df-diagval+1)/(df-diagval+2))
others<--diagval/(df-(0:(d-1)))
m<-matrix(rep(others,df+1),nrow=df+1,byrow=TRUE)
diag(m)<-diagval
m[upper.tri(m)]<-0
m<-m[,1:df]