Rで解析:レパートリー・グリッドを作成・解析「OpenRepGrid」パッケージ

Rの解析に役に立つ記事
スポンサーリンク

市場調査や心理学などで使用されるレパートリー・グリッドを作成・解析するパッケージの紹介です。

レパートリー・グリッドを初めて聞きました。
どのようなデータが解析対象となるのか解らなかったので、下記論文のFig4のデータを参考にしています。

・阿部ひと美・今井正司・根建金男(2013)
 レパートリー・グリッド法を適用してとらえた社会不安の特徴
 パーソナリティ研究, 21, 203-215.
 https://www.jstage.jst.go.jp/article/personality/21/3/21_203/_pdf

論文でも主張されていますが、レパートリー・グリッドは大変可能性があるツールだと考えます。

なお紹介していませんが、テキストファイルなどからレパートリー・グリッドのデータを読み込むコマンドがパッケージに収録されています。パッケージヘルプだけでなくOpenRepGrid公式ページも参考にしてください。

・OpenRepGrid公式ページ
 http://docu.openrepgrid.org/index.html

パッケージバージョンは0.1.12。R version 4.2.2で動作を確認しています。

スポンサーリンク

パッケージのインストール

下記コマンドを実行してください。

#パッケージのインストール
install.packages("OpenRepGrid")

コマンドの紹介

詳細はコマンド、各パッケージのヘルプを確認してください。

#パッケージの読み込み
library("OpenRepGrid") 

