訂正;hetcor関数のこと

データはデータフレーム型で与えねばならないみたい。で、factorに指定されてあったら、ordinalと見なすようです。
サンプル・プログラムをあげておきます。

<span class="synComment">#データフレーム形式でデータをつくる</span>
<span class="synComment">#前から順に、二件法、三件法、四件法、、、七件法のつもりで適当に作ったデータ。</span>
data <span class="synStatement">&lt;-</span> <span class="synType">data.frame</span><span class="synSpecial">(</span><span class="synType">matrix</span><span class="synSpecial">(</span>c<span class="synSpecial">(</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">5</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">6</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">5</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">6</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span>
<span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">0</span><span class="synSpecial">,</span><span class="synConstant">3</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">4</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">5</span><span class="synSpecial">,</span>
<span class="synConstant">1</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">2</span><span class="synSpecial">,</span><span class="synConstant">5</span><span class="synSpecial">,</span><span class="synConstant">2</span>
<span class="synSpecial">),</span>ncol=<span class="synConstant">6</span><span class="synSpecial">,</span>byrow=<span class="synConstant">TRUE</span><span class="synSpecial">))</span>
<span class="synComment">#変数名をつけておく。grade2〜grade7</span>
colnames<span class="synSpecial">(</span>data<span class="synSpecial">)</span> <span class="synStatement">&lt;-</span> c<span class="synSpecial">(</span><span class="synConstant">&quot;g2&quot;</span><span class="synSpecial">,</span><span class="synConstant">&quot;g3&quot;</span><span class="synSpecial">,</span><span class="synConstant">&quot;g4&quot;</span><span class="synSpecial">,</span><span class="synConstant">&quot;g5&quot;</span><span class="synSpecial">,</span><span class="synConstant">&quot;g6&quot;</span><span class="synSpecial">,</span><span class="synConstant">&quot;g7&quot;</span><span class="synSpecial">)</span>
<span class="synComment">#四件法以下は水準(factor)だと考える</span>
data$g2 <span class="synStatement">&lt;-</span> as.factor<span class="synSpecial">(</span>data$g2<span class="synSpecial">)</span>
data$g3 <span class="synStatement">&lt;-</span> as.factor<span class="synSpecial">(</span>data$g3<span class="synSpecial">)</span>
data$g4 <span class="synStatement">&lt;-</span> as.factor<span class="synSpecial">(</span>data$g4<span class="synSpecial">)</span>
<span class="synComment">#ライブラリのインストール</span>
library<span class="synSpecial">(</span>polycor<span class="synSpecial">)</span>
<span class="synComment">#あの関数</span>
hetcor<span class="synSpecial">(</span>data<span class="synSpecial">)</span>
日記
オンラインでもオフラインでも

後期が始まりました。 徐々に対面授業も解禁。後期の授業どうしますか,と聞かれたので一応対面で申し込ん …

日記
停電と漏電

夜にAmazon Prime Videoを見るのが最近のルーチン。昨日はジム・キャリーの「イエスマン …

日記
コロナとボン

不定期につづける日記だが,前に書いたのは一ヶ月前か。そんなに経つんだな。毎日家の中で過ごしていると, …