1 Check installations 2 Open Mplus 3 Type basic commands 4 Get data read in, spat out - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

1 Check installations 2 Open Mplus 3 Type basic commands 4 Get data read in, spat out

Description:

... over data at the start of a file ... You data (the subset of variables that you modelled only, or ... Bob the (re)-builder walk through. Reading data with ... – PowerPoint PPT presentation

Number of Views:130
Avg rating:3.0/5.0
Slides: 51
Provided by: timcro
Category:

less

Transcript and Presenter's Notes

Title: 1 Check installations 2 Open Mplus 3 Type basic commands 4 Get data read in, spat out


1
Session 1
  • 1 Check installations2 Open Mplus3 Type basic
    commands4 Get data read in, spat out read in
    again5 Run an analysis6 What has it done?

2
Session 2
  • 1 Mplus input file command structures2 Mplus
    conventions
  • 3 Mplus punctuation CaSeS (.) green!4
    Common typos in input
  • 5 Mplus output file structure
  • 6 Output options inc. saves and plots

3
Session 1
  • 1 Check installations2 Open Mplus3 Type basic
    commands4 Get data read in, spat out read in
    again5 Run an analysis6 What has it done?

4
  • Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2
  • 7 5 12 1 7 5 12 1
  • 4 4 8 1 4 3 7 1
  • 12 10 22 1 12 12 24 1
  • 5 5 10 1 7 7 14 1
  • 3 7 10 1 3 5 8 1
  • 4 2 6 0 3 1 4 0
  • 3 5 8 1 2 3 5 0
  • 2 2 4 0 3 3 6 0
  • 7 7 14 1 6 8 14 1
  • 3 3 6 0 2 3 5 0
  • 0 2 2 0 3 2 5 0
  • 11 11 22 1 8 8 16 1
  • 12345678901234567890123456789012
  • 12341234XXXX123412341234XXXX1234

DATA Dunn Statistics in Psychiatry GHQ12 T1
T2 Clinical Psychology students
General Health Questionnaire Short self-report
questionnaire Used to screen for common
mental Disorder (anxiety and depression)
5
Warning, detour ahead
6
Getting (past) the basics
  • The importance of total control over data
  • The value of learning simple FORTRAN formatting
    statements
  • LISCOMP, the predecessor to Mplus,
  • And Mplus itself, is written in FORTRAN
  • Reading data in uses simple conventions
  • F / I / G / E / X / T
  • 34.234 could be read as F6
  • 92 read as F2.1 would be 9.1
  • Width in columns for the real number
  • then number of numerals that appear after the
    decimal point

7
Overcoming limitations
  • Of the Mplus demo
  • It has a limit on the number of variables
  • Depending on what analysis you are doing these
    limits are
  • 4 variables
  • 6 variables
  • We shall (largely) work within them
  • But we can also beat them to make life easier for
    you

8
FORTRAN FORMATSTATEMENTS
  • I X T and /
  • I1
  • Integer single digit
  • 4X
  • skip four columns without reading anything
  • Can jump over data in the middle of a file this
    way
  • i.e. columns in text files can be ignored
  • T10
  • Jump from first column to and start reading at
    column ten, then process rest of format
    instructions
  • Can jump over data at the start of a file this
    way
  • / is to jump to next line (when data has more
    records lines of data per individidual)
  • 001 1 2 3
  • 4 5 6 rather than
    001 1 2 3 4 5 6

9
Specifications for formatted inputsome F5 some F6

Dunn SiP Book GHQ12 from clinical
psychology students Odd1 Even1 Sum1 Case1
Odd2 Even2 Sum2Case2 ---------------------------
--------------- 7 5 12 1 7
5 12 1 4 4 8 1 4 3
7 1 12 10 22 1 12 12 24
1 5 5 10 1 7 7 14
1 3 7 10 1 3 5 8 1
4 2 6 0 3 1 4 0
3 5 8 1 2 3 5 0 2
2 4 0 3 3 6 0 7 7
14 1 6 8 14 1 3 3
6 0 2 3 5 0 0 2 2
0 3 2 5 0 11 11 22 1
8 8 16 1 1234512345123451234561234
51234561234512345 Numbered columns for field
widths (guide for eye and FORTRAN SYNTAX) F5
F5 F5 F6 F5 F6 F5 F5 i.e
(3F5,F6,F5,F6,2F5)
10
End of detour
11
Analysis time
  • Time to begin!
  • A first orientation to Mplus in action
  • Data
  • Input file syntax
  • Output
  • Plot
  • Actually just doing data transformation at this
    stage
  • Not doing any analysis

12
  • Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2
  • 7 5 12 1 7 5 12 1
  • 4 4 8 1 4 3 7 1
  • 12 10 22 1 12 12 24 1
  • 5 5 10 1 7 7 14 1
  • 3 7 10 1 3 5 8 1
  • 4 2 6 0 3 1 4 0
  • 3 5 8 1 2 3 5 0
  • 2 2 4 0 3 3 6 0
  • 7 7 14 1 6 8 14 1
  • 3 3 6 0 2 3 5 0
  • 0 2 2 0 3 2 5 0
  • 11 11 22 1 8 8 16 1
  • 12345678901234567890123456789012
  • 12341234XXXX123412341234XXXX1234

DATA Dunn Statistics in Psychiatry GHQ12 T1
T2 Clinical Psychology students
General Health Questionnaire Short self-report
questionnaire Used to screen for common
mental Disorder (anxiety and depression)
13
Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2 7
5 12 1 7 5 12 1ltsnipgt 3 3 6 0
2 3 5 011 11 22 1 8 8 16 1
DATA FILE IS "c\dunn_ghqoddeven12.dat"
FORMAT IS I4 I4 4x I4 I4 I4 4x I4
14
Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2 7
5 12 1 7 5 12 1ltsnipgt 3 3 6 0
2 3 5 011 11 22 1 8 8 16 1
DATA FILE IS "c\dunn_ghqoddeven12.dat"
FORMAT IS I4 I4 4x I4 I4 I4 4x I4 DEFINE
sum1 odd1 even1 diff1 odd1 - even1
!sum2 odd2 even2 !diff2 odd2 - even2
VARIABLE NAMES ARE odd1 even1 case1 odd2
even2 case2 File actually contains SUM1 SUM2
variables USEVARIABLES ARE sum1 diff1
This file is dunn_GHQ12_T1T2_ClinPsych_SiP.inp
WARNING - more syntax below in the file
estimates a correlation and produces a scatter
plot
15
Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2 7
5 12 1 7 5 12 1ltsnipgt 3 3 6 0
2 3 5 011 11 22 1 8 8 16 1
ANALYSIS ESTIMATORML MODEL sum1 with
diff1 !sum1 with diff1 sum2 diff2 ! diff1
with sum2 diff2 ! sum2 with
diff2 OUTPUT STDY SAMPSTAT PLOT TYPE IS
PLOT1
This file is dunn_GHQ12_T1T2_ClinPsych_SiP.inp
16
ANALYSIS ESTIMATORML MODEL sum1 with
diff1 !sum1 with diff1 sum2 diff2 ! diff1
with sum2 diff2 ! sum2 with
diff2 OUTPUT STDY SAMPSTAT PLOT TYPE IS
PLOT1
This file is dunn_GHQ12_T1T2_ClinPsych_SiP.inp
17
  • SUMMARY OF ANALYSIS dunn_GHQ12_T1T2_ClinPsych_SiP
    .out
  • Number of groups
    1
  • Number of observations
    12
  • Number of dependent variables
    2
  • Number of independent variables
    0
  • Number of continuous latent variables
    0
  • Observed dependent variables
  • Continuous
  • SUM1 DIFF1

18
  • dunn_GHQ12_T1T2_ClinPsych_SiP.out
  • Estimator
    ML
  • Information matrix
    OBSERVED
  • Maximum number of iterations
    1000
  • Convergence criterion
    0.500D-04
  • Maximum number of steepest descent iterations
    20
  • Input data file(s)
  • c\dunn_ghqoddeven12.dat
  • Input data format
  • (I4 I4 4X I4 I4 I4 4X I4)

dunn_GHQ12_T1T2_ClinPsych_SiP.out
19
dunn_GHQ12_T1T2_ClinPsych_SiP.out
  • SAMPLE STATISTICS dunn_GHQ12_T1T2_ClinPsych_SiP.o
    ut
  • Means
  • SUM1 DIFF1
  • ________ ________
  • 1 10.333 -0.167
  • Covariances
  • SUM1 DIFF1
  • ________ ________
  • SUM1 37.222
  • DIFF1 3.389 2.972
  • Correlations
  • SUM1 DIFF1
  • ________ ________
  • SUM1 1.000
  • DIFF1 0.322 1.000

20
  • THE MODEL ESTIMATION TERMINATED NORMALLY
  • TESTS OF MODEL FIT
  • Chi-Square Test of Model Fit
  • Value
    0.000
  • Degrees of Freedom
    0
  • P-Value
    0.0000
  • Chi-Square Test of Model Fit for the Baseline
    Model
  • Value
    1.315
  • Degrees of Freedom
    1
  • P-Value
    0.2515
  • CFI/TLI
  • CFI
    1.000
  • TLI
    1.000
  • Loglikelihood
  • H0 Value
    -61.634
  • H1 Value -61.634

dunn_GHQ12_T1T2_ClinPsych_SiP.out
21
  • MODEL RESULTS Two-Tailed
  • Estimate S.E.
    Est./S.E. P-Value
  • SUM1 WITH
  • DIFF1 3.389 3.190
    1.062 0.288
  • Means
  • SUM1 10.333 1.761
    5.867 0.000
  • DIFF1 -0.167 0.498
    -0.335 0.738
  • Variances
  • SUM1 37.221 15.195
    2.450 0.014
  • DIFF1 2.972 1.213
    2.449 0.014
  • STANDARDIZED MODEL RESULTS
  • STDY Standardization
    Two-Tailed
  • Estimate S.E.
    Est./S.E. P-Value
  • SUM1 WITH
  • DIFF1 0.322 0.259
    1.245 0.213
  • Means
  • SUM1 1.694 0.450
    3.761 0.000

dunn_GHQ12_T1T2_ClinPsych_SiP.out
22
dunn_GHQ12_T1T2_ClinPsych_SiP.out/gph
23
Session 2
  • 1 Mplus input file COMMAND STRUCTURES2 Mplus
    conventions
  • 3 Mplus punctuation (.) green!
    comment4 Common typos in input
  • 5 Mplus output file structure
  • 6 Output options inc. saves and plots

24
Command Structures
  • TITLE
  • DATA
  • VARIABLE
  • DEFINE
  • ANALYSIS
  • MODEL
  • OUTPUT
  • SAVEDATA
  • PLOT

Simple command structures can be built from the
GUI
25
Conventions
  • Main command structures appear first on lines as
  • BLOCK CAPS OTHER COMMANDS THEN FOLLOW
  • either IN CAPS or lowercase
  • All lines end with a
  • but lines can run
  • over more than one line and end with a
    colon

26
Weve seen this already
TITLE DATA VARIABLE DEFINE ANALYSIS MODEL OU
TPUT SAVEDATA PLOT
Mplus does not mind which Order commands come in
. You do not need them all! Actually you can
do a lot With a little!
27
Mplus is not CaSe SeNsItIvE
! Exclamations - are like comment statements, the
editor turns them green
28
All lines end with a semi-colon
The most common typo is probably omitting
one of these or typing two
29
( Mplus parameters )
  • Variances or Residual Variances
  • Variable name without brackets
  • Means or Thresholds catvar1
  • Variable name in square brackets
  • (round brackets)
  • Variable name in round brackets
  • Scale factors
  • Variable name in curly brackets

30
Mplus output file structure-has to be seen to be
believed!
  • OUTPUT options here govern what you will see in
    the text output file
  • SAVEDATA options here will determine what else
    is saved in new text files
  • PLOT options here will enable you to view graphs
    of certain things

31
OUTPUT and PLOT
  • OUTPUT !many more!
  • SAMP
  • STAND
  • RES ! short for residuals)
  • MOD (number)
  • CINT !(three types)
  • TECHn !(14 types-nos 1 to 14)
  • FSCOEFF
  • FSDETERMINACY
  • a few more
  • dont forget that final colon
  • PLOT TYPE IS
  • PLOT1
  • PLOT2 or
  • PLOT3 ! Thats about it