#レパートリー・グリッドの作成とスケールの設定:makeRepgrid,setScaleコマンド
TestData <- list(
  name = c("&#21021;&#23550;&#38754;&#12398;&#30064;&#24615;&#12392;&#35441;&#12377;", "&#21021;&#23550;&#38754;&#12398;&#21516;&#22995;&#12392;&#35441;&#12377;",
           "&#20154;&#21069;&#12391;&#30330;&#34920;&#12377;&#12427;", "&#12424;&#12367;&#30693;&#12425;&#12394;&#12356;&#20154;&#12395;&#38651;&#35441;&#12434;&#12363;&#12369;&#12427;",
           "&#12464;&#12523;&#12540;&#12503;&#12398;&#20013;&#12391;&#33258;&#20998;&#12398;&#24847;&#35211;&#12434;&#35328;&#12358;", "&#25480;&#26989;&#20013;&#12395;&#20808;&#29983;&#12395;&#36074;&#21839;&#12434;&#12377;&#12427;",
           "&#35504;&#12363;&#12434;&#35480;&#12362;&#12358;&#12392;&#12377;&#12427;", "&#35242;&#12375;&#12367;&#12394;&#12356;&#20154;&#12395;&#38972;&#12415;&#12372;&#12392;&#12434;&#12377;&#12427;",
           "&#27177;&#23041;&#12398;&#12354;&#12427;&#20154;&#12392;&#35441;&#12377;", "&#37325;&#35201;&#12394;&#35430;&#39443;&#12434;&#21463;&#12369;&#12427;",
           "&#23398;&#39135;&#12420;&#12524;&#12473;&#12488;&#12521;&#12531;&#12391;&#39135;&#20107;&#12434;&#12377;&#12427;", "&#21451;&#20154;&#12395;&#38651;&#35441;&#12434;&#25499;&#12369;&#12427;",
           "&#30427;&#12426;&#19978;&#12364;&#12387;&#12390;&#36650;&#12398;&#20013;&#12395;&#20837;&#12427;", "&#35242;&#12375;&#12367;&#12394;&#12356;&#20154;&#12392;&#35441;&#12377;",
           "&#35242;&#12375;&#12356;&#21451;&#20154;&#12392;&#35441;&#12377;"),
  l.name = c("&#32202;&#24373;&#12377;&#12427;", "&#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12390;&#12356;&#12427;&#12363;&#27671;&#12395;&#12394;&#12427;",
             "&#33258;&#20449;&#12364;&#12394;&#12356;", "&#33510;&#25163;&#12391;&#12354;&#12427;", "&#36991;&#12369;&#12424;&#12358;&#12392;&#12377;&#12427;",
             "&#38627;&#12375;&#12356;", "&#28040;&#26997;&#30340;&#12391;&#12354;&#12427;", "&#24907;&#24230;&#12364;&#12366;&#12371;&#12385;&#12394;&#12356;",
             "&#12497;&#12491;&#12483;&#12463;&#12395;&#12394;&#12427;", "&#38957;&#12364;&#28151;&#20081;&#12377;&#12427;", "&#34920;&#24773;&#12364;&#12371;&#12431;&#12400;&#12427;",
             "&#12388;&#12414;&#12425;&#12394;&#12356;", "&#21475;&#12372;&#12418;&#12427;", "&#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12394;&#12356;"),
  r.name = c("&#12522;&#12521;&#12483;&#12463;&#12473;&#12377;&#12427;", "&#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12424;&#12358;&#12392;&#27671;&#12395;&#12375;&#12394;&#12356;",
             "&#33258;&#20449;&#12364;&#12354;&#12427;", "&#24471;&#24847;&#12391;&#12354;&#12427;", "&#36914;&#12435;&#12391;&#21462;&#12426;&#32068;&#12416;",
             "&#12383;&#12420;&#12377;&#12356;", "&#31309;&#26997;&#30340;&#12391;&#12354;&#12427;", "&#33258;&#28982;&#12394;&#24907;&#24230;",
             "&#33853;&#12385;&#30528;&#12356;&#12390;&#12356;&#12427;", "&#38957;&#12364;&#12399;&#12387;&#12365;&#12426;&#12375;&#12390;&#12356;&#12427;",
             "&#34920;&#24773;&#12364;&#33258;&#28982;", "&#12424;&#12367;&#12375;&#12419;&#12409;&#12427;", "&#27005;&#12375;&#12356;",
             "&#12399;&#12365;&#12399;&#12365;&#12392;&#35441;&#12377;", "&#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12427;"),
  scores = c(1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 5, 3, 3, 3, 6,
             3, 3, 2, 4, 3, 3, 2, 3, 4, 4, 5, 3, 3, 2, 3,
             2, 2, 3, 2, 3, 3, 2, 3, 4, 4, 4, 4, 2, 2, 4,
             2, 2, 3, 1, 3, 2, 1, 3, 4, 4, 3, 3, 2, 3, 4,
             4, 4, 2, 1, 2, 2, 2, 3, 3, 4, 4, 3, 3, 6, 6,
             3, 3, 2, 2, 2, 2, 2, 3, 4, 3, 5, 3, 3, 3, 6,
             3, 3, 3, 3, 3, 2, 2, 3, 1, 4, 4, 3, 3, 4, 6,
             3, 3, 3, 2, 3, 3, 3, 2, 3, 4, 5, 5, 4, 4, 7,
             3, 3, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 3, 7,
             2, 2, 1, 3, 3, 3, 3, 3, 3, 6, 4, 5, 4, 3, 6,
             1, 1, 2, 3, 3, 3, 4, 3, 3, 1, 4, 6, 6, 6, 7,
             2, 2, 6, 4, 4, 5, 5, 5, 3, 1, 4, 6, 5, 4, 7,
             4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, 4, 7,
             2, 2, 5, 5, 5, 3, 3, 6, 5, 4, 4, 6, 5, 6, 6,
             2, 2, 7, 5, 5, 3, 3, 3, 2, 4, 4, 7, 4, 4, 6))

