SlideShare a Scribd company logo
1 of 64
Download to read offline
Mplusによる統計解析
~初心者による初心者のための解説~
甲南大学大学院人文科学研究科
日本学術振興会特別研究員DC2
松尾和弥
目的
Mplusに興味があるけど使ったことがない
という方に向けて, Mplusの使い方を
簡単に説明するためのスライドです。
ですので, Mplusユーザーにとって
目新しい内容は含まれていません。
※というか松尾がMplusのことを詳しく説明できない
間違いがあったらすみません。
2
発表者について
氏名 : 松尾和弥
所属 : 甲南大学大学院人文科学研究科
日本学術振興会
資格 : 臨床心理士
Mplus歴: 約1年(ほぼ初心者)
※一応,以下の論文執筆等にMplusを使用
松尾他(印刷中)被虐待経験が対人ライフイベントに及ぼす影響―
愛着スタイルの媒介効果の検討― 子ども虐待とネグレクト
3
アジェンダ
・ Mplusとは
・ Mplusの基本
・ 僕の思うMplusの魅力
・ RでMplusを動かす
4
5
Mplusとは
Mplusとは ①
Muthénらが開発した構造方程式モデリング用の
ソフトウェア
様々な分析を行うことが可能
⇒ 回帰分析・媒介分析・階層線形モデル
因子分析・項目反応理論・潜在クラスモデル等
データハンドリングは不得意
⇒ 一応できるらしい。
6
Mplusとは ②
Mplusの公式HPで購入可能
https://www.statmodel.com/index.shtml
大学教員だと$595~$895
学生だと$195~$350
高機能なバージョンほど高いが,
一度購入すればそれを使い続けることができる。
7
Mplusとは ③
分析の実行にCUIを採用。
⇒ 代筆機能はある。
入力はすべて英語
⇒ 日本語が含まれると分析がうまくいかない。
アルファベット入力するだけであるため,
英文法を理解できなくても利用可能。
8
Mplusとは ④ エディタ画面(コードを書く場所) 9
Mplusとは ⑤ エディタ画面(コード記入後) 10
Mplusとは ⑥ 分析の出力画面 11
コードの下に分析結果が記述されている(これは出力の一部)
12
Mplusの基本
ーデータファイル編ー
① SPSSのようにデータを直接読み込まない。
・分析するたびに毎回使用するデータを
明示しなければならない。
13
↑は分析に使用するデータが
「Cドライブの中にあるmplusフォルダの中のsample03.txtである」
と指定
② 読み込むデータはテキストかCSV形式
・Excelファイルを直接読み込むことはできない。
・Excelファイルでデータを保存している場合は
テキストかCSV形式への変換が必要。
14
データの変換
③ 読み込むデータに変数名を含めない(CSV)
・変数名を含めると分析が走らない。
15
× 〇
③ 読み込むデータに変数名を含めない(txt)
・変数名を含めると分析が走らない。
16
× 〇
④ データを保存する専用フォルダの作成
・分析時にファイルパスを指定する必要がある
⇒ 毎回ファイルパスが異なると,
ファイルパスを間違いやすい。
+
・ Mplusが日本語に対応していない
⇒ フォルダ名もダメ
17
④ データを保存する専用フォルダの作成
・松尾はCドライブの中にMplus用のフォルダを
作成
18
19
Mplusの基本
ーコマンド編ー
① 文章はすべて半角英数字
・分析
20
※大文字・小文字の区別はなし
② 文末にはセミコロン
・分析
21
③ ISやAREでなく=でもOK
・分析
22
④ TITLE:分析のタイトル(なくても問題ない)
・分析
23
⑤ DATA:使うデータファイルの指定
・分析
24
⑥ VARIABLE:変数の指定
・分析
25
NAMESにはデータファイルにある
全ての変数名を記述
⇒ 変数と変数の間はスペース
⇒ A1 A2 A3であればA1-3と
省略可能
⇒ 変数名は8字まで
USERVARIABLESには
使用する変数名を記述
⑥ VARIABLE:変数の指定
・分析
26
NAMESにはデータファイルにある
全ての変数名を記述
⇒ 変数と変数の間はスペース
⇒ A1 A2 A3であればA1-3と
省略可能
USERNAMESには
使用する変数名を記述
欠損値を指定する場合は
MISSINGで指定
⇒ 今回は欠損値をピリオドと
指定
⑦ ANALYSIS:分析方法の指定
・分析
27
TYPEは分析に応じて選択
GENERAL :SEM等
TWOLEVEL:マルチレベル分析
EFA :探索的因子分析
MIXTURE :潜在クラス分析
⑦ ANALYSIS:分析方法の指定
・分析
28
ESTIMATORは推定方法
ML :最尤法
MLR :ロバスト最尤法
WLS :重み付き最小二乗法
WLSMV :ロバスト重み付き最小二乗法
ULS :重みなし最小二乗法
ULSMV :ロバスト重みなし最小二乗法
GLS :一般化最小二乗法
BAYES :ベイズ推定法
⑧ MODEL:モデルの指定
・分析
29
kyuryo と ningen から syokumu に及ぼす影響を検討
⑧ MODEL:モデルの指定 30
⑧ MODEL:モデルの指定 別ver 31
⑧ MODEL:モデルの指定 別ver 32
⑨ OUTPUT:出力の設定
・分析
33
SAMPSTAT :サンプルの統計量
STANDARDIZED :標準化係数
STDYX :独立変数と従属変数両方を
標準化した係数
MODINDICES :修正指標
CINTERVAL :信頼区間
⑩ 分析の実行:出力の設定
・分析
34
⑩ 分析の実行:出力の設定
・RUNを押して以下のポップアップウィンドウで
「はい」を選択するとinputファイルと
outputファイルの保存場所を選択。
35
⑩ 分析の実行:出力の設定
inputファイル
・分析コードが保存されたファイル
outputファイル
・分析結果が保存されたファイル
分析実行後,inputファイルとoutputファイルが保存
36
⑩ 分析の実行:出力の設定
データの流れ
37
データの変換
out
inp
Mplusで
読み込み分析
⑪ 分析結果:ダイアグラム 38
⑪ 分析結果:ダイアグラム 39
⑪ 分析結果 40
⑪ 分析結果:適合度情報 41
⑪ 分析結果:標準化偏回帰係数 42
※STDYX:従属変数と独立変数双方を標準化
※STDY:従属変数を標準化
43
僕の思うMplusの魅力
柔軟な分析が可能 ①
例えば以下のモデルで間接効果を検討したいとする。
44
A1
A2
A3
.30 .50
間接効果?
他の変数(媒介変数)を介して与える効果の大きさ
前のスライドの例であれば,
A1がA2を介してA3に及ぼす因果的効果のこと
間接効果の大きさは,因果連鎖をなすパス係数の
積で表される(例:.30×.50=.15)。
→ これの有意性を確認しないと媒介モデルの結果を
正確に解釈できない。
45
柔軟な分析が可能 ②
A2・A3が正規分布に従う変数であれば
多くのソフトウェアで検討可能。
・SPSS :Andrew F. Hayes博士のマクロを
ダウンロードすれば可
・HAD :ソルバーオン版をダウンロードして
構造方程式モデリングで可
・STATA:SEMのオプションから可
・R :できるらしい(松尾はやったことがない)
46
柔軟な分析が可能 ③
しかし, A2・A3が正規分布に従わない変数であれば
分析できないソフトウェアが多い。
・SPSS :不可
・HAD :不可
・STATA:分析はできるが間接効果の検定は
行えない。
・R :不明
⇒ Mplusであればできる!
47
柔軟な分析が可能 ④
Mplusであれば様々な変数を柔軟に扱うことが可能。
・二値変数
・カウントデータ
・カテゴリカル変数
・打ち切りデータ
など
データの生成過程に沿ったモデリングが可能!
48
49
RでMplusを動かす
Mplusの弱点
①「データフレームに変数名を入れてはいけない」
という独自ルール
→ データフレームの準備が面倒
→ 分析の数だけデータフレームが必要になる
②モデル比較が苦手
→ 潜在クラスモデルのようにクラス数の選択の
ために複数モデルを立てる場合に面倒
50
MplusAutomation
MplusAutomationを使えばMplus弱点を緩和できる
かもしれない。
MplusAutomationはRのパッケージの一つで
RからMplusを動かそうとするもの。
R言語の柔軟性とMplusの強力なモデリング機能が
組み合わさる。
51
MplusAutomationのメリット
① データハンドリングから分析までを
Rで一括管理できるようになる。
→ ソフトウェア変更の手間が省ける。
→ 「 再生可能性 」の向上
② 潜在クラス分析のような複数のモデルを
比較する際の負担を軽減
52
MplusAutomation実践①
Rにもともと入っているirisデータを使って
MplusAutomationを練習してみる。
53
54
データハンドリング
※必須ではない
データハンドリング
irisデータをmplusで分析できるように,
prepareMplusDATA()でdatファイルとして保存。
下記では,irisデータの1~4行目のみを選択。
⇒ 5行目は文字列で分析できないため。
55
データハンドリング
prepareMplusDATA()を実行後,変数名がなく
Mplusで分析できる形式のデータが保存される。
56
57
分析方法ver 1
※prepareMplusDATA()で
datファイルを事前に作成する必要がない方法
分析方法 ver 1
mplusobjectでMplusのエディタ画面に書くコードを
mplusオブジェクトとして格納。
その後,mplusModeleterでその分析を走らせる。
※8文字以上の変数はMplusで扱えないので
名前を省略後に分析を行っている。
58
分析方法 ver 1
分析結果をresultsに格納しておいたので,
コンソールでresultsを実行すれば,
分析結果を確認することができる。
59
分析方法 ver 1
もちろん,分析結果はoutファイルとして
作業ディレクトリにも保存されている。
60
61
分析方法ver 2
※prepareMplusDATA()で
datファイルを事前に作成する必要がある方法
分析方法 ver2
すでに作業ディレクトリ内に以下のような
inpファイルを用意している場合に
runmodels()でそれを実行する。
※inpファイルで指定したdatファイルがないと×
62
分析方法 ver2
runmodels()で実行したいinpファイルを指定
すると,その内容でMplusの分析が実行される。
例えば,”Regression.inp”というinpファイルを
実行すると”Regression.out”というoutファイルに
分析結果が保存される。
readmodels()を使えば,分析結果をRに読み込む
ことが可能。
63
本スライドで紹介したMplusAutomationの関数
prepareMplusDATA() : mplus用のデータを作成
mplusobject() : mplusオブジェクトを作成
mplusModeleter() : mplusオブジェクトの
分析を実行
runmodels() :inpファイルの分析を実行
readmodels() :outファイルを読み込む
64

More Related Content

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Mplusによる統計解析