32
SAVEDATA
  • You can save
  • You data (the subset of variables that you
    modelled only, or these variables plus some more
    that you want to keep even though you did not use
    them e.g. IDVARIABLE a subid or AUXILIARY other
    variables such as sex etc.
  • You can also save
  • Factor scores (appended to your data)
  • Latent class memberships
  • Cooks distances or influence statistics
  • There are also other things you can save .
  • These depend on what analysis you have constructed

33
Watch out for the GUIspot here .. (if you want
it)
34
Watch out for the GUI-2
35
GUI doesnt build this part
E1 E2
E3 E4
V1
V2
V3
V4
F1
F2
36
GHQ T1 T2Psychological Distress
E1 E2
E3 E4
Odd 1
Even 1
Odd 2
Even 2
GHQ T1
GHQ T2
Correlation Among GHQ scores at T1 and T2 (could
be regression)
37
Acronyms / Abbreviations / Fit
  • Chi-Square Pearson and Likelihood Ratio
  • CFI/TLI
  • Loglikelihood H0 Value H1 Value
  • Information Criteria
  • Akaike (AIC)
  • Bayesian (BIC)
  • Sample-Size Adjusted BIC (n (n 2) / 24)
  • RMSEA Root Mean Square Error Of Approximation
  • SRMR Standardized Root Mean Square Residual

38
  • TITLE
  • Dunn SiP Book
  • GHQ12 from clinical psychology students
  • Odd1 Even1 Sum1 Case1 Odd2 Even2 Sum2 Case2
  • 7 5 12 1 7 5 12 1
  • 4 4 8 1 4 3 7 1
  • 12 10 22 1 12 12 24 1
  • 5 5 10 1 7 7 14 1
  • 3 7 10 1 3 5 8 1
  • 4 2 6 0 3 1 4 0
  • 3 5 8 1 2 3 5 0
  • 2 2 4 0 3 3 6 0
  • 7 7 14 1 6 8 14 1
  • 3 3 6 0 2 3 5 0
  • 0 2 2 0 3 2 5 0
  • 11 11 22 1 8 8 16 1
  • DATA

39
Out and back Bob the (re)-builder walk through
  • Reading data with a fixed format
  • Same kind of data now, bigger dataset
  • Do an analysis and save data
  • Then read back in formatted
  • hals_ighq.inp
  • Then
  • read_savehalstxt.inp

40
Passing out variablesquick2_rebuild2.inp
Little words IS/ARE are optional
  • DATA
  • FILE IS c\halsghq3.dat
  • VARIABLE
  • NAMES ARE GHQ22 GHQ24 GHQ28
  • AGEYRS IDNUM
    SEXM1F2
  • USEVARIABLES ARE AGEYRS GHQ22 GHQ24 GHQ28
  • CATEGORICAL ARE GHQ22 GHQ24 GHQ28
  • IDVARIABLE IDNUM
  • AUXILIARY SEXM1F2
  • MODEL
  • IGHQ BY GHQ22 GHQ24 GHQ28!define IGHQ measured
    BY 3vars
  • IGHQ ON AGEYRS !Here regressing latent factor
    ON age
  • SAVEDATA
  • FILE IS savedata.txt

41
HALSGHQ3.DAT
  • "halsGHQ3.dat
  • 1.000 0.000 0.000 65.000 8514
    2.000
  • 0.000 0.000 0.000 74.000 7642
    1.000
  • 0.000 1.000 0.000 62.000 12249
    2.000
  • 2.000 0.000 2.000 46.000 12024
    1.000
  • 0.000 0.000 0.000 44.000 8808
    2.000
  • 0.000 0.000 1.000 32.000 4863
    2.000
  • 1.000 0.000 0.000 22.000 4849
    1.000
  • 0.000 0.000 0.000 60.000 8005
    2.000
  • 0.000 1.000 0.000 36.000 5923
    1.000
  • 0.000 0.000 0.000 58.000 3080
    1.000
  • 1.000 0.000 1.000 63.000 4446
    1.000
  • 0.000 0.000 0.000 69.000 6357
    1.000
  • ltsnipped after a dozen linesgt

GHQ22 GHQ24 GHQ28 AGEYRS IDNUM SEXM1F2
42
Output .
  • SUMMARY OF ANALYSIS
  • Number of groups
    1
  • Number of observations
    6553
  • Number of dependent variables
    3
  • Number of independent variables
    1
  • Number of continuous latent variables
    1
  • Observed dependent variables
  • Binary and ordered categorical (ordinal)
  • GHQ22 GHQ24 GHQ28
  • Observed independent variables
  • AGEYRS
  • Observed auxiliary variables
  • SEXM1F2
  • Continuous latent variables
  • IGHQ
  • Variables with special functions
  • ID variable IDNUM

43
Output ..
  • SAVEDATA INFORMATION
  • Order and format of variables
  • GHQ22 F10.3
  • GHQ24 F10.3
  • GHQ28 F10.3
  • AGEYRS F10.3
  • IDNUM I6
  • SEXM1F2 F10.3
  • Save file
  • savedata.txt
  • Save file format
  • 4F10.3 I6 F10.3
  • Save file record length 5000

1.000 0.000 0.000 65.000 8514
2.000 0.000 0.000 0.000 74.000
7642 1.000 0.000 1.000 0.000
62.000 12249 2.000 2.000 0.000
2.000 46.000 12024 1.000 0.000
0.000 0.000 44.000 8808 2.000
0.000 0.000 1.000 32.000 4863
2.000 1.000 0.000 0.000 22.000
4849 1.000 0.000 0.000 0.000
60.000 8005 2.000 0.000 1.000
0.000 36.000 5923 1.000 0.000
0.000 0.000 58.000 3080 1.000
1.000 0.000 1.000 63.000 4446
1.000 0.000 0.000 0.000 69.000
6357 1.000
44
Quick2rebuildout.out
  • INPUT READING TERMINATED NORMALLY
  • SUMMARY OF ANALYSIS
  • Number of groups
    1
  • Number of observations
    6553
  • Number of dependent variables
    3
  • Number of independent variables
    1
  • Number of continuous latent variables
    1
  • Observed dependent variables
  • Binary and ordered categorical (ordinal)
  • GHQ22 GHQ24 GHQ28
  • Observed independent variables
  • AGEYRS
  • Observed auxiliary variables
  • SEXM1F2
  • Continuous latent variables
  • IGHQ
  • Variables with special functions
  • ID variable IDNUM

45
Quick2rebuildout.out
  • (cont)
  • Estimator
    WLSMV
  • Maximum number of iterations
    1000
  • Convergence criterion
    0.500D-04
  • Maximum number of steepest descent iterations
    20
  • Parameterization
    DELTA
  • Input data file(s)
  • c\halsghq3.dat
  • Input data format FREE

46
Quick2rebuildout.out
  • SUMMARY OF CATEGORICAL DATA PROPORTIONS
  • GHQ22
  • Category 1 0.444
  • Category 2 0.343
  • Category 3 0.167
  • Category 4 0.046
  • GHQ24
  • Category 1 0.713
  • Category 2 0.202
  • Category 3 0.062
  • Category 4 0.023
  • GHQ28
  • Category 1 0.523
  • Category 2 0.329
  • Category 3 0.120
  • Category 4 0.027

47
Quick2rebuildout.out
  • MODEL ESTIMATION TERMINATED NORMALLY TESTS OF
    MODELFIT
  • Chi-Square Test of Model Fit
  • Value
    20.172
  • Degrees of Freedom
    2
  • P-Value
    0.0000
  • Chi-Square Test of Model Fit for the Baseline
    Model
  • Value
    12807.273
  • Degrees of Freedom
    4
  • P-Value
    0.0000
  • CFI/TLI
  • CFI
    0.999
  • TLI
    0.997
  • Number of Free Parameters
    13
  • RMSEA (Root Mean Square Error Of Approximation)
  • Estimate
    0.037
  • WRMR (Weighted Root Mean Square Residual)
  • Value
    0.812

48
Quick2rebuildout.out
  • MODEL RESULTS

  • Two-Tailed
  • Estimate S.E.
    Est./S.E. P-Value
  • IGHQ BY
  • GHQ22 1.000 0.000
    999.000 999.000
  • GHQ24 0.846 0.013
    63.991 0.000
  • GHQ28 0.946 0.014
    66.696 0.000
  • IGHQ ON
  • AGEYRS -0.003 0.001
    -3.608 0.000
  • Thresholds
  • GHQ221 -0.344 0.040
    -8.706 0.000
  • GHQ222 0.595 0.040
    14.912 0.000
  • GHQ223 1.490 0.046
    32.627 0.000
  • GHQ241 0.480 0.045
    10.725 0.000
  • GHQ242 1.289 0.046
    27.834 0.000
  • GHQ243 1.913 0.053
    35.945 0.000
  • GHQ281 0.023 0.041
    0.551 0.582

49
Quick2rebuildout.out
  • R-SQUARE
  • Observed Residual
  • Variable Estimate Variance
  • GHQ22 0.794 0.207
  • GHQ24 0.568 0.433
  • GHQ28 0.710 0.291
  • Latent
  • Variable Estimate
  • IGHQ 0.003
  • QUALITY OF NUMERICAL RESULTS
  • Condition Number for the Information Matrix
    0.967E-04

50
Time for some constraints _at_
  • F by y11 (1)
  • y2 (1)
  • F1 by i1 i2 (10)
  • i3 i4 (11)
  • can be words not numbers
Write a Comment
User Comments (0)
About PowerShow.com