#&#12464;&#12522;&#12483;&#12489;&#12398;&#20316;&#25104;:makeRepgrid&#12467;&#12510;&#12531;&#12489;
TestGrid <- makeRepgrid(TestData)
#&#12473;&#12465;&#12540;&#12523;&#12398;&#35373;&#23450;:setScale&#12467;&#12510;&#12531;&#12489;
TestGrid <- setScale(TestGrid, 1, 7)
#&#12464;&#12522;&#12483;&#12489;&#12398;&#34920;&#31034;
TestGrid
########

#&#12464;&#12522;&#12483;&#12489;&#12487;&#12540;&#12479;&#12398;&#32113;&#35336;&#24773;&#22577;&#12434;&#34920;&#31034;:statsConstructs&#12467;&#12510;&#12531;&#12489;
#&#12467;&#12531;&#12473;&#12488;&#12521;&#12463;&#12488;&#12398;&#25991;&#23383;&#34920;&#31034;&#25968;:trim&#12458;&#12503;&#12471;&#12519;&#12531;
#&#38917;&#30446;&#30058;&#21495;&#12398;&#34920;&#31034;:index&#12458;&#12503;&#12471;&#12519;&#12531;
Result <- statsConstructs(TestGrid, trim = 10, index = TRUE)
#class&#30906;&#35469;
class(Result)
[1] "statsConstructs" "data.frame"
#&#32080;&#26524;&#12434;&#34920;&#31034;
Result
####################################
Desriptive statistics for constructs
####################################
vars  n mean   sd median trimmed  mad min max range  skew kurtosis   se
(1) &#32202;&#24373;&#12377;&#12427; - &#12522;&#12521;&#12483;&#12463;&#12473;       1 15 2.27 1.58      2    2.08 1.48   1   6     5  1.01    -0.12 0.41
(2) &#33258;&#20998;&#12364;&#12393;&#12358; - &#33258;&#20998;&#12364;&#12393;&#12358;     2 15 3.13 0.83      3    3.08 0.00   2   5     3  0.47    -0.41 0.22
(3) &#33258;&#20449;&#12364;&#12394;&#12356; - &#33258;&#20449;&#12364;&#12354;&#12427;     3 15 2.93 0.88      3    2.92 1.48   2   4     2  0.12    -1.79 0.23
(4) &#33510;&#25163;&#12391;&#12354;&#12427; - &#24471;&#24847;&#12391;&#12354;&#12427;     4 15 2.67 0.98      3    2.69 1.48   1   4     3 -0.22    -1.11 0.25
(5) &#36991;&#12369;&#12424;&#12358;&#12392; - &#36914;&#12435;&#12391;&#21462;&#12426;     5 15 3.27 1.44      3    3.23 1.48   1   6     5  0.51    -0.67 0.37
(6) &#38627;&#12375;&#12356; - &#12383;&#12420;&#12377;&#12356;           6 15 3.07 1.16      3    2.92 1.48   2   6     4  1.15     0.47 0.30
(7) &#28040;&#26997;&#30340;&#12391;&#12354; - &#31309;&#26997;&#30340;&#12391;&#12354;     7 15 3.13 1.13      3    3.08 0.00   1   6     5  0.60     0.87 0.29
(8) &#24907;&#24230;&#12364;&#12366;&#12371; - &#33258;&#28982;&#12394;&#24907;&#24230;     8 15 3.60 1.30      3    3.46 1.48   2   7     5  1.07     0.65 0.34
(9) &#12497;&#12491;&#12483;&#12463;&#12395; - &#33853;&#12385;&#30528;&#12356;&#12390;     9 15 3.40 1.18      3    3.23 0.00   2   7     5  1.67     3.00 0.31
(10) &#38957;&#12364;&#28151;&#20081;&#12377; - &#38957;&#12364;&#12399;&#12387;&#12365;   10 15 3.40 1.40      3    3.38 1.48   1   6     5  0.48    -0.61 0.36
(11) &#34920;&#24773;&#12364;&#12371;&#12431; - &#34920;&#24773;&#12364;&#33258;&#28982;   11 15 3.53 1.96      3    3.46 1.48   1   7     6  0.30    -1.26 0.51
(12) &#12388;&#12414;&#12425;&#12394;&#12356; - &#12424;&#12367;&#12375;&#12419;&#12409;   12 15 4.20 1.66      4    4.23 1.48   1   7     6 -0.30    -0.89 0.43
(13) &#21475;&#12372;&#12418;&#12427; - &#27005;&#12375;&#12356;         13 15 4.53 0.99      4    4.38 0.00   4   7     3  1.36     0.27 0.26
(14) &#35328;&#12356;&#12383;&#12356;&#12371; - &#12399;&#12365;&#12399;&#12365;&#12392;   14 15 4.47 1.41      5    4.54 1.48   2   6     4 -0.51    -1.20 0.36
(15) &#32202;&#24373;&#12377;&#12427; - &#35328;&#12356;&#12383;&#12356;&#12371;     15 15 4.07 1.67      4    4.00 1.48   2   7     5  0.42    -1.08 0.43

