1 / 86

Session 1

Session 1. 1 Check installations 2 Open Mplus 3 Type basic commands 4 Get data read in, spat out &read in again 5 Run an analysis 6 What has it done?. Session 2. 1 Mplus input file command structures 2 Mplus conventions 3 Mplus punctuation CaSeS ; : (.) & green! 4 Common typos in input

ophira
Télécharger la présentation

Session 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 123451234512345123456123451234561234512345 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 1<snip> 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 1<snip> 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 1<snip> 3 3 6 0 2 3 5 011 11 22 1 8 8 16 1 ANALYSIS: ESTIMATOR=ML; 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: ESTIMATOR=ML; 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] [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)

  19. [dunn_GHQ12_T1T2_ClinPsych_SiP.out] SAMPLE STATISTICS [dunn_GHQ12_T1T2_ClinPsych_SiP.out] 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. [dunn_GHQ12_T1T2_ClinPsych_SiP.out] 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 DIFF1 -0.097 0.289 -0.334 0.738 Variances SUM1 1.000 0.000 999.000 999.000 DIFF1 1.000 0.000 999.000 999.000

  22. [dunn_GHQ12_T1T2_ClinPsych_SiP.out/gph]

  23. Session 2 1 Mplus input file COMMAND STRUCTURES:2 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. We’ve seen this already … TITLE: DATA: VARIABLE: DEFINE: ANALYSIS: MODEL: OUTPUT: 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 [catvar$1] • 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: !many more! SAMP STAND RES ! short for residuals) MOD (number) CINT !(three types) TECHn !(14 types-no’s 1 to 14) FSCOEFF FSDETERMINACY + a few more … don’t forget that final colon; PLOT: TYPE IS PLOT1 PLOT2 or PLOT3; ! That’s about it OUTPUT: and PLOT:

  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 • Cook’s 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 doesn’t 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: FILE IS "c:\dunn_ghqoddeven12.dat"; FORMAT IS I4 I4 4x I4 I4 I4 4x I4; VARIABLE: NAMES ARE odd1 even1 case1 odd2 even2 case2; USEVARIABLES ARE odd1 even1 odd2 even2;

  39. ANALYSIS: ESTIMATOR=ML; MODEL: GHQ_T1 by Odd1*1 (1) Even1 (1); GHQ_T1@1; GHQ_T2 by Odd2*1 (1) Even2 (1); GHQ_T2@1; GHQ_T1 with GHQ_T2; Odd1 Even1 Odd2 Even2 (2); OUTPUT: SAMPSTAT RESIDUAL; PLOT: TYPE IS PLOT3;INPUT READING TERMINATED NORMALLY

  40. BY As in “latent construct measured BY variable” An example would be Depression BY BDI1-BDI3; ! first loading constrained to 1 by default – else can free it and fix var=1 …. which can be read as “measure the latent factor Depression by three variables from the Beck Depression Inventory” [BDI1-BDI3] NB. “through” = hyphen & numbering goes 1-3 not 01-03 ON As in “regression of y ON x” An example would be Depression ON Sex Age; ….. which can be read as “regress the latent construct Depression (y) on the 1st covariate Sex (x1) and 2nd covariate Age (x2)” WITH As in “x1 correlated with y” or “y2 correlated with y3” An example would be Age WITH Depression or Mental WITH Physical The MODEL statement:Basic commands for modelling

  41. MODEL: WITH ON BY • WITH –correlated with • ON –regressed on • BY –measured by

  42. SUMMARY OF ANALYSISNumber of groups 1Number of observations 12Number of dependent variables 4Number of independent variables 0Number of continuous latent variables 2Observed dependent variables Continuous ODD1 EVEN1 ODD2 EVEN2Continuous latent variables GHQ_T1 GHQ_T2

  43. SAMPLE STATISTICS SAMPLE STATISTICS Means ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ 1 5.083 5.250 5.000 5.000 Covariances ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ ODD1 11.743 EVEN1 8.562 8.354 ODD2 9.000 6.333 8.500 EVEN2 9.000 7.667 8.083 9.333 Correlations ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ ODD1 1.000 EVEN1 0.864 1.000 ODD2 0.901 0.752 1.000 EVEN2 0.860 0.868 0.908 1.000

  44. TESTS OF MODEL FITChi-Square Test of Model Fit Value 11.920 Degrees of Freedom 7 P-Value 0.1032Chi-Square Test of Model Fit for the Baseline Model Value 66.542 Degrees of Freedom 6 P-Value 0.0000CFI/TLI CFI 0.919 TLI 0.930Loglikelihood H0 Value -94.556 H1 Value -88.596Information Criteria Number of Free Parameters 7 Akaike (AIC) 203.112 Bayesian (BIC) 206.507 Sample-Size Adjusted BIC 185.339 (n* = (n + 2) / 24)RMSEA (Root Mean Square Error Of Approximation) Estimate 0.242 90 Percent C.I. 0.000 0.471 Probability RMSEA <= .05 0.115SRMR (Standardized Root Mean Square Residual) Value 0.097

  45. Ratio of estimate to std error is an approximate z test MODEL RESULTS Two-Tailed Estimate S.E. Est./S.E. P-Value GHQ_T1 BY ODD1 2.885 0.600 4.812 0.000 EVEN1 2.885 0.600 4.812 0.000 GHQ_T2 BY ODD2 2.885 0.600 4.812 0.000 EVEN2 2.885 0.600 4.812 0.000 GHQ_T1 WITH GHQ_T2 0.961 0.050 19.155 0.000 Intercepts ODD1 5.083 0.889 5.718 0.000 EVEN1 5.250 0.889 5.906 0.000 ODD2 5.000 0.889 5.625 0.000 EVEN2 5.000 0.889 5.625 0.000 Variances GHQ_T1 1.000 0.000 999.000 999.000 GHQ_T2 1.000 0.000 999.000 999.000 Residual Variances ODD1 1.160 0.335 3.464 0.001 EVEN1 1.160 0.335 3.464 0.001 ODD2 1.160 0.335 3.464 0.001 EVEN2 1.160 0.335 3.464 0.001

  46. RESIDUAL OUTPUT ESTIMATED MODEL AND RESIDUALS (OBSERVED - ESTIMATED) Model Estimated Means/Intercepts/Thresholds ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ 1 5.083 5.250 5.000 5.000 Standardized Residuals (z-scores) for Means/Intercepts/Thresholds ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ 1 0.000 0.000 0.000 0.000 Model Estimated Covariances/Correlations/Residual Correlations ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ ODD1 9.483 EVEN1 8.323 9.483 ODD2 8.000 8.000 9.483 EVEN2 8.000 8.000 8.323 9.483 Residuals for Covariances/Correlations/Residual Correlations ODD1 EVEN1 ODD2 EVEN2 ________ ________ ________ ________ ODD1 2.260 EVEN1 0.240 -1.128 ODD2 1.000 -1.667 -0.983 EVEN2 1.000 -0.333 -0.240 -0.149

  47. ABBREVIATIONS & FIT STATISTICS A structural model Measurement and structural relations

  48. We will see more like that tomorrow, and later today Now for some simple syntax steps INCLUDING REGRESSIONCLARIFICATIONS each TYPE

  49. Using Mplus to estimatedifferent types of regression model Output gives Odds ratios

  50. Linear Regression ANALYSIS: TYPE IS GENERAL; ESTIMATOR=ML; MODEL: Y ON X; Probit regression VARIABLE: CATEGORICAL ARE Y1234; ANALYSIS: TYPE IS GENERAL; ESTIMATOR=WLS; MODEL: Y1234 ON X; Mplus regressions (1) Y ON X

More Related