#&#12467;&#12531;&#12473;&#12488;&#12521;&#12463;&#12488;&#38291;&#12398;&#30456;&#38306;&#12434;&#35336;&#31639;:constructCor&#12467;&#12510;&#12531;&#12489;
#&#35336;&#31639;&#26041;&#27861;&#12434;&#25351;&#23450;:method&#12458;&#12503;&#12471;&#12519;&#12531;;"pearson","kendall","spearman"&#12398;&#25351;&#23450;&#12364;&#21487;&#33021;
CorResult <- constructCor(TestGrid, method = "spearman")
#class&#30906;&#35469;
class(CorResult)
[1] "constructCor" "matrix"
#&#32080;&#26524;&#12434;&#34920;&#31034;
CorResult

#RMS&#30456;&#38306;&#12434;&#35336;&#31639;:constructRmsCor&#12467;&#12510;&#12531;&#12489;
constructRmsCor(TestGrid)
##########################################
Root-mean-square correlation of constructs
##########################################
RMS
(1) &#32202;&#24373;&#12377;&#12427; - &#12522;&#12521;&#12483;&#12463;&#12473;&#12377;&#12427;                                           0.64
(2) &#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12390;&#12356;&#12427;&#12363;&#27671;&#12395;&#12394;&#12427; - &#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12424;&#12358;&#12392;&#27671;&#12395;&#12375;&#12394;&#12356; 0.27
(3) &#33258;&#20449;&#12364;&#12394;&#12356; - &#33258;&#20449;&#12364;&#12354;&#12427;                                             0.46
(4) &#33510;&#25163;&#12391;&#12354;&#12427; - &#24471;&#24847;&#12391;&#12354;&#12427;                                             0.45
(5) &#36991;&#12369;&#12424;&#12358;&#12392;&#12377;&#12427; - &#36914;&#12435;&#12391;&#21462;&#12426;&#32068;&#12416;                                     0.47
(6) &#38627;&#12375;&#12356; - &#12383;&#12420;&#12377;&#12356;                                                   0.58
(7) &#28040;&#26997;&#30340;&#12391;&#12354;&#12427; - &#31309;&#26997;&#30340;&#12391;&#12354;&#12427;                                         0.50
(8) &#24907;&#24230;&#12364;&#12366;&#12371;&#12385;&#12394;&#12356; - &#33258;&#28982;&#12394;&#24907;&#24230;                                       0.65
(9) &#12497;&#12491;&#12483;&#12463;&#12395;&#12394;&#12427; - &#33853;&#12385;&#30528;&#12356;&#12390;&#12356;&#12427;                                     0.63
(10) &#38957;&#12364;&#28151;&#20081;&#12377;&#12427; - &#38957;&#12364;&#12399;&#12387;&#12365;&#12426;&#12375;&#12390;&#12356;&#12427;                                0.53
(11) &#34920;&#24773;&#12364;&#12371;&#12431;&#12400;&#12427; - &#34920;&#24773;&#12364;&#33258;&#28982;                                        0.52
(12) &#12388;&#12414;&#12425;&#12394;&#12356; - &#12424;&#12367;&#12375;&#12419;&#12409;&#12427;                                          0.40
(13) &#21475;&#12372;&#12418;&#12427; - &#27005;&#12375;&#12356;                                                  0.59
(14) &#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12394;&#12356; - &#12399;&#12365;&#12399;&#12365;&#12392;&#35441;&#12377;                            0.41
(15) &#32202;&#24373;&#12377;&#12427; - &#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12427;                                    0.39

Average of statistic 0.5 
Standard deviation of statistic 0.1 

#&#12467;&#12531;&#12473;&#12488;&#12521;&#12463;&#12488;,&#12456;&#12524;&#12513;&#12531;&#12488;&#38291;&#12398;&#36317;&#38626;&#12434;&#35336;&#31639;:distance&#12467;&#12510;&#12531;&#12489;
#&#35336;&#31639;&#26041;&#27861;&#12434;&#25351;&#23450;:dmethod&#12458;&#12503;&#12471;&#12519;&#12531;;"euclidean","maximum","manhattan",
#"canberra","binary","minkowski"&#12364;&#25351;&#23450;&#21487;&#33021;
#&#36317;&#38626;&#12398;&#23550;&#35937;&#12434;&#25351;&#23450;:along&#12458;&#12503;&#12471;&#12519;&#12531;;1:&#12467;&#12531;&#12473;&#12488;&#12521;&#12463;&#12488;,2:&#12456;&#12524;&#12513;&#12531;&#12488;
distance(TestGrid, along = 2, dmethod = "euclidean")

#&#20027;&#25104;&#20998;&#20998;&#26512;&#12434;&#23455;&#26045;:constructPca&#12467;&#12510;&#12531;&#12489;
constructPca(TestGrid, nf=3)
#################
PCA of constructs
#################
Number of components extracted: 3
Type of rotation: varimax 

Loadings:
  RC1   RC2   RC3  
&#32202;&#24373;&#12377;&#12427; - &#12522;&#12521;&#12483;&#12463;&#12473;&#12377;&#12427;                                            0.79  0.30  0.40
&#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12390;&#12356;&#12427;&#12363;&#27671;&#12395;&#12394;&#12427; - &#33258;&#20998;&#12364;&#12393;&#12358;&#24605;&#12431;&#12428;&#12424;&#12358;&#12392;&#27671;&#12395;&#12375;&#12394;&#12356;  0.06 -0.31  0.75
&#33258;&#20449;&#12364;&#12394;&#12356; - &#33258;&#20449;&#12364;&#12354;&#12427;                                              0.21  0.26  0.89
&#33510;&#25163;&#12391;&#12354;&#12427; - &#24471;&#24847;&#12391;&#12354;&#12427;                                              0.36  0.14  0.73
&#36991;&#12369;&#12424;&#12358;&#12392;&#12377;&#12427; - &#36914;&#12435;&#12391;&#21462;&#12426;&#32068;&#12416;                                      0.87 -0.17  0.04
&#38627;&#12375;&#12356; - &#12383;&#12420;&#12377;&#12356;                                                    0.82  0.00  0.43
&#28040;&#26997;&#30340;&#12391;&#12354;&#12427; - &#31309;&#26997;&#30340;&#12391;&#12354;&#12427;                                          0.77  0.21  0.07
&#24907;&#24230;&#12364;&#12366;&#12371;&#12385;&#12394;&#12356; - &#33258;&#28982;&#12394;&#24907;&#24230;                                        0.86  0.33  0.25
&#12497;&#12491;&#12483;&#12463;&#12395;&#12394;&#12427; - &#33853;&#12385;&#30528;&#12356;&#12390;&#12356;&#12427;                                      0.88  0.22  0.26
&#38957;&#12364;&#28151;&#20081;&#12377;&#12427; - &#38957;&#12364;&#12399;&#12387;&#12365;&#12426;&#12375;&#12390;&#12356;&#12427;                                  0.60  0.24  0.49
&#34920;&#24773;&#12364;&#12371;&#12431;&#12400;&#12427; - &#34920;&#24773;&#12364;&#33258;&#28982;                                          0.56  0.69 -0.12
&#12388;&#12414;&#12425;&#12394;&#12356; - &#12424;&#12367;&#12375;&#12419;&#12409;&#12427;                                            0.15  0.88 -0.19
&#21475;&#12372;&#12418;&#12427; - &#27005;&#12375;&#12356;                                                    0.72  0.53  0.11
&#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12394;&#12356; - &#12399;&#12365;&#12399;&#12365;&#12392;&#35441;&#12377;                              0.12  0.78  0.28
&#32202;&#24373;&#12377;&#12427; - &#35328;&#12356;&#12383;&#12356;&#12371;&#12392;&#12364;&#35328;&#12360;&#12427;                                      0.06  0.85  0.14

RC1  RC2  RC3
SS loadings    5.57 3.43 2.76
Proportion Var 0.37 0.23 0.18
Cumulative Var 0.37 0.60 0.78
Warning message:
  In cor.smooth(r) : Matrix was not positive definite, smoothing was done

#&#12463;&#12521;&#12473;&#12479;&#12540;&#20998;&#26512;&#12434;&#23455;&#26045;:cluster&#12467;&#12510;&#12531;&#12489;
#&#36317;&#38626;&#12398;&#35336;&#31639;&#26041;&#27861;&#12434;&#25351;&#23450;:dmethod&#12458;&#12503;&#12471;&#12519;&#12531;;"euclidean","maximum","manhattan",
#"canberra","binary","minkowski"&#12364;&#25351;&#23450;&#21487;&#33021;
#&#32080;&#21512;&#26041;&#27861;&#12434;&#25351;&#23450;:cmethod&#12458;&#12503;&#12471;&#12519;&#12531;;"ward","single","complete","average",
#"mcquitty","median","centroid"&#12364;&#25351;&#23450;&#21487;&#33021;
cluster(TestGrid, dmethod = "euclidean", cmethod = "complete")

#bertin&#12503;&#12525;&#12483;&#12488;&#12398;&#20316;&#25104;:bertin&#12467;&#12510;&#12531;&#12489;
#&#25968;&#20516;&#12398;&#34920;&#31034;:showvalues&#12458;&#12503;&#12471;&#12519;&#12531;
#&#38917;&#30446;&#30058;&#21495;&#12398;&#34920;&#31034;:id&#12458;&#12503;&#12471;&#12519;&#12531;
bertin(TestGrid, color = c("white", "#5c463e"),
       showvalues = TRUE, id = c(FALSE, FALSE))

#&#12463;&#12521;&#12473;&#12479;&#20184;&#12365;&#12398;bertin&#12503;&#12525;&#12483;&#12488;&#12398;&#20316;&#25104;:bertinCluster&#12467;&#12510;&#12531;&#12489;
bertinCluster(TestGrid, color = c("white", "#5c463e"),
              showvalues = TRUE, id = c(FALSE, FALSE),
              type = "rectangle", align = FALSE,
              dmethod = c("euclidean", "euclidean"),
              cmethod = c("complete", "complete"),
              draw.axis = TRUE)

#biplot&#12398;&#20316;&#25104;:biplotSimple&#12467;&#12510;&#12531;&#12489;
biplotSimple(TestGrid, c.label.col = "#f5c971")

出力例

・clusterコマンド

・bertinコマンド

・bertinClusterコマンド

・biplotSimpleコマンド


少しでも、あなたの解析が楽になりますように!!
けものフレンズ、奥が深いです。ぺぱぷらいぶ、気になります。

タイトルとURLをコピーしました