├── .RData
├── .Rhistory
├── .Rproj.user
├── 8A50D253
│ ├── pcs
│ │ ├── debug-breakpoints.pper
│ │ ├── files-pane.pper
│ │ ├── find-in-files.pper
│ │ ├── source-pane.pper
│ │ ├── windowlayoutstate.pper
│ │ └── workbench-pane.pper
│ ├── persistent-state
│ ├── saved_source_markers
│ └── sdb
│ │ ├── per
│ │ └── t
│ │ │ ├── 19F123E4
│ │ │ ├── 1EA5907E
│ │ │ ├── 73ECF038
│ │ │ ├── 8C4BD055
│ │ │ ├── 99649CAC
│ │ │ ├── BB09661E
│ │ │ └── DC23D4FA
│ │ └── prop
│ │ ├── 11883573
│ │ ├── 32248325
│ │ ├── 68675942
│ │ ├── 76246031
│ │ ├── 140CABDE
│ │ ├── 1A44F4FC
│ │ ├── 221174BD
│ │ ├── 2A33A06D
│ │ ├── 2B7E67D0
│ │ ├── 2D28D210
│ │ ├── 2DA6D6B0
│ │ ├── 324CBC30
│ │ ├── 484C7DCC
│ │ ├── 4CD40149
│ │ ├── 55670BBE
│ │ ├── 58CADEA0
│ │ ├── 5A79CF8F
│ │ ├── 5B259621
│ │ ├── 64D64EA9
│ │ ├── 6A9E6961
│ │ ├── 6E8CEFA7
│ │ ├── 70032E9E
│ │ ├── 768B1A0D
│ │ ├── 7A9F0200
│ │ ├── 841388A5
│ │ ├── 85DB6DF
│ │ ├── 886014D2
│ │ ├── 8F94BB1
│ │ ├── 9562DCB
│ │ ├── 9C314550
│ │ ├── 9ED58F33
│ │ ├── A8F0FCC4
│ │ ├── AF61ED2
│ │ ├── B4E2F8FC
│ │ ├── BC30A869
│ │ ├── C0DB0A75
│ │ ├── C60A2888
│ │ ├── C74D6359
│ │ ├── CB71E45C
│ │ ├── E0641EB0
│ │ ├── E2B01BC2
│ │ ├── F011FF8C
│ │ ├── F3C2FA9F
│ │ ├── F4108B1A
│ │ ├── FF338CBA
│ │ ├── FFB20693
│ │ └── INDEX
└── 93BC151B
│ ├── pcs
│ ├── files-pane.pper
│ ├── find-in-files.pper
│ ├── packages-pane.pper
│ ├── source-pane.pper
│ ├── windowlayoutstate.pper
│ └── workbench-pane.pper
│ └── sdb
│ ├── per
│ └── t
│ │ ├── 21EBB49B
│ │ ├── 3065D9D6
│ │ ├── B26FAB2
│ │ └── D04C3A18
│ └── prop
│ ├── 28F6BF01
│ ├── 347565E5
│ ├── 370278D2
│ ├── 554A2E9D
│ ├── 69DC04A6
│ ├── 769B8DF6
│ ├── 9A4E8FDC
│ ├── B85CA76A
│ ├── C08B4901
│ ├── C9B6B2B3
│ ├── D135F4A6
│ ├── D2CF7CAD
│ ├── D5E6305E
│ ├── F22F3062
│ ├── F35B16BA
│ ├── FDC2FC1
│ └── INDEX
├── Chapters
├── 10
│ ├── CHAP.txt
│ ├── Chapter10a_LRTs_CIs_Figures.xlsx
│ ├── Chapter10b_LRTs_CIs_Figures.xlsx
│ ├── OCTO.txt
│ ├── SAS_Chapter10a
│ │ ├── SAS_Chapter10a.sas7bdat
│ │ ├── SAS_Chapter10a_Output.html
│ │ ├── SAS_Chapter10a_Syntax.html
│ │ └── SAS_Chapter10a_Syntax.sas
│ └── SAS_Chapter10b
│ │ ├── SAS_Chapter10b.sas7bdat
│ │ ├── SAS_Chapter10b_Output.html
│ │ └── SAS_Chapter10b_Syntax.sas
├── 11
│ ├── CPE.txt
│ ├── Chapter11a_LRTs_CIs_R2.xlsx
│ ├── Chapter11b_LRTs_R2.xlsx
│ ├── SAS_Chapter11a
│ │ ├── SAS_Chapter11a.sas7bdat
│ │ ├── SAS_Chapter11a_Output.html
│ │ ├── SAS_Chapter11a_Syntax.html
│ │ └── SAS_Chapter11a_Syntax.sas
│ └── SAS_Chapter11b
│ │ ├── SAS_Chapter11b.sas7bdat
│ │ ├── SAS_Chapter11b_Output.html
│ │ ├── SAS_Chapter11b_Syntax.html
│ │ └── SAS_Chapter11b_Syntax.sas
├── 12
│ ├── Chapter12_LRTs_CIs_R2_Figure.xlsx
│ └── SAS_Chapter12
│ │ ├── SAS_Chapter12.sas7bdat
│ │ ├── SAS_Chapter12_Output.html
│ │ ├── SAS_Chapter12_Syntax.html
│ │ └── SAS_Chapter12_Syntax.sas
├── 02
│ ├── Chapter2_Regions_Figures.xlsx
│ ├── MPLUS_Chapter2
│ │ ├── MPLUS_Chapter2.csv
│ │ ├── MPLUS_Chapter2_aEq3_EmptyMeans.inp
│ │ ├── MPLUS_Chapter2_aEq3_EmptyMeans.out
│ │ ├── MPLUS_Chapter2_bEq4_AddAge85.inp
│ │ ├── MPLUS_Chapter2_bEq4_AddAge85.out
│ │ ├── MPLUS_Chapter2_cEq4_AddOriginalAge.inp
│ │ ├── MPLUS_Chapter2_cEq4_AddOriginalAge.out
│ │ ├── MPLUS_Chapter2_dEq6_AddGrip9.inp
│ │ ├── MPLUS_Chapter2_dEq6_AddGrip9.out
│ │ ├── MPLUS_Chapter2_eEq7_AddSexMW.inp
│ │ ├── MPLUS_Chapter2_eEq7_AddSexMW.out
│ │ ├── MPLUS_Chapter2_fEq6_AddSexWM.inp
│ │ ├── MPLUS_Chapter2_fEq6_AddSexWM.out
│ │ ├── MPLUS_Chapter2_gEq8_AddDemNFDemNC.inp
│ │ ├── MPLUS_Chapter2_gEq8_AddDemNFDemNC.out
│ │ ├── MPLUS_Chapter2_hEq9_AddAge85byGrip9.inp
│ │ ├── MPLUS_Chapter2_hEq9_AddAge85byGrip9.out
│ │ ├── MPLUS_Chapter2_iEq9_AddAge80byGrip12.inp
│ │ ├── MPLUS_Chapter2_iEq9_AddAge80byGrip12.out
│ │ ├── MPLUS_Chapter2_jEq9_AddAge90byGrip6.inp
│ │ ├── MPLUS_Chapter2_jEq9_AddAge90byGrip6.out
│ │ ├── MPLUS_Chapter2_kEq13_AddSexMWbyDemNFNC.inp
│ │ ├── MPLUS_Chapter2_kEq13_AddSexMWbyDemNFNC.out
│ │ ├── MPLUS_Chapter2_lEq13_AddSexWMbyDemNFNC.inp
│ │ ├── MPLUS_Chapter2_lEq13_AddSexWMbyDemNFNC.out
│ │ ├── MPLUS_Chapter2_mEq15_AddSexMWbyDemFNFC.inp
│ │ ├── MPLUS_Chapter2_mEq15_AddSexMWbyDemFNFC.out
│ │ ├── MPLUS_Chapter2_nEq15_AddSexWMbyDemFNFC.inp
│ │ ├── MPLUS_Chapter2_nEq15_AddSexWMbyDemFNFC.out
│ │ ├── MPLUS_Chapter2_oEq16_AddSexMWbyDemCNCF.inp
│ │ ├── MPLUS_Chapter2_oEq16_AddSexMWbyDemCNCF.out
│ │ ├── MPLUS_Chapter2_pEq16_AddSexWMbyDemCNCF.inp
│ │ ├── MPLUS_Chapter2_pEq16_AddSexWMbyDemCNCF.out
│ │ ├── MPLUS_Chapter2_qEq17_AddAgeSexGripSex.inp
│ │ ├── MPLUS_Chapter2_qEq17_AddAgeSexGripSex.out
│ │ ├── MPLUS_Chapter2_rEq18_AddAgeGripSex.inp
│ │ ├── MPLUS_Chapter2_rEq18_AddAgeGripSex.out
│ │ ├── MPLUS_Chapter2_sEq13_Final.inp
│ │ └── MPLUS_Chapter2_sEq13_Final.out
│ ├── OCTO.txt
│ ├── R_Chapter2
│ │ ├── dsL.R
│ │ ├── hoffman-ch2.R
│ │ ├── hoffman-ch2.Rmd
│ │ └── hoffman-ch2.html
│ ├── SAS_Chapter2
│ │ ├── SAS_Chapter2.sas7bdat
│ │ ├── SAS_Chapter2_Output.html
│ │ ├── SAS_Chapter2_Syntax.html
│ │ └── SAS_Chapter2_Syntax.sas
│ └── hoffman-ch2.knit.md
├── 03
│ ├── CHAP.txt
│ ├── Chapter3b_LRTs.xlsx
│ ├── MPLUS_Chapter3a
│ │ ├── MPLUS_Chapter3a.csv
│ │ ├── MPLUS_Chapter3a_aEq1_EmptyBPModel.inp
│ │ ├── MPLUS_Chapter3a_aEq1_EmptyBPModel.out
│ │ ├── MPLUS_Chapter3a_bEq2_EmptyWPModel.inp
│ │ ├── MPLUS_Chapter3a_bEq2_EmptyWPModel.out
│ │ ├── MPLUS_Chapter3a_cEq7_CondBPModel.inp
│ │ ├── MPLUS_Chapter3a_cEq7_CondBPModel.out
│ │ ├── MPLUS_Chapter3a_dEq7_CondWPModel.inp
│ │ └── MPLUS_Chapter3a_dEq7_CondWPModel.out
│ ├── MPLUS_Chapter3b
│ │ ├── MPLUS_Chapter3b.csv
│ │ ├── MPLUS_Chapter3b_aEq10_BPANOVA.inp
│ │ ├── MPLUS_Chapter3b_aEq10_BPANOVA.out
│ │ ├── MPLUS_Chapter3b_bEq10_UnivRMANOVA.inp
│ │ ├── MPLUS_Chapter3b_bEq10_UnivRMANOVA.out
│ │ ├── MPLUS_Chapter3b_cEq10_MultivRMANOVA.inp
│ │ └── MPLUS_Chapter3b_cEq10_MultivRMANOVA.out
│ ├── R_Chapter3
│ │ ├── figure_rmd
│ │ │ ├── EmptyBP4.png
│ │ │ ├── EmptyBP5.png
│ │ │ ├── EmptyWP4.png
│ │ │ ├── EmptyWP5.png
│ │ │ ├── GraphingData0.png
│ │ │ ├── GraphingData1.png
│ │ │ ├── GraphingData2.png
│ │ │ ├── GraphingData3.png
│ │ │ └── StackData.png
│ │ ├── hoffman-ch3.R
│ │ ├── hoffman-ch3.Rmd
│ │ ├── hoffman-ch3.html
│ │ └── slide308.R
│ ├── SAS_Chapter3a
│ │ ├── SAS_Chapter3a.sas7bdat
│ │ ├── SAS_Chapter3a_Output.html
│ │ ├── SAS_Chapter3a_Syntax.html
│ │ └── SAS_Chapter3a_Syntax.sas
│ └── SAS_Chapter3b
│ │ ├── SAS_Chapter3b.sas7bdat
│ │ ├── SAS_Chapter3b_Output.html
│ │ ├── SAS_Chapter3b_Syntax.html
│ │ └── SAS_Chapter3b_Syntax.sas
├── 04
│ ├── Chapter4_LRTs.xlsx
│ ├── MIDUS-NSDE.txt
│ └── SAS_Chapter4
│ │ ├── SAS_Chapter4.sas7bdat
│ │ ├── SAS_Chapter4_Output.html
│ │ ├── SAS_Chapter4_Syntax.html
│ │ └── SAS_Chapter4_Syntax.sas
├── 05
│ ├── Chapter5_LRTs_CIs_R2.xlsx
│ ├── MPlus_Chapter5
│ │ ├── Ch5_Mplus.pdf
│ │ ├── ELSA_LONG_n1000.dat
│ │ ├── ELSA_MLMGROWTH_EMPTY.inp
│ │ └── elsa_mlmgrowth_empty.out
│ ├── R_Chapter5
│ │ ├── .Rhistory
│ │ ├── SimpleExample_Key.R
│ │ ├── SimpleExample_Key.xlsx
│ │ ├── SimpleExample_studentCopy.R
│ │ ├── SimpleExample_studentCopy.xlsx
│ │ ├── ch5-ELSA.R
│ │ ├── ch5-ELSA.Rmd
│ │ ├── ch5-ELSA.html
│ │ ├── figure_rmd
│ │ │ ├── GraphM3_1.png
│ │ │ ├── GraphM5_1.png
│ │ │ ├── GraphM5_3.png
│ │ │ ├── GraphM5_5.png
│ │ │ ├── GraphingData0.png
│ │ │ ├── GraphingData1.png
│ │ │ └── GraphingData2.png
│ │ ├── general.JPG
│ │ ├── hoffman-ch5.R
│ │ ├── hoffman-ch5.Rmd
│ │ ├── hoffman-ch5.html
│ │ ├── how to adapt CH5 script for ELSA study.txt
│ │ └── images
│ │ │ ├── general.JPG
│ │ │ ├── m3.1.JPG
│ │ │ ├── m5.1.JPG
│ │ │ ├── m5.3.JPG
│ │ │ ├── m5.5.JPG
│ │ │ └── m5.5a.JPG
│ └── SAS_Chapter5
│ │ ├── SAS_Chapter5.sas7bdat
│ │ ├── SAS_Chapter5_Output.html
│ │ ├── SAS_Chapter5_Syntax.html
│ │ └── SAS_Chapter5_Syntax.sas
├── 06
│ ├── CHAP.txt
│ ├── Chapter6_LRTs_CIs_R2.xlsx
│ ├── MPlus_Chpater6
│ │ ├── 2b R(I) R(S).inp
│ │ ├── 2b r(i) r(s).out
│ │ ├── 3A R(I) R(S) F(Q).inp
│ │ ├── 3a r(i) r(s) f(q).out
│ │ ├── MPLUS_Chapter6.csv
│ │ └── MPLUS_Chpater6 (1).csv
│ └── SAS_Chapter6
│ │ ├── SAS_Chapter6.sas7bdat
│ │ ├── SAS_Chapter6_Output.html
│ │ ├── SAS_Chapter6_Syntax.html
│ │ └── SAS_Chapter6_Syntax.sas
├── 07
│ ├── CHAP.txt
│ ├── Chapter7a_LRTs_CIs_R2_Regions.xlsx
│ ├── Chapter7b_LRTs_CIs_R2_Figure.xlsx
│ ├── FRP.txt
│ ├── SAS_Chapter7a
│ │ ├── SAS_Chapter7a.sas7bdat
│ │ ├── SAS_Chapter7a_Output.html
│ │ ├── SAS_Chapter7a_Syntax.html
│ │ └── SAS_Chapter7a_Syntax.sas
│ └── SAS_Chapter7b
│ │ ├── SAS_Chapter7b.sas7bdat
│ │ ├── SAS_Chapter7b_Output.html
│ │ ├── SAS_Chapter7b_Syntax.html
│ │ └── SAS_Chapter7b_Syntax.sas
├── 08
│ ├── CHAP.txt
│ ├── Chapter8_LRTs_CIs_R2_Figures.xlsx
│ └── SAS_Chapter8
│ │ ├── SAS_Chapter8.sas7bdat
│ │ ├── SAS_Chapter8_Output.html
│ │ ├── SAS_Chapter8_Syntax.html
│ │ └── SAS_Chapter8_Syntax.sas
└── 09
│ ├── Chapter9_LRTs_CIs_R2.xlsx
│ ├── FRP.txt
│ └── SAS_Chapter9
│ ├── SAS_Chapter9.sas7bdat
│ ├── SAS_Chapter9_Output.html
│ ├── SAS_Chapter9_Syntax.html
│ └── SAS_Chapter9_Syntax.sas
├── Data
├── Derived
│ ├── ELSA
│ │ └── dsL_ELSA.rds
│ └── MPLUS_Chpater6.csv
└── Raw
│ ├── ELSA
│ ├── ds0_ELSA.rds
│ └── dsELSA.rds
│ └── HRS
│ └── HRS_WIDE_n2000.dat
├── Projects
├── ELSA
│ └── CogDecline
│ │ ├── ELSA_report.Rmd
│ │ ├── ELSA_report.html
│ │ ├── dsELSA.R
│ │ ├── dsL_ELSA.csv
│ │ ├── dsL_ELSA.dat
│ │ ├── dsL_ELSA_varNames.csv
│ │ ├── dsW_ELSA.dat
│ │ ├── dsW_ELSA_varNames.csv
│ │ ├── extract from mplus.R
│ │ ├── figure_rmd
│ │ ├── BasicLinePlot-1.png
│ │ ├── CrossSectionCount-1.png
│ │ ├── CrossSectionDist-1.png
│ │ ├── IndividualPredictionsAge-1.png
│ │ ├── IndividualPredictionsAge2-1.png
│ │ ├── ProtoLines-1.png
│ │ └── ProtoLines2-1.png
│ │ └── irecall
│ │ ├── dsL_ELSA.csv
│ │ ├── irecall_r(I)_r(S)_(IS)Age80.inp
│ │ ├── irecall_r(I)_r(S)_(IS)Age80_(IS)Edu11.inp
│ │ ├── irecall_r(I)_r(S)_(IS)Age80_(IS)Edu11_(IS)Smoked.inp
│ │ ├── irecall_r(I)_r(S)_NoCovar.inp
│ │ ├── irecall_r(i)_r(s)_(is)age80.gh5
│ │ ├── irecall_r(i)_r(s)_(is)age80.out
│ │ ├── irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5
│ │ ├── irecall_r(i)_r(s)_(is)age80_(is)edu11.out
│ │ ├── irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5
│ │ ├── irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.out
│ │ ├── irecall_r(i)_r(s)_nocovar.gh5
│ │ ├── irecall_r(i)_r(s)_nocovar.out
│ │ ├── results.dat
│ │ └── retired
│ │ ├── irecall_0r_1f_2x_x.inp
│ │ ├── irecall_r0_f1_x2_x.out
│ │ ├── irecall_r0_r1_f2_x.inp
│ │ ├── irecall_r0_r1_f2_x.out
│ │ ├── irecall_r0_r1_r2_012age80.inp
│ │ ├── irecall_r0_r1_r2_012age80.out
│ │ ├── irecall_r0_r1_r2_012age80_0edu11.inp
│ │ ├── irecall_r0_r1_r2_012age80_0edu11.out
│ │ ├── irecall_r0_r1_r2_01age80.inp
│ │ ├── irecall_r0_r1_r2_01age80.out
│ │ ├── irecall_r0_r1_r2_0age80.inp
│ │ ├── irecall_r0_r1_r2_0age80.out
│ │ ├── irecall_r0_r1_r2_age012.inp
│ │ ├── irecall_r0_r1_r2_age012.out
│ │ ├── irecall_r0_r1_r2_x.inp
│ │ ├── irecall_r0_r1_r2_x.out
│ │ ├── irecall_r0_r1_x2_x.inp
│ │ ├── irecall_r0_r1_x2_x.out
│ │ ├── irecall_r0_x1_x2_x.inp
│ │ └── irecall_r0_x1_x2_x.out
├── HRS
│ ├── HRS.zip
│ └── Various
│ │ ├── HRS_BASIC.inp
│ │ ├── HRS_General Information.docx
│ │ ├── HRS_General_VariableList.xlsx
│ │ ├── HRS_LGMGROWTH.inp
│ │ ├── HRS_LGMGROWTH_ExampWriteup.docx
│ │ ├── HRS_LGMGROWTH_age.inp
│ │ ├── HRS_LGMGROWTH_piecewise.inp
│ │ ├── HRS_LGMGROWTH_timestudy.inp
│ │ ├── HRS_MLMGROWTH_WIDETOLONG.inp
│ │ ├── HRS_WIDE_n2000.dat
│ │ ├── dsHRS.R
│ │ ├── hrs_basic.dgm
│ │ ├── hrs_basic.gh5
│ │ ├── hrs_basic.out
│ │ ├── hrs_lgmgrowth.dgm
│ │ ├── hrs_lgmgrowth.gh5
│ │ ├── hrs_lgmgrowth.out
│ │ └── namesare.txt
├── LMG_Mplus_primer.pdf
└── README.md
├── README.md
├── Scripts
├── Data
│ ├── LabelingFactorLevels.R
│ ├── dsL.R
│ └── loadChapterDatasets.R
├── Graphs
│ ├── AesDefine.R
│ ├── basicTrajectory.R
│ ├── basicTrajectory300.R
│ ├── graphThemes.R
│ └── line_graph_trajectories.R
├── MPlus
│ └── mplus.R
└── Utility
│ ├── InstallPackages.R
│ ├── runAll.R
│ ├── runMany.R
│ └── runOne.R
├── final
├── Data
│ ├── HRS_WIDE_n2000.dat
│ └── namesare.txt
├── Documentation
│ ├── HRS_General Information.docx
│ ├── HRS_General_VariableList.xlsx
│ └── HRS_LGMGROWTH_ExampWriteup.docx
├── Mplus
│ ├── HRS_BASIC.inp
│ ├── HRS_LGMGROWTH.inp
│ ├── HRS_LGMGROWTH_age.inp
│ ├── HRS_LGMGROWTH_piecewise.inp
│ ├── HRS_LGMGROWTH_timestudy.inp
│ └── HRS_MLMGROWTH_WIDETOLONG.inp
└── README.md
├── general.JPG
├── gradesGraph.R
├── libs
└── css
│ └── sidebar.css
└── psy564.Rproj
/.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/.RData
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/debug-breakpoints.pper:
--------------------------------------------------------------------------------
1 | {
2 | "debugBreakpointsState" : {
3 | "breakpoints" : [
4 | ]
5 | }
6 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/files-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "path" : "~/GitHub/psy564",
3 | "sortOrder" : [
4 | {
5 | "ascending" : true,
6 | "columnIndex" : 2
7 | },
8 | {
9 | "ascending" : true,
10 | "columnIndex" : 1
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/find-in-files.pper:
--------------------------------------------------------------------------------
1 | {
2 | "dialog-state" : {
3 | "caseSensitive" : false,
4 | "filePatterns" : [
5 | ],
6 | "path" : "~/GitHub/psy564",
7 | "query" : "lme4 package",
8 | "regex" : false
9 | }
10 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/source-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "activeTab" : 6
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/windowlayoutstate.pper:
--------------------------------------------------------------------------------
1 | {
2 | "left" : {
3 | "panelheight" : 958,
4 | "splitterpos" : 391,
5 | "topwindowstate" : "MAXIMIZE",
6 | "windowheight" : 996
7 | },
8 | "right" : {
9 | "panelheight" : 958,
10 | "splitterpos" : 689,
11 | "topwindowstate" : "NORMAL",
12 | "windowheight" : 996
13 | }
14 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/pcs/workbench-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "TabSet1" : 1,
3 | "TabSet2" : 0
4 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/persistent-state:
--------------------------------------------------------------------------------
1 | build-last-errors="[]"
2 | build-last-errors-base-dir=""
3 | build-last-outputs="[]"
4 | compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}"
5 | console_procs="[]"
6 | files.monitored-path=""
7 | find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}"
8 | imageDirtyState="1"
9 | saveActionState="-1"
10 |
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/saved_source_markers:
--------------------------------------------------------------------------------
1 | {"active_set":"","sets":[]}
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/per/t/19F123E4:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "# remove all elements for a clean start\nrm(list=ls(all=TRUE))\ncat(\"\\014\")\n\n\n## @knitr InstallPackage\n# source(\"./Scripts/Utility/InstallPackages.R\")\n\n\n\n## @knitr LoadPackages\nrequire(sas7bdat) # for inputting data \nlibrary(dplyr) # for general data manipulation\n# library(reshape2) # for data : wide <-> long\n# library(psych) # data summary + etc\nlibrary(ggplot2) # graphing\n# library(nlme) # estimate fixed models | esp. gls()\n# library(lme4) # estimate mixed models | esp. lmer()\n# library(arm) # process model objects\n\n\n## @knitr LoadData\nds0 <- read.csv(\"~/GitHub/psy564/Data/Raw/HRS/HRS_WIDE_n2000.dat\", header=F)\ndim(ds0)\n\n# namesare <- read.table(\"./Projects/HRS/HRS/namesare.txt\", sep=\" \")\nnamesarePath <- \"./Projects/HRS/Various/namesare.txt\"\nnamesare <- scan (namesarePath, what=\"character\", sep=\" \")\nnames(ds0) <- namesare\n\nselectVars <- c()",
3 | "created" : 1426623137609.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "4013783609",
8 | "id" : "19F123E4",
9 | "lastKnownWriteTime" : 1427776920,
10 | "path" : "~/GitHub/psy564/Projects/HRS/Various/dsHRS.R",
11 | "project_path" : "Projects/HRS/Various/dsHRS.R",
12 | "properties" : {
13 | },
14 | "relative_order" : 0,
15 | "source_on_save" : false,
16 | "type" : "r_source"
17 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/per/t/73ECF038:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "# remove all elements for a clean start\nrm(list=ls(all=TRUE))\ncat(\"\\014\")\n\n## @knitr LoadPackages\nrequire(sas7bdat) # for inputting data \nlibrary(dplyr) # for general data manipulation\nlibrary(reshape2) # for data : wide <-> long\nlibrary(psych) # data summary + etc\nlibrary(ggplot2) # graphing\nlibrary(nlme) # estimate fixed models | esp. gls()\nlibrary(lme4) # estimate mixed models | esp. lmer()\nlibrary(arm) # process model objects\n\n# source(\"./Scripts/Mplus/mplus.R\")\nsource(\"http://www.statmodel.com/mplus-R/mplus.R\")\nls() # list the availible function in mplus.R\n\nm0 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_nocovar.gh5\"\nm1 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80.gh5\"\nm2 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5\"\nm3 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5\"\n\n\nmplus.view.plots(m3)\nmodel <- m3\n\nmplus.list.variables(m3)\n\nmplus.plot.histogram(model, \"OUTCOME\")\nmplus.plot.histogram(model, \"TIMEL\")\nmplus.plot.histogram(model, \"EVRSMK1A\")\nmplus.plot.histogram(model, \"EDU11\")\nmplus.plot.histogram(model, \"AGE80\")\nmplus.plot.histogram(model, \"LINEAR\")\nmplus.plot.histogram(model, \"B_OUTCOME\")\n\n# extract raw data\na <- mplus.get.data(m2,\"OUTCOME\")\nb <- mplus.get.data(m2,\"TIMEL\")\nc <- mplus.get.data(m2,\"EDU11\")\nd <- mplus.get.data(m2,\"AGE80\")\ne <- mplus.get.data(m2,\"LINEAR\")\nf <- mplus.get.data(m2,\"B_OUTCOME\")\ng <- mplus.get.data(m2,\"ID\")\n\nds <- data.frame(cbind(a, b, c, d, e, f, g))\nnames(ds) <- c(\"OUTCOME\", \"TIMEL\",\"EDU11\",\"AGE80\",\"LINEAR\",\"B_OUTCOME\",\"ID\")\n\nhead(ds)\n\n\n\n###### ########\nmplus.load(m1)\nmplus.plot.loop(m1, ypred)\n\nsource(\"http://www.statmodel.com/mplus-R/mplus.R\")\nls() # list the availible function in mplus.R\n\n# create objects containing the paths to gh5 files\nmodel_basic <- './Projects/HRS/Various/HRS_BASIC.gh5'\nmodel_growth <- './Projects/HRS/Various/hrs_lgmgrowth.gh5'\n\n# choose what model to work with\nmodel <- model_basic\nmodel <- model_growth\n\n\nmplus.list.variables(model)\nmplus.plot.histogram(model,'CDWR1')\nmplus.plot.histogram(model,'I')\nmplus.plot.histogram(model,'S')\n\nmplus.plot.loop(model)\n\nmplus.plot.scatterplot('HRS_BASIC.gh5','CDWRSCR4','DAGEYRS4')\n\n\n\n\n",
3 | "created" : 1428010904751.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "911814083",
8 | "id" : "73ECF038",
9 | "lastKnownWriteTime" : 1427776920,
10 | "path" : "~/GitHub/psy564/Projects/ELSA/CogDecline/extract from mplus.R",
11 | "project_path" : "Projects/ELSA/CogDecline/extract from mplus.R",
12 | "properties" : {
13 | },
14 | "relative_order" : 0,
15 | "source_on_save" : false,
16 | "type" : "r_source"
17 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/per/t/BB09661E:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "---\ntitle: \"Reporting Statistical Models (demo)\"\nauthor: \"Psyc 564\"\ndate: \"Friday, January 30, 2015\"\noutput:\n html_document:\n css: ~/GitHub/psy564/libs/css/sidebar.css\n highlight: haddock\n theme: spacelab\n toc: yes\n---\n\n\n```{r, echo=F, message=F} \nlibrary(knitr)\nopts_knit$set(root.dir='../../../') #Don't combine this call with any other chunk -especially one that uses file paths.\n```\n\n\n```{r, echo=F, message=T}\nrequire(knitr)\nopts_chunk$set(\n results='show', \n message = TRUE,\n comment = NA, \n tidy = FALSE,\n# fig.height = 4.8, \n# fig.width = 6.5, \n out.width = NULL,\n fig.path = 'figure_rmd/', \n dev = \"png\",\n dpi = 70\n)\nechoChunks <- FALSE\nwarningChunks<- FALSE\nmessageChunks<- FALSE\noutwidthChunks <- \"130%\"\noptions(width=120) #So the output is 50% wider than the default.\nread_chunk(\"./Projects/ELSA/CogDecline/dsELSA.R\") # the file to which knitr calls for the chunks\n```\n\n## LoadPackages\n```{r LoadPackages}\n\n```\n\n\n## Load data\n```{r LoadData}\n\n```\n\n\n## DataFilter\n```{r DataFilter}\n\n```\n\n\n## DataFilter2\n```{r DataFilter2}\n\n```\n\n## DataExportLong\n```{r DataExportLong, eval=F}\n\n```\n\n## DataExportWide\n```{r DataExportWide, eval=F,echo=F}\n\n```\nNOTE: the export of the wide data is suppressed for brevity\n\n## LoadGraphThemes\n```{r LoadGraphThemes}\n\n```\n\n## CrossSectionDist\n```{r CrossSectionDist, out.width=\"900px\"}\n\n```\n\n## CrossSectionCount\n```{r CrossSectionCount, out.width=\"900px\"}\n\n```\n\n## MakeAgeBins\n```{r MakeAgeBins}\n\n```\n\n## EasyData\n```{r EasyData}\n\n```\n\n## BasicLinePlot\n```{r BasicLinePlot, warning=F,out.width=\"900px\"}\n\n```\n\n## DefineModelData\n```{r DefineModelData, warning=F}\n\n```\n\n## ProtoLines\n```{r ProtoLines, warning=F}\n\n```\n\n## IndividualPredictionsAge\n```{r IndividualPredictionsAge, warning=F, out.width=\"900px\"}\n\n```\n\n\n\n## DefineModelData2\n```{r DefineModelData2, warning=F}\n\n```\n\n## ProtoLines2\n```{r ProtoLines2, warning=F}\n\n```\n\n## IndividualPredictionsAge2\n```{r IndividualPredictionsAge2, warning=F}\n\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n \n",
3 | "created" : 1428009850748.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "1121424642",
8 | "id" : "BB09661E",
9 | "lastKnownWriteTime" : 1427776920,
10 | "path" : "~/GitHub/psy564/Projects/ELSA/CogDecline/ELSA_report.Rmd",
11 | "project_path" : "Projects/ELSA/CogDecline/ELSA_report.Rmd",
12 | "properties" : {
13 | },
14 | "relative_order" : 0,
15 | "source_on_save" : false,
16 | "type" : "r_markdown"
17 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/11883573:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/140CABDE:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/1A44F4FC:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/221174BD:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/2A33A06D:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/2B7E67D0:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/2D28D210:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/2DA6D6B0:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/32248325:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/324CBC30:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/484C7DCC:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/4CD40149:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/55670BBE:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/58CADEA0:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/5A79CF8F:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/5B259621:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/64D64EA9:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/68675942:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/6A9E6961:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/6E8CEFA7:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/70032E9E:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/76246031:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/768B1A0D:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/7A9F0200:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/841388A5:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/85DB6DF:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/886014D2:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/8F94BB1:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/9562DCB:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/9C314550:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/9ED58F33:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/A8F0FCC4:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/AF61ED2:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/B4E2F8FC:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/BC30A869:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/C0DB0A75:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/C60A2888:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/C74D6359:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/CB71E45C:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/E0641EB0:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/E2B01BC2:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/F011FF8C:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/F3C2FA9F:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/F4108B1A:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/FF338CBA:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/FFB20693:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/8A50D253/sdb/prop/INDEX:
--------------------------------------------------------------------------------
1 | C%3A%2FUsers%2Fkoval_000%2FAppData%2FLocal%2FMicrosoft%2FWindows%2FINetCache%2FContent.Outlook%2FAGJUNCJ3%2Fmplus%20plot.R="E2B01BC2"
2 | C%3A%2FUsers%2Fkoval_000%2FDropbox%2FProjects%2FMBRcover%2FCattellPoem.R="A8F0FCC4"
3 | ~%2FGitHub%2FCOAG-colloquium-2014F%2FReports%2F2015-01-06-Intro-Lecture-StatModeling.Rmd="6A9E6961"
4 | ~%2FGitHub%2FDiabetes-Tri-Study%2FReports%2FELSA%2FELSA-Unconditional.R="2DA6D6B0"
5 | ~%2FGitHub%2FDiabetes-Tri-Study%2FReports%2FELSA_2%2FELSA_report.R="140CABDE"
6 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FData%2FDerive_dsL_from_Extract.R="9C314550"
7 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2FIntroLCM.Rmd="76246031"
8 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2FLCModels2.R="2B7E67D0"
9 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2Fcollecting%20results.R="841388A5"
10 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2FsequenceLCM.R="70032E9E"
11 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2FsingleModel.Rmd="4CD40149"
12 | ~%2FGitHub%2FLongitudinal_Models_of_Religiosity_NLSY97%2FModels%2FLCM%2FsingleModel_brief.R="C0DB0A75"
13 | ~%2FGitHub%2Fpsy564%2FChapters%2F02%2FR_Chapter2%2Fhoffman-ch2.R="2D28D210"
14 | ~%2FGitHub%2Fpsy564%2FChapters%2F02%2FR_Chapter2%2Fhoffman-ch2.Rmd="32248325"
15 | ~%2FGitHub%2Fpsy564%2FChapters%2F02%2FR_Chapter2%2Fhoffman-ch3.R="C60A2888"
16 | ~%2FGitHub%2Fpsy564%2FChapters%2F02%2FR_Chapter2%2Fhoffman-ch3.Rmd="9562DCB"
17 | ~%2FGitHub%2Fpsy564%2FChapters%2F03%2FR_Chapter3%2Fhoffman-ch3.R="AF61ED2"
18 | ~%2FGitHub%2Fpsy564%2FChapters%2F03%2FR_Chapter3%2Fhoffman-ch3.Rmd="1A44F4FC"
19 | ~%2FGitHub%2Fpsy564%2FChapters%2F03%2FR_Chapter3%2Fhoffman-ch5.Rmd="BC30A869"
20 | ~%2FGitHub%2Fpsy564%2FChapters%2F03%2FR_Chapter3%2Fslide308.R="C74D6359"
21 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2FSimpleExample.R="7A9F0200"
22 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2FSimpleExample_studentCopy.R="5B259621"
23 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fch5-ELSA.R="55670BBE"
24 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fch5-ELSA.Rmd="2A33A06D"
25 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2FdsELSA.R="68675942"
26 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fhoffman-ch5.R="FFB20693"
27 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fhoffman-ch5.Rmd="221174BD"
28 | ~%2FGitHub%2Fpsy564%2FData%2FDerived%2FMPLUS_Chpater6.csv="8F94BB1"
29 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2FELSA_graphs.R="85DB6DF"
30 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2FELSA_report.R="F4108B1A"
31 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2FELSA_report.Rmd="58CADEA0"
32 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2FdsELSA.R="484C7DCC"
33 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2Fextract%20from%20mplus.R="E0641EB0"
34 | ~%2FGitHub%2Fpsy564%2FProjects%2FHRS%2FHRS%2FdsHRS.R="F3C2FA9F"
35 | ~%2FGitHub%2Fpsy564%2FProjects%2FHRS%2FVarious%2FdsHRS.R="886014D2"
36 | ~%2FGitHub%2Fpsy564%2FProjects%2FREADME.md="768B1A0D"
37 | ~%2FGitHub%2Fpsy564%2FREADME.md="5A79CF8F"
38 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FLabelingFactorLevels.R="11883573"
39 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FdsELSA.R="9ED58F33"
40 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FdsL.R="324CBC30"
41 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FloadChapterDS.R="6E8CEFA7"
42 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FloadChapterDatasets.R="B4E2F8FC"
43 | ~%2FGitHub%2Fpsy564%2FScripts%2FGraphs%2FbasicTrajectory.R="FF338CBA"
44 | ~%2FGitHub%2Fpsy564%2FScripts%2FGraphs%2FgraphThemes.R="CB71E45C"
45 | ~%2FGitHub%2Fpsy564%2FScripts%2FUtility%2FInstallPackages.R="F011FF8C"
46 | ~%2FGitHub%2Fpsy564%2FScripts%2FUtility%2FrunOne.R="64D64EA9"
47 |
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/files-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "path" : "~/GitHub/psy564/Scripts/Graphs",
3 | "sortOrder" : [
4 | {
5 | "ascending" : false,
6 | "columnIndex" : 1
7 | },
8 | {
9 | "ascending" : true,
10 | "columnIndex" : 2
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/find-in-files.pper:
--------------------------------------------------------------------------------
1 | {
2 | "dialog-state" : {
3 | "caseSensitive" : false,
4 | "filePatterns" : [
5 | ],
6 | "path" : "~/GitHub/psy564",
7 | "query" : "seq_along",
8 | "regex" : false
9 | }
10 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/packages-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "installOptions" : {
3 | "installDependencies" : true,
4 | "installFromRepository" : true,
5 | "libraryPath" : "C:/Users/andkov/Documents/R/win-library/3.1"
6 | }
7 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/source-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "activeTab" : 0
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/windowlayoutstate.pper:
--------------------------------------------------------------------------------
1 | {
2 | "left" : {
3 | "panelheight" : 1079,
4 | "splitterpos" : 446,
5 | "topwindowstate" : "MAXIMIZE",
6 | "windowheight" : 1117
7 | },
8 | "right" : {
9 | "panelheight" : 1079,
10 | "splitterpos" : 800,
11 | "topwindowstate" : "NORMAL",
12 | "windowheight" : 1117
13 | }
14 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/pcs/workbench-pane.pper:
--------------------------------------------------------------------------------
1 | {
2 | "TabSet1" : 0,
3 | "TabSet2" : 2
4 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/per/t/21EBB49B:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "# p <- ggplot2::ggplot(dsM,aes(x=time,y=attend, group=id))\n# p <- p + geom_line() \n# p <- p + geom_point(pch=20, size=2.5)\n# p <- p + plotTheme\n# p <- p + scale_x_continuous(limits=c(0,11),\n# breaks=c(0:11))\n# p <- p + scale_y_continuous(limits=c(1,8), \n# breaks=seq(1,8, by=1))\n# p <- p + labs(list(\n# title=\"How often did you attend worship last year?\",\n# x=\"Time scale: years since 2000\", y=\"Church attendance\"))\n\n\n# dsM <- dplyr::filter(dsL, id <=300, \n# raceF != \"Mixed (Non-H)\") %>% \n# dplyr::select(id,sexF,raceF,year,attend,attendF) %>%\n# dplyr::mutate(yearc = year - 2000)\n# \np <- ggplot2::ggplot(dsM,aes(x=time,y=attend))\np <- p + geom_line(aes(group=id), color='firebrick',\n alpha=.2,\n position=position_jitter(w=0.3, h=0.3))\np <- p + geom_point(shape=1, color=\"black\", fill=NA, \n alpha=.4, size=2, \n position=position_jitter(w=0.3, h=0.3))\np <- p + plotTheme\np <- p + scale_x_continuous(limits=c(0,11),\n breaks=c(0:11))\np <- p + scale_y_continuous(limits=c(0,8), \n breaks=seq(1,8, by=1))\np <- p + labs(list(\n title=\"How often did you attend worship last year?\",\n x=\"Time scale: years since 2000\", y=\"Church attendance\"))\np\n",
3 | "created" : 1426265100156.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "3582181915",
8 | "id" : "21EBB49B",
9 | "lastKnownWriteTime" : 1425589641,
10 | "path" : "~/GitHub/psy564/Scripts/Graphs/basicTrajectory300.R",
11 | "project_path" : "Scripts/Graphs/basicTrajectory300.R",
12 | "properties" : {
13 | },
14 | "source_on_save" : false,
15 | "type" : "r_source"
16 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/per/t/3065D9D6:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "p <- ggplot2::ggplot(dsM,aes(x=time,y=attend, group=id))\np <- p + geom_line() \np <- p + geom_point(pch=20, size=2.5)\np <- p + plotTheme\np <- p + scale_x_continuous(limits=c(0,11),\n breaks=c(0:11))\np <- p + scale_y_continuous(limits=c(0,8), \n breaks=seq(1,8, by=1))\np <- p + labs(list(\n title=\"How often did you attend worship last year?\",\n x=\"Time scale: years since 2000\", y=\"Church attendance\"))\n",
3 | "created" : 1426265113865.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "3428172300",
8 | "id" : "3065D9D6",
9 | "lastKnownWriteTime" : 1425589641,
10 | "path" : "~/GitHub/psy564/Scripts/Graphs/basicTrajectory.R",
11 | "project_path" : "Scripts/Graphs/basicTrajectory.R",
12 | "properties" : {
13 | },
14 | "source_on_save" : false,
15 | "type" : "r_source"
16 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/per/t/D04C3A18:
--------------------------------------------------------------------------------
1 | {
2 | "contents" : "# remove all elements for a clean start\nrm(list=ls(all=TRUE))\ncat(\"\\014\")\n\n## @knitr LoadPackages\nrequire(sas7bdat) # for inputting data \nlibrary(dplyr) # for general data manipulation\nlibrary(reshape2) # for data : wide <-> long\nlibrary(psych) # data summary + etc\nlibrary(ggplot2) # graphing\nlibrary(nlme) # estimate fixed models | esp. gls()\nlibrary(lme4) # estimate mixed models | esp. lmer()\nlibrary(arm) # process model objects\n\n# source(\"./Scripts/Mplus/mplus.R\")\nsource(\"http://www.statmodel.com/mplus-R/mplus.R\")\nls() # list the availible function in mplus.R\n\nm0 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_nocovar.gh5\"\nm1 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80.gh5\"\nm2 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5\"\nm3 <- \"./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5\"\n\n\nmplus.view.plots(m3)\nmodel <- m3\n\nmplus.list.variables(m3)\n\nmplus.plot.histogram(model, \"OUTCOME\")\nmplus.plot.histogram(model, \"TIMEL\")\nmplus.plot.histogram(model, \"EVRSMK1A\")\nmplus.plot.histogram(model, \"EDU11\")\nmplus.plot.histogram(model, \"AGE80\")\nmplus.plot.histogram(model, \"LINEAR\")\nmplus.plot.histogram(model, \"B_OUTCOME\")\n\n# extract raw data\na <- mplus.get.data(m2,\"OUTCOME\")\nb <- mplus.get.data(m2,\"TIMEL\")\nc <- mplus.get.data(m2,\"EDU11\")\nd <- mplus.get.data(m2,\"AGE80\")\ne <- mplus.get.data(m2,\"LINEAR\")\nf <- mplus.get.data(m2,\"B_OUTCOME\")\ng <- mplus.get.data(m2,\"ID\")\n\nds <- data.frame(cbind(a, b, c, d, e, f, g))\nnames(ds) <- c(\"OUTCOME\", \"TIMEL\",\"EDU11\",\"AGE80\",\"LINEAR\",\"B_OUTCOME\",\"ID\")\n\nhead(ds)\n\n\n\n###### ########\nmplus.load(m1)\nmplus.plot.loop(m1, ypred)\n\n\n\n",
3 | "created" : 1426028012622.000,
4 | "dirty" : false,
5 | "encoding" : "UTF-8",
6 | "folds" : "",
7 | "hash" : "76570768",
8 | "id" : "D04C3A18",
9 | "lastKnownWriteTime" : 1426274067,
10 | "path" : "~/GitHub/psy564/Projects/ELSA/CogDecline/extract from mplus.R",
11 | "project_path" : "Projects/ELSA/CogDecline/extract from mplus.R",
12 | "properties" : {
13 | "tempName" : "Untitled1"
14 | },
15 | "source_on_save" : false,
16 | "type" : "r_source"
17 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/28F6BF01:
--------------------------------------------------------------------------------
1 | {
2 | "tempName" : "Untitled1"
3 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/347565E5:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/370278D2:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/554A2E9D:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/69DC04A6:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/769B8DF6:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/9A4E8FDC:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/B85CA76A:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/C08B4901:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/C9B6B2B3:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/D135F4A6:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/D2CF7CAD:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/D5E6305E:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/F22F3062:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/F35B16BA:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/FDC2FC1:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/.Rproj.user/93BC151B/sdb/prop/INDEX:
--------------------------------------------------------------------------------
1 | ~%2FGitHub%2FDiabetes-Tri-Study%2FScripts%2FData%2FdsL_ELSA.r="769B8DF6"
2 | ~%2FGitHub%2Fpsy564%2FChapters%2F02%2FR_Chapter2%2Fhoffman-ch2.R="D2CF7CAD"
3 | ~%2FGitHub%2Fpsy564%2FChapters%2F03%2FR_Chapter3%2Fhoffman-ch3.R="69DC04A6"
4 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fch5-ELSA.R="B85CA76A"
5 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2Fch5-ELSA.Rmd="370278D2"
6 | ~%2FGitHub%2Fpsy564%2FChapters%2F05%2FR_Chapter5%2FdsELSA.R="C08B4901"
7 | ~%2FGitHub%2Fpsy564%2FData%2FDerived%2FELSA%2FdsM_ELSA_varNames.csv="FDC2FC1"
8 | ~%2FGitHub%2Fpsy564%2FData%2FDerived%2FELSA%2FdsM_ELSA_varNames.dat="554A2E9D"
9 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2FdsELSA.R="347565E5"
10 | ~%2FGitHub%2Fpsy564%2FProjects%2FELSA%2FCogDecline%2Fextract%20from%20mplus.R="28F6BF01"
11 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FdsL.R="F35B16BA"
12 | ~%2FGitHub%2Fpsy564%2FScripts%2FData%2FloadChapterDatasets.R="D135F4A6"
13 | ~%2FGitHub%2Fpsy564%2FScripts%2FGraphs%2FbasicTrajectory.R="9A4E8FDC"
14 | ~%2FGitHub%2Fpsy564%2FScripts%2FGraphs%2FbasicTrajectory300.R="D5E6305E"
15 | ~%2FGitHub%2Fpsy564%2FScripts%2FMPlus%2Fmplus.R="C9B6B2B3"
16 | ~%2FGitHub%2Fpsy564%2FScripts%2FUtility%2FInstallPackages.R="F22F3062"
17 |
--------------------------------------------------------------------------------
/Chapters/02/Chapter2_Regions_Figures.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/02/Chapter2_Regions_Figures.xlsx
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_aEq3_EmptyMeans.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.3: Empty Means Model
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | VARIABLE:
9 | NAMES = PersonID cog age grip sexMW demgroup;
10 | USEVARIABLES = cog;
11 | MISSING = ALL (-9999);
12 |
13 | ANALYSIS:
14 | ESTIMATOR = ML;
15 | PROCESSORS = 4;
16 |
17 | MODEL:
18 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_bEq4_AddAge85.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.4: Adding Age (0=85)
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | age85 = age - 85;
10 |
11 | VARIABLE:
12 | NAMES = PersonID cog age grip sexMW demgroup;
13 | USEVARIABLES = cog age85;
14 | MISSING = ALL (-9999);
15 |
16 | ANALYSIS:
17 | ESTIMATOR = ML;
18 | PROCESSORS = 4;
19 |
20 | MODEL:
21 | cog ON age85;
22 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_cEq4_AddOriginalAge.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.4: Adding Original Age Instead
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | VARIABLE:
9 | NAMES = PersonID cog age grip sexMW demgroup;
10 | USEVARIABLES = cog age;
11 | MISSING = ALL (-9999);
12 |
13 | ANALYSIS:
14 | ESTIMATOR = ML;
15 | PROCESSORS = 4;
16 |
17 | MODEL:
18 | cog ON age;
19 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_dEq6_AddGrip9.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.6: Adding Grip (0=9)
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | age85 = age - 85;
10 | grip9 = grip - 9;
11 |
12 | VARIABLE:
13 | NAMES = PersonID cog age grip sexMW demgroup;
14 | USEVARIABLES = cog age85 grip9;
15 | MISSING = ALL (-9999);
16 |
17 | ANALYSIS:
18 | ESTIMATOR = ML;
19 | PROCESSORS = 4;
20 |
21 | MODEL:
22 | cog ON age85 grip9 (bage85 bgrip9);
23 |
24 | MODEL TEST:
25 | ! Model R2 Test
26 | bage85=0;
27 | bgrip9=0;
28 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_eEq7_AddSexMW.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.7: Adding Sex (0=M, 1=W)
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | age85 = age - 85;
10 | grip9 = grip - 9;
11 |
12 | VARIABLE:
13 | NAMES = PersonID cog age grip sexMW demgroup;
14 | USEVARIABLES = cog sexMW age85 grip9;
15 | MISSING = ALL (-9999);
16 |
17 | ANALYSIS:
18 | ESTIMATOR = ML;
19 | PROCESSORS = 4;
20 |
21 | MODEL:
22 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
23 |
24 | MODEL TEST:
25 | ! Model R2 Test
26 | bage85=0;
27 | bgrip9=0;
28 | bsexMW=0;
29 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_fEq6_AddSexWM.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.7: Adding Sex (1=M 0=W)
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter2.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | age85 = age - 85;
10 | grip9 = grip - 9;
11 | IF sexMW EQ 0 THEN sexWM=1;
12 | IF sexMW EQ 1 THEN sexWM=0;
13 |
14 | VARIABLE:
15 | NAMES = PersonID cog age grip sexMW demgroup;
16 | USEVARIABLES = cog age85 grip9 sexWM;
17 | MISSING = ALL (-9999);
18 |
19 | ANALYSIS:
20 | ESTIMATOR = ML;
21 | PROCESSORS = 4;
22 |
23 | MODEL:
24 | cog ON age85 grip9 sexWM;
25 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_gEq8_AddDemNFDemNC.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.8: Adding Dementia Group
3 | Using Manual Group Contrasts so Reference=None
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 |
19 | VARIABLE:
20 | NAMES = PersonID cog age grip sexMW demgroup;
21 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC;
22 | MISSING = ALL (-9999);
23 |
24 | ANALYSIS:
25 | ESTIMATOR = ML;
26 | PROCESSORS = 4;
27 |
28 | MODEL:
29 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
30 | cog ON demNF demNC (bdemNF bdemNC);
31 |
32 | MODEL TEST:
33 | ! Omnibus Dementia Group Test
34 | bdemNF=0;
35 | bdemNC=0;
36 |
37 | MODEL CONSTRAINT:
38 | NEW(est1);
39 | ! est1: Future vs Current
40 | est1 = -1*bdemNF + 1*bdemNC;
41 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_hEq9_AddAge85byGrip9.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.9: Adding Age by Grip Interaction
3 | Age (0=85), Grip (0=9)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age85*grip9;
19 |
20 | VARIABLE:
21 | NAMES = PersonID cog age grip sexMW demgroup;
22 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC agegrip;
23 | MISSING = ALL (-9999);
24 |
25 | ANALYSIS:
26 | ESTIMATOR = ML;
27 | PROCESSORS = 4;
28 |
29 | OUTPUT:
30 | TECH3;
31 |
32 | MODEL:
33 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
34 | cog ON demNF demNC (bdemNF bdemNC);
35 | cog ON agegrip (bagegrip);
36 | [cog] (int);
37 |
38 | MODEL TEST:
39 | ! Model R2 Test
40 | bage85=0;
41 | bgrip9=0;
42 | bsexMW=0;
43 | bdemNF=0;
44 | bdemNC=0;
45 | bagegrip=0;
46 |
47 | MODEL CONSTRAINT:
48 | NEW(est1-est16);
49 | ! est1: Future vs Current
50 | est1 = -1*bdemNF + 1*bdemNC;
51 | ! est2: Age Slope at Grip Strength = 6
52 | est2 = bage85*1 - bagegrip*3;
53 | ! est3: Age Slope at Grip Strength = 9
54 | est3 = bage85*1 + bagegrip*0;
55 | ! est4: Age Slope at Grip Strength = 12
56 | est4 = bage85*1 + bagegrip*3;
57 | ! est5: Grip Strength Slope at Age = 80
58 | est5 = bgrip9*1 - bagegrip*5;
59 | ! est6: Grip Strength Slope at Age = 85
60 | est6 = bgrip9*1 + bagegrip*0;
61 | ! est7: Grip Strength Slope at Age = 90
62 | est7 = bgrip9*1 + bagegrip*5;
63 | ! est8: Cognition at Grip = 12 Age = 80
64 | est8 = int*1 - bage85*5 + bgrip9*3 - bagegrip*15;
65 | ! est9: Cognition at Grip = 12 Age = 85
66 | est9 = int*1 + bage85*0 + bgrip9*3 + bagegrip*0;
67 | ! est10: Cognition at Grip = 12 Age = 90
68 | est10 = int*1 + bage85*5 + bgrip9*3 + bagegrip*15;
69 | ! est11: Cognition at Grip = 9 Age = 80
70 | est11 = int*1 - bage85*5 + bgrip9*0 + bagegrip*0;
71 | ! est12: Cognition at Grip = 9 Age = 85
72 | est12 = int*1 + bage85*0 + bgrip9*0 + bagegrip*0;
73 | ! est13: Cognition at Grip = 9 Age = 90
74 | est13 = int*1 + bage85*5 + bgrip9*0 + bagegrip*0;
75 | ! est14: Cognition at Grip = 6 Age = 80
76 | est14 = int*1 - bage85*5 - bgrip9*3 + bagegrip*15;
77 | ! est15: Cognition at Grip = 6 Age = 85
78 | est15 = int*1 + bage85*0 - bgrip9*3 + bagegrip*0;
79 | ! est16: Cognition at Grip = 6 Age = 90
80 | est16 = int*1 + bage85*5 - bgrip9*3 - bagegrip*15;
81 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_iEq9_AddAge80byGrip12.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.9: Adding Age by Grip Interaction
3 | Age (0=80), Grip (0=12)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age80 = age - 80;
11 | grip12 = grip - 12;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age80*grip12;
19 |
20 | VARIABLE:
21 | NAMES = PersonID cog age grip sexMW demgroup;
22 | USEVARIABLES = cog sexMW age80 grip12 demNF demNC agegrip;
23 | MISSING = ALL (-9999);
24 |
25 | ANALYSIS:
26 | ESTIMATOR = ML;
27 | PROCESSORS = 4;
28 |
29 | MODEL:
30 | cog ON age80 grip12 sexMW (bage80 bgrip12 bsexMW);
31 | cog ON demNF demNC (bdemNF bdemNC);
32 | cog ON agegrip (bagegrip);
33 |
34 | MODEL CONSTRAINT:
35 | NEW(est1);
36 | ! est1: Future vs Current
37 | est1 = -1*bdemNF + 1*bdemNC;
38 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_jEq9_AddAge90byGrip6.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.9: Adding Age by Grip Interaction
3 | Age (0=90), Grip (0=6)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age90 = age - 90;
11 | grip6 = grip - 6;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age90*grip6;
19 |
20 | VARIABLE:
21 | NAMES = PersonID cog age grip sexMW demgroup;
22 | USEVARIABLES = cog sexMW age90 grip6 demNF demNC agegrip;
23 | MISSING = ALL (-9999);
24 |
25 | ANALYSIS:
26 | ESTIMATOR = ML;
27 | PROCESSORS = 4;
28 |
29 | MODEL:
30 | cog ON age90 grip6 sexMW (bage90 bgrip6 bsexMW);
31 | cog ON demNF demNC (bdemNF bdemNC);
32 | cog ON agegrip (bagegrip);
33 |
34 | MODEL CONSTRAINT:
35 | NEW(est1);
36 | ! est1: Future vs Current
37 | est1 = -1*bdemNF + 1*bdemNC;
38 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_kEq13_AddSexMWbyDemNFNC.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.13: Adding Sex by Dementia Interaction
3 | Sex (0=Men), Dementia (0=None)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age85*grip9;
19 | sexNF = sexMW*demNF;
20 | sexNC = sexMW*demNC;
21 |
22 | VARIABLE:
23 | NAMES = PersonID cog age grip sexMW demgroup;
24 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC agegrip sexNF sexNC;
25 | MISSING = ALL (-9999);
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 |
31 | OUTPUT:
32 | TECH3;
33 |
34 | MODEL:
35 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
36 | cog ON demNF demNC (bdemNF bdemNC);
37 | cog ON agegrip sexNF sexNC (bagegrip bsexNF bsexNC);
38 | [cog] (int);
39 |
40 | MODEL TEST:
41 | ! Omnibus Dementia*Sex Interaction Test
42 | bsexNF=0;
43 | bsexNC=0;
44 |
45 | MODEL CONSTRAINT:
46 | NEW(est1-est18);
47 | ! est1: Cognition for Men None
48 | est1 = int*1 + bsexMW*0 + bdemNF*0 + bdemNC*0 + bsexNF*0 + bsexNC*0;
49 | ! est2: Cognition for Women None
50 | est2 = int*1 + bsexMW*1 + bdemNF*0 + bdemNC*0 + bsexNF*0 + bsexNC*0;
51 | ! est3: Cognition for Men Future
52 | est3 = int*1 + bsexMW*0 + bdemNF*1 + bdemNC*0 + bsexNF*0 + bsexNC*0;
53 | ! est4: Cognition for Women Future
54 | est4 = int*1 + bsexMW*1 + bdemNF*1 + bdemNC*0 + bsexNF*1 + bsexNC*0;
55 | ! est5: Cognition for Men Current
56 | est5 = int*1 + bsexMW*0 + bdemNF*0 + bdemNC*1 + bsexNF*0 + bsexNC*0;
57 | ! est6: Cognition for Women Current
58 | est6 = int*1 + bsexMW*1 + bdemNF*0 + bdemNC*1 + bsexNF*0 + bsexNC*1;
59 | ! est7: Sex Difference for No Dementia
60 | est7 = bsexMW*1 + bsexNF*0 + bsexNC*0;
61 | ! est8: Sex Difference for Future Dementia
62 | est8 = bsexMW*1 + bsexNF*1 + bsexNC*0;
63 | ! est9: Sex Difference for Current Dementia
64 | est9 = bsexMW*1 + bsexNF*0 + bsexNC*1;
65 | ! est10: None-Future Difference for Men
66 | est10 = bdemNF*1 + bsexNF*0;
67 | ! est11: None-Future Difference for Women
68 | est11 = bdemNF*1 + bsexNF*1;
69 | ! est12: None-Current Difference for Men
70 | est12 = bdemNC*1 + bsexNC*0;
71 | ! est13: None-Current Difference for Women
72 | est13 = bdemNC*1 + bsexNC*1;
73 | ! est14: Future-Current Difference for Men
74 | est14 = -1*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
75 | ! est15: Future-Current Difference for Women
76 | est15 = -1*bdemNF + 1*bdemNC - 1*bsexNF + 1*bsexNC;
77 | ! est16: None-Future Sex Difference
78 | est16 = 1*bsexNF;
79 | ! est17: None-Current Sex Difference
80 | est17 = 1*bsexNC;
81 | ! est18: Future-Current Sex Difference
82 | est18 = -1*bsexNF + 1*bsexNC;
83 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_lEq13_AddSexWMbyDemNFNC.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.13: Adding Sex by Dementia Interaction
3 | Sex (0=Women), Dementia (0=None)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF sexMW EQ 0 THEN sexWM=1;
13 | IF sexMW EQ 1 THEN sexWM=0;
14 | IF demgroup EQ 1 THEN demNF=0;
15 | IF demgroup EQ 1 THEN demNC=0;
16 | IF demgroup EQ 2 THEN demNF=1;
17 | IF demgroup EQ 2 THEN demNC=0;
18 | IF demgroup EQ 3 THEN demNF=0;
19 | IF demgroup EQ 3 THEN demNC=1;
20 | agegrip = age85*grip9;
21 | sexNF = sexWM*demNF;
22 | sexNC = sexWM*demNC;
23 |
24 | VARIABLE:
25 | NAMES = PersonID cog age grip sexMW demgroup;
26 | USEVARIABLES = cog age85 grip9 sexWM demNF demNC agegrip sexNF sexNC;
27 | MISSING = ALL (-9999);
28 |
29 | ANALYSIS:
30 | ESTIMATOR = ML;
31 | PROCESSORS = 4;
32 |
33 | MODEL:
34 | cog ON age85 grip9 sexWM (bage85 bgrip9 bsexWM);
35 | cog ON demNF demNC (bdemNF bdemNC);
36 | cog ON agegrip sexNF sexNC (bagegrip bsexNF bsexNC);
37 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_mEq15_AddSexMWbyDemFNFC.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.15: Adding Sex by Dementia Interaction
3 | Sex (0=Men), Dementia (0=Future)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demFN=1;
13 | IF demgroup EQ 1 THEN demFC=0;
14 | IF demgroup EQ 2 THEN demFN=0;
15 | IF demgroup EQ 2 THEN demFC=0;
16 | IF demgroup EQ 3 THEN demFN=0;
17 | IF demgroup EQ 3 THEN demFC=1;
18 | agegrip = age85*grip9;
19 | sexFN = sexMW*demFN;
20 | sexFC = sexMW*demFC;
21 |
22 | VARIABLE:
23 | NAMES = PersonID cog age grip sexMW demgroup;
24 | USEVARIABLES = cog sexMW age85 grip9 demFN demFC agegrip sexFN sexFC;
25 | MISSING = ALL (-9999);
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 |
31 | MODEL:
32 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
33 | cog ON demFN demFC (bdemFN bdemFC);
34 | cog ON agegrip sexFN sexFC (bagegrip bsexFN bsexFC);
35 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_nEq15_AddSexWMbyDemFNFC.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.15: Adding Sex by Dementia Interaction
3 | Sex (0=Women), Dementia (0=Future)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF sexMW EQ 0 THEN sexWM=1;
13 | IF sexMW EQ 1 THEN sexWM=0;
14 | IF demgroup EQ 1 THEN demFN=1;
15 | IF demgroup EQ 1 THEN demFC=0;
16 | IF demgroup EQ 2 THEN demFN=0;
17 | IF demgroup EQ 2 THEN demFC=0;
18 | IF demgroup EQ 3 THEN demFN=0;
19 | IF demgroup EQ 3 THEN demFC=1;
20 | agegrip = age85*grip9;
21 | sexFN = sexWM*demFN;
22 | sexFC = sexWM*demFC;
23 |
24 | VARIABLE:
25 | NAMES = PersonID cog age grip sexMW demgroup;
26 | USEVARIABLES = cog age85 grip9 sexWM demFN demFC agegrip sexFN sexFC;
27 | MISSING = ALL (-9999);
28 |
29 | ANALYSIS:
30 | ESTIMATOR = ML;
31 | PROCESSORS = 4;
32 |
33 | MODEL:
34 | cog ON age85 grip9 sexWM (bage85 bgrip9 bsexWM);
35 | cog ON demFN demFC (bdemFN bdemFC);
36 | cog ON agegrip sexFN sexFC (bagegrip bsexFN bsexFC);
37 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_oEq16_AddSexMWbyDemCNCF.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.16: Adding Sex by Dementia Interaction
3 | Sex (0=Men), Dementia (0=Current)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demCN=1;
13 | IF demgroup EQ 1 THEN demCF=0;
14 | IF demgroup EQ 2 THEN demCN=0;
15 | IF demgroup EQ 2 THEN demCF=1;
16 | IF demgroup EQ 3 THEN demCN=0;
17 | IF demgroup EQ 3 THEN demCF=0;
18 | agegrip = age85*grip9;
19 | sexCN = sexMW*demCN;
20 | sexCF = sexMW*demCF;
21 |
22 | VARIABLE:
23 | NAMES = PersonID cog age grip sexMW demgroup;
24 | USEVARIABLES = cog sexMW age85 grip9 demCN demCF agegrip sexCN sexCF;
25 | MISSING = ALL (-9999);
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 |
31 | MODEL:
32 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
33 | cog ON demCN demCF (bdemCN bdemCF);
34 | cog ON agegrip sexCN sexCF (bagegrip bsexCN bsexCF);
35 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_pEq16_AddSexWMbyDemCNCF.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.16: Adding Sex by Dementia Interaction
3 | Sex (0=Women), Dementia (0=Current)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF sexMW EQ 0 THEN sexWM=1;
13 | IF sexMW EQ 1 THEN sexWM=0;
14 | IF demgroup EQ 1 THEN demCN=1;
15 | IF demgroup EQ 1 THEN demCF=0;
16 | IF demgroup EQ 2 THEN demCN=0;
17 | IF demgroup EQ 2 THEN demCF=1;
18 | IF demgroup EQ 3 THEN demCN=0;
19 | IF demgroup EQ 3 THEN demCF=0;
20 | agegrip = age85*grip9;
21 | sexCN = sexWM*demCN;
22 | sexCF = sexWM*demCF;
23 |
24 | VARIABLE:
25 | NAMES = PersonID cog age grip sexMW demgroup;
26 | USEVARIABLES = cog age85 grip9 sexWM demCN demCF agegrip sexCN sexCF;
27 | MISSING = ALL (-9999);
28 |
29 | ANALYSIS:
30 | ESTIMATOR = ML;
31 | PROCESSORS = 4;
32 |
33 | MODEL:
34 | cog ON age85 grip9 sexWM (bage85 bgrip9 bsexWM);
35 | cog ON demCN demCF (bdemCN bdemCF);
36 | cog ON agegrip sexCN sexCF (bagegrip bsexCN bsexCF);
37 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_qEq17_AddAgeSexGripSex.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.17: Adding Age by Sex and Grip by Sex Interactions
3 | Age (0=85), Grip (0=9), Sex (0=Men), Dementia (0=None)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age85*grip9;
19 | sexNF = sexMW*demNF;
20 | sexNC = sexMW*demNC;
21 | agesex = age85*sexMW;
22 | gripsex = grip9*sexMW;
23 |
24 | VARIABLE:
25 | NAMES = PersonID cog age grip sexMW demgroup;
26 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC agegrip sexNF sexNC agesex gripsex;
27 | MISSING = ALL (-9999);
28 |
29 | ANALYSIS:
30 | ESTIMATOR = ML;
31 | PROCESSORS = 4;
32 |
33 | MODEL:
34 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
35 | cog ON demNF demNC (bdemNF bdemNC);
36 | cog ON agegrip sexNF sexNC (bagegrip bsexNF bsexNC);
37 | cog ON agesex gripsex (bagesex bgripsex);
38 |
39 | MODEL CONSTRAINT:
40 | NEW(est1-est16);
41 | ! est1: Age for Men
42 | est1 = bage85*1 + bagesex*0;
43 | ! est2: Age for Women
44 | est2 = bage85*1 + bagesex*1;
45 | ! est3: Grip for Men
46 | est3 = bgrip9*1 + bgripsex*0;
47 | ! est4: Grip for Women
48 | est4 = bgrip9*1 + bgripsex*1;
49 | ! est5: Sex for None
50 | est5 = bsexMW*1 + bsexNF*0 + bsexNC*0;
51 | ! est6: Sex for Future
52 | est6 = bsexMW*1 + bsexNF*1 + bsexNC*0;
53 | ! est7: Sex for Current
54 | est7 = bsexMW*1 + bsexNF*0 + bsexNC*1;
55 | ! est8: Men: None vs Future
56 | est8 = 1*bdemNF + 0*bdemNC + 0*bsexNF + 0*bsexNC;
57 | ! est9: Men: None vs Current
58 | est9 = 0*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
59 | ! est10: Men: Future vs Current
60 | est10 = -1*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
61 | ! est11: Women: None vs Future
62 | est11 = 1*bdemNF + 0*bdemNC + 1*bsexNF + 0*bsexNC;
63 | ! est12: Women: None vs Current
64 | est12 = 0*bdemNF + 1*bdemNC + 0*bsexNF + 1*bsexNC;
65 | ! est13: Women: Future vs Current
66 | est13 = -1*bdemNF + 1*bdemNC - 1*bsexNF + 1*bsexNC;
67 | ! est14: Sex by None vs Future
68 | est14 = 1*bsexNF + 0*bsexNC;
69 | ! est15: Sex by None vs Current
70 | est15 = 0*bsexNF + 1*bsexNC;
71 | ! est16: Sex by Future vs Current
72 | est16 = -1*bsexNF + 1*bsexNC;
73 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_rEq18_AddAgeGripSex.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.18: Adding Adding Age by Grip by Sex Three-Way Interaction
3 | Age (0=85), Grip (0=9), Sex (0=Men), Dementia (0=None)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age85*grip9;
19 | sexNF = sexMW*demNF;
20 | sexNC = sexMW*demNC;
21 | agesex = age85*sexMW;
22 | gripsex = grip9*sexMW;
23 | ags = age85*grip9*sexMW;
24 |
25 | VARIABLE:
26 | NAMES = PersonID cog age grip sexMW demgroup;
27 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC agegrip sexNF sexNC agesex gripsex ags;
28 | MISSING = ALL (-9999);
29 |
30 | ANALYSIS:
31 | ESTIMATOR = ML;
32 | PROCESSORS = 4;
33 |
34 | MODEL:
35 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
36 | cog ON demNF demNC (bdemNF bdemNC);
37 | cog ON agegrip sexNF sexNC (bagegrip bsexNF bsexNC);
38 | cog ON agesex gripsex ags (bagesex bgripsex bags);
39 |
40 | MODEL CONSTRAINT:
41 | NEW(est1-est18);
42 | ! est1: Age for Men
43 | est1 = bage85*1 + bagesex*0;
44 | ! est2: Age for Women
45 | est2 = bage85*1 + bagesex*1;
46 | ! est3: Grip for Men
47 | est3 = bgrip9*1 + bgripsex*0;
48 | ! est4: Grip for Women
49 | est4 = bgrip9*1 + bgripsex*1;
50 | ! est5: Sex for None
51 | est5 = bsexMW*1 + bsexNF*0 + bsexNC*0;
52 | ! est6: Sex for Future
53 | est6 = bsexMW*1 + bsexNF*1 + bsexNC*0;
54 | ! est7: Sex for Current
55 | est7 = bsexMW*1 + bsexNF*0 + bsexNC*1;
56 | ! est8: Men: None vs Future
57 | est8 = 1*bdemNF + 0*bdemNC + 0*bsexNF + 0*bsexNC;
58 | ! est9: Men: None vs Current
59 | est9 = 0*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
60 | ! est10: Men: Future vs Current
61 | est10 = -1*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
62 | ! est11: Women: None vs Future
63 | est11 = 1*bdemNF + 0*bdemNC + 1*bsexNF + 0*bsexNC;
64 | ! est12: Women: None vs Current
65 | est12 = 0*bdemNF + 1*bdemNC + 0*bsexNF + 1*bsexNC;
66 | ! est13: Women: Future vs Current
67 | est13 = -1*bdemNF + 1*bdemNC - 1*bsexNF + 1*bsexNC;
68 | ! est14: Sex by None vs Future
69 | est14 = 1*bsexNF + 0*bsexNC;
70 | ! est15: Sex by None vs Current
71 | est15 = 0*bsexNF + 1*bsexNC;
72 | ! est16: Sex by Future vs Current
73 | est16 = -1*bsexNF + 1*bsexNC;
74 | ! est17: Age by Grip for Men
75 | est17 = 1*bagegrip + 0*bags;
76 | ! est18: Age by Grip for Women
77 | est18 = 1*bagegrip + 1*bags;
78 |
--------------------------------------------------------------------------------
/Chapters/02/MPLUS_Chapter2/MPLUS_Chapter2_sEq13_Final.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 2.13: Final Reported Model
3 | Age (0=85), Grip (0=9), Sex (0=Men), Dementia (0=None)
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter2.csv;
7 | FORMAT = FREE;
8 |
9 | DEFINE:
10 | age85 = age - 85;
11 | grip9 = grip - 9;
12 | IF demgroup EQ 1 THEN demNF=0;
13 | IF demgroup EQ 1 THEN demNC=0;
14 | IF demgroup EQ 2 THEN demNF=1;
15 | IF demgroup EQ 2 THEN demNC=0;
16 | IF demgroup EQ 3 THEN demNF=0;
17 | IF demgroup EQ 3 THEN demNC=1;
18 | agegrip = age85*grip9;
19 | sexNF = sexMW*demNF;
20 | sexNC = sexMW*demNC;
21 |
22 | VARIABLE:
23 | NAMES = PersonID cog age grip sexMW demgroup;
24 | USEVARIABLES = cog sexMW age85 grip9 demNF demNC agegrip sexNF sexNC;
25 | MISSING = ALL (-9999);
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 |
31 | MODEL:
32 | cog ON age85 grip9 sexMW (bage85 bgrip9 bsexMW);
33 | cog ON demNF demNC (bdemNF bdemNC);
34 | cog ON agegrip sexNF sexNC (bagegrip bsexNF bsexNC);
35 |
36 | MODEL TEST:
37 | ! Omnibus Dementia*Sex Interaction Test
38 | bsexNF=0;
39 | bsexNC=0;
40 |
41 | MODEL CONSTRAINT:
42 | NEW(est1-est12);
43 | ! est1: Sex Difference for No Dementia
44 | est1 = bsexMW*1 + bsexNF*0 + bsexNC*0;
45 | ! est2: Sex Difference for Future Dementia
46 | est2 = bsexMW*1 + bsexNF*1 + bsexNC*0;
47 | ! est3: Sex Difference for Current Dementia
48 | est3 = bsexMW*1 + bsexNF*0 + bsexNC*1;
49 | ! est4: None-Future Difference for Men
50 | est4 = bdemNF*1 + bsexNF*0;
51 | ! est5: None-Future Difference for Women
52 | est5 = bdemNF*1 + bsexNF*1;
53 | ! est6: None-Current Difference for Men
54 | est6 = bdemNC*1 + bsexNC*0;
55 | ! est7: None-Current Difference for Women
56 | est7 = bdemNC*1 + bsexNC*1;
57 | ! est8: Future-Current Difference for Men
58 | est8 = -1*bdemNF + 1*bdemNC + 0*bsexNF + 0*bsexNC;
59 | ! est9: Future-Current Difference for Women
60 | est9 = -1*bdemNF + 1*bdemNC - 1*bsexNF + 1*bsexNC;
61 | ! est10: None-Future Sex Difference
62 | est10 = 1*bsexNF;
63 | ! est11: None-Current Sex Difference
64 | est11 = 1*bsexNC;
65 | ! est12: Future-Current Sex Difference
66 | est12 = -1*bsexNF + 1*bsexNC;
67 |
--------------------------------------------------------------------------------
/Chapters/02/OCTO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/02/OCTO.txt
--------------------------------------------------------------------------------
/Chapters/02/R_Chapter2/dsL.R:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/02/R_Chapter2/dsL.R
--------------------------------------------------------------------------------
/Chapters/02/R_Chapter2/hoffman-ch2.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | # Supplementary Material for Longitudinal Analysis: Modeling Within-Person Fluctuation and Change
4 | # Chapter 2: MPLUS Syntax and Output by Model
5 |
6 | ## @knitr LoadPackages
7 | require(sas7bdat)
8 | library(nlme)
9 |
10 |
11 | ## @knitr LoadData
12 | pathDir <- getwd()
13 | pathCh2 <- file.path(pathDir,"Chapters/02/SAS_Chapter2/SAS_Chapter2.sas7bdat")
14 | dsL2 <- read.sas7bdat(pathCh2, debug=TRUE)
15 | ds <- dsL2
16 | names(ds)
17 | str(ds)
18 | table(ds$sexMW, ds$demgroup)
19 |
20 |
21 | ## @knitr EmptyMeansModel
22 | m0 <- nlme::gls(cognition ~ 1, data=ds, method="ML")
23 | summary(m0)
24 | ds$m0 <- predict(m0)
25 |
26 |
27 | ## @knitr AddingAge(0=85)
28 | ds$age85 <- ds$age - 85
29 | # m1 <- nlme::gls(cognition ~ 1 + age85, data=ds, method="ML")
30 | m1 <- stats::glm(cognition ~ 1 + age85, data=ds)
31 | summary(m1)
32 | ds$m1 <- predict(m1)
33 |
34 |
35 | model <- m1
36 | logLik<- summary(model)$logLik
37 | deviance<- -2*logLik
38 | AIC<- AIC(model)
39 | BIC<- BIC(model)
40 | df.resid<- NA
41 | N<- summary(model)$dims$N
42 | p<- summary(model)$dims$p
43 | ids<- length(unique(ds$PersonID))
44 | df.resid<- N-p
45 | mInfo<- data.frame("logLik" = logLik,
46 | "deviance"= deviance,
47 | "AIC" = AIC, "BIC" = BIC,
48 | "df.resid" = df.resid, "N" = N,
49 | "p" = p, "ids" = ids)
50 | t<- t(mInfo)
51 | rownames(t)<-colnames(mInfo)
52 | dsmInfo<- data.frame(new=t)
53 | colnames(dsmInfo) <- c("modelA")
54 | # dsmInfo$Coefficient <- rownames(dsmInfo)
55 | mA <- dsmInfo
56 | print(mA)
57 |
--------------------------------------------------------------------------------
/Chapters/02/R_Chapter2/hoffman-ch2.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Untitled"
3 | author: "Andrey Koval"
4 | date: "Monday, January 12, 2015"
5 | output: html_document
6 | ---
7 |
8 |
9 | ```{r, echo=F, message=F}
10 | library(knitr)
11 | opts_knit$set(root.dir='../../../') #Don't combine this call with any other chunk -especially one that uses file paths.
12 | ```
13 |
14 |
15 | ```{r, echo=F, message=T}
16 | require(knitr)
17 | opts_chunk$set(
18 | results='show',
19 | message = TRUE,
20 | comment = NA,
21 | tidy = FALSE,
22 | # fig.height = 4.8,
23 | # fig.width = 6.5,
24 | out.width = NULL,
25 | fig.path = 'figure_rmd/',
26 | dev = "png",
27 | dpi = 70
28 | )
29 | echoChunks <- FALSE
30 | warningChunks<- FALSE
31 | messageChunks<- FALSE
32 | outwidthChunks <- "90%"
33 | options(width=120) #So the output is 50% wider than the default.
34 | read_chunk("./Chapters/02/R_Chapter2/hoffman-ch2.R") # the file to which knitr calls for the chunks
35 | ```
36 |
37 |
38 | ## Beginnings of modeling
39 |
40 | There are several packages in R suited to fit linear and non-linear models. Some of them that we will use are:
41 | - stats
42 | - nlme
43 | - lme4
44 |
45 |
46 | ### stats
package
47 |
48 | - [Official Documentation](http://www.rdocumentation.org/packages/stats)
49 | - [lm()](http://www.rdocumentation.org/packages/stats/functions/lm) function
50 | - [glm()](http://www.rdocumentation.org/packages/stats/functions/glm) function
51 |
52 |
53 | ### nlme
package
54 | - [Official Documentation](http://www.rdocumentation.org/packages/nlme)
55 | - [gls()](http://www.rdocumentation.org/packages/nlme/functions/gls) function
56 | - see a basic example of model result processing in the slides on [Statistical Modeling](http://ialsa.github.io/COAG-colloquium-2014F/2014-11-18-Statistical-Modeling.html#35) of the COAG [Colloquium series](http://ialsa.github.io/COAG-colloquium-2014F) on reproducible research.
57 |
58 |
59 | ### lme4
package
60 | - [Official Documentation](http://www.rdocumentation.org/packages/lme4)
61 | - [lmer](http://www.rdocumentation.org/packages/nlme/functions/gls) function
62 | - [lmer guide](http://htmlpreview.github.io/?https://github.com/andkov/Longitudinal_Models_of_Religiosity_NLSY97/blob/master/Vignettes/lmer/for%20Appendix/lmerGuide.html#adding-model-output)
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Chapters/02/SAS_Chapter2/SAS_Chapter2.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/02/SAS_Chapter2/SAS_Chapter2.sas7bdat
--------------------------------------------------------------------------------
/Chapters/02/hoffman-ch2.knit.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Untitled"
3 | author: "Andrey Koval"
4 | date: "Monday, January 12, 2015"
5 | output: html_document
6 | ---
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Chapters/03/CHAP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/CHAP.txt
--------------------------------------------------------------------------------
/Chapters/03/Chapter3b_LRTs.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/Chapter3b_LRTs.xlsx
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3a/MPLUS_Chapter3a.csv:
--------------------------------------------------------------------------------
1 | 1,1,55.957283963,57.806318788
2 | 2,1,53.751907541,58.943056442
3 | 3,1,53.255502297,59.149057693
4 | 4,1,44.796028615,44.561577796
5 | 5,1,47.155837804,50.087385986
6 | 6,1,45.030325245,46.902295792
7 | 7,1,45.531226704,50.682110797
8 | 8,1,53.204271854,59.202372304
9 | 9,1,44.922434442,54.122123839
10 | 10,1,49.547571598,57.493299841
11 | 11,1,48.216133309,53.842204966
12 | 12,1,43.26607867,52.729441781
13 | 13,1,53.421233182,61.840788524
14 | 14,1,51.872439533,56.283524602
15 | 15,1,59.348657824,67.106032056
16 | 16,1,59.550481021,62.876913731
17 | 17,1,44.476805682,55.212112947
18 | 18,1,44.752826003,53.59692632
19 | 19,1,49.205520003,53.472559197
20 | 20,1,37.533504082,47.00154487
21 | 21,1,49.779179708,55.929933738
22 | 22,1,45.176923516,51.270398055
23 | 23,1,46.278076819,50.948180215
24 | 24,1,58.407288685,63.25440177
25 | 25,1,42.482405437,48.164511936
26 | 26,2,46.155245033,52.525766026
27 | 27,2,46.639796291,55.424533465
28 | 28,2,62.130913441,63.61611513
29 | 29,2,52.106332761,59.279146508
30 | 30,2,47.570615071,56.986816807
31 | 31,2,40.532193155,47.430344319
32 | 32,2,53.939025905,60.229146044
33 | 33,2,47.215971313,54.697213928
34 | 34,2,45.34969795,57.026963303
35 | 35,2,53.054923017,61.110452154
36 | 36,2,46.883747598,56.313332471
37 | 37,2,55.695269628,62.728856626
38 | 38,2,51.433554916,49.669190235
39 | 39,2,49.505369424,58.536020666
40 | 40,2,55.959596477,68.616302796
41 | 41,2,48.446347249,57.425746359
42 | 42,2,50.49732145,60.902380259
43 | 43,2,52.045289549,59.969413052
44 | 44,2,52.572673115,56.576064094
45 | 45,2,51.946362571,61.393311514
46 | 46,2,52.925010805,66.092277209
47 | 47,2,58.082071372,65.533738256
48 | 48,2,49.309854627,55.304632273
49 | 49,2,51.55191299,62.173306839
50 | 50,2,47.419394763,56.029715171
51 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3a/MPLUS_Chapter3a_aEq1_EmptyBPModel.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3a.1: Empty Between-Person Model
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter3a.csv;
6 | FORMAT = FREE;
7 |
8 | DATA WIDETOLONG:
9 | WIDE = outcome1-outcome2;
10 | LONG = outcome;
11 | IDVARIABLE = PersonID;
12 | REPETITION = time1;
13 |
14 | VARIABLE:
15 | NAMES = PersonID group outcome1 outcome2;
16 | USEVARIABLES = outcome;
17 | MISSING = ALL (-9999);
18 | CLUSTER = PersonID;
19 |
20 | ANALYSIS:
21 | ESTIMATOR = ML;
22 | PROCESSORS = 4;
23 | TYPE = TWOLEVEL RANDOM;
24 |
25 | MODEL:
26 |
27 | %WITHIN%
28 | outcome;
29 |
30 | %BETWEEN%
31 | [outcome];
32 | outcome@0;
33 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3a/MPLUS_Chapter3a_bEq2_EmptyWPModel.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3a.2: Empty Within-Person Model
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter3a.csv;
6 | FORMAT = FREE;
7 |
8 | DATA WIDETOLONG:
9 | WIDE = outcome1-outcome2;
10 | LONG = outcome;
11 | IDVARIABLE = PersonID;
12 | REPETITION = time1;
13 |
14 | VARIABLE:
15 | NAMES = PersonID group outcome1 outcome2;
16 | USEVARIABLES = outcome;
17 | MISSING = ALL (-9999);
18 | CLUSTER = PersonID;
19 |
20 | ANALYSIS:
21 | ESTIMATOR = ML;
22 | PROCESSORS = 4;
23 | TYPE = TWOLEVEL RANDOM;
24 |
25 | MODEL:
26 |
27 | %WITHIN%
28 | outcome;
29 |
30 | %BETWEEN%
31 | [outcome];
32 | outcome;
33 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3a/MPLUS_Chapter3a_cEq7_CondBPModel.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3a.7: Conditional Between-Person Model (top of Eq. 3.7)
3 | Manual Contrasts for Time and Group
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter3a.csv;
7 | FORMAT = FREE;
8 |
9 | DATA WIDETOLONG:
10 | WIDE = outcome1-outcome2;
11 | LONG = outcome;
12 | IDVARIABLE = PersonID;
13 | REPETITION = time1;
14 |
15 | DEFINE:
16 | treat = group - 1;
17 |
18 | VARIABLE:
19 | NAMES = PersonID group outcome1 outcome2;
20 | USEVARIABLES = outcome time1 treat;
21 | MISSING = ALL (-9999);
22 | CLUSTER = PersonID;
23 | WITHIN = time1;
24 | BETWEEN = treat;
25 |
26 | ANALYSIS:
27 | ESTIMATOR = ML;
28 | PROCESSORS = 4;
29 | TYPE = TWOLEVEL RANDOM;
30 |
31 | MODEL:
32 |
33 | %WITHIN%
34 | outcome (resvar);
35 | time | outcome ON time1;
36 |
37 | %BETWEEN%
38 | [outcome time] (int btime1);
39 | outcome@0 time@0;
40 | outcome time ON treat (btreat btimtreat);
41 |
42 | MODEL CONSTRAINT:
43 | NEW(est1-est8);
44 | ! est1: Mean: Control Group at Pre-Test
45 | est1 = int*1 + btime1*0 + btreat*0 + btimtreat*0;
46 | ! est2: Mean: Control Group at Post-Test
47 | est2 = int*1 + btime1*1 + btreat*0 + btimtreat*0;
48 | ! est3: Mean: Treatment Group at Pre-Test
49 | est3 = int*1 + btime1*0 + btreat*1 + btimtreat*0;
50 | ! est4: Mean: Treatment Group at Post-Test
51 | est4 = int*1 + btime1*1 + btreat*1 + btimtreat*1;
52 | ! est5: Time Effect for Control Group
53 | est5 = btime1*1 + btimtreat*0;
54 | ! est6: Time Effect for Treatment Group
55 | est6 = btime1*1 + btimtreat*1;
56 | ! est7: Group Effect at Pre-Tmplusest
57 | est7 = btreat*1 + btimtreat*0;
58 | ! est8: Group Effect at Post-Tmplusest
59 | est8 = btreat*1 + btimtreat*1;
60 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3a/MPLUS_Chapter3a_dEq7_CondWPModel.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3a.7: Conditional Within-Person Model (bottom of Eq. 3.7)
3 | Manual Contrasts for Time and Group
4 |
5 | DATA:
6 | FILE = MPLUS_Chapter3a.csv;
7 | FORMAT = FREE;
8 |
9 | DATA WIDETOLONG:
10 | WIDE = outcome1-outcome2;
11 | LONG = outcome;
12 | IDVARIABLE = PersonID;
13 | REPETITION = time1;
14 |
15 | DEFINE:
16 | treat = group - 1;
17 |
18 | VARIABLE:
19 | NAMES = PersonID group outcome1 outcome2;
20 | USEVARIABLES = outcome time1 treat;
21 | MISSING = ALL (-9999);
22 | CLUSTER = PersonID;
23 | WITHIN = time1;
24 | BETWEEN = treat;
25 |
26 | ANALYSIS:
27 | ESTIMATOR = ML;
28 | PROCESSORS = 4;
29 | TYPE = TWOLEVEL RANDOM;
30 |
31 | MODEL:
32 |
33 | %WITHIN%
34 | outcome (resvar);
35 | time | outcome ON time1;
36 |
37 | %BETWEEN%
38 | [outcome time] (int btime1);
39 | outcome time@0 (intvar);
40 | outcome time ON treat (btreat btimtreat);
41 |
42 | MODEL CONSTRAINT:
43 | NEW(est1-est9);
44 | ! est1: Mean: Control Group at Pre-Test
45 | est1 = int*1 + btime1*0 + btreat*0 + btimtreat*0;
46 | ! est2: Mean: Control Group at Post-Test
47 | est2 = int*1 + btime1*1 + btreat*0 + btimtreat*0;
48 | ! est3: Mean: Treatment Group at Pre-Test
49 | est3 = int*1 + btime1*0 + btreat*1 + btimtreat*0;
50 | ! est4: Mean: Treatment Group at Post-Test
51 | est4 = int*1 + btime1*1 + btreat*1 + btimtreat*1;
52 | ! est5: Time Effect for Control Group
53 | est5 = btime1*1 + btimtreat*0;
54 | ! est6: Time Effect for Treatment Group
55 | est6 = btime1*1 + btimtreat*1;
56 | ! est7: Group Effect at Pre-Tmplusest
57 | est7 = btreat*1 + btimtreat*0;
58 | ! est8: Group Effect at Post-Tmplusest
59 | est8 = btreat*1 + btimtreat*1;
60 | ! est9: Conditional Intraclass Correlation
61 | est9 = intvar/(intvar+resvar);
62 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3b/MPLUS_Chapter3b_aEq10_BPANOVA.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3b.10: Between-Person Independent ANOVA
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter3b.csv;
6 | FORMAT = FREE;
7 |
8 | DATA LONGTOWIDE:
9 | LONG = rt;
10 | WIDE = rt1-rt6;
11 | IDVARIABLE = PersonID;
12 | REPETITION = session (1-6);
13 |
14 | DEFINE:
15 | ! Rescale original rt so Mplus will show all results
16 | rt = rt/10;
17 |
18 | VARIABLE:
19 | NAMES = PersonID session rt;
20 | USEVARIABLES = rt1-rt6;
21 | MISSING = ALL (-9999);
22 |
23 | ANALYSIS:
24 | ESTIMATOR = ML;
25 | PROCESSORS = 4;
26 |
27 | MODEL:
28 | rt1-rt6 (totvar);
29 | rt1-rt6 WITH rt1-rt6@0;
30 | [rt1-rt6] (mean1-mean6);
31 |
32 | MODEL TEST:
33 | ! Omnibus Test of Session Mean Differences
34 | 0=mean6-mean1;
35 | 0=mean6-mean2;
36 | 0=mean6-mean3;
37 | 0=mean6-mean4;
38 | 0=mean6-mean5;
39 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3b/MPLUS_Chapter3b_bEq10_UnivRMANOVA.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3b.10: Univariate Repeated Measures ANOVA
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter3b.csv;
6 | FORMAT = FREE;
7 |
8 | DATA LONGTOWIDE:
9 | LONG = rt;
10 | WIDE = rt1-rt6;
11 | IDVARIABLE = PersonID;
12 | REPETITION = session (1-6);
13 |
14 | DEFINE:
15 | ! Rescale original rt so Mplus will show all results
16 | rt = rt/10;
17 |
18 | VARIABLE:
19 | NAMES = PersonID session rt;
20 | USEVARIABLES = rt1-rt6;
21 | MISSING = ALL (-9999);
22 |
23 | ANALYSIS:
24 | ESTIMATOR = ML;
25 | PROCESSORS = 4;
26 |
27 | OUTPUT:
28 | STDYX;
29 |
30 | MODEL:
31 | rt1-rt6 (totvar);
32 | rt1-rt6 WITH rt1-rt6 (totcov);
33 | [rt1-rt6] (mean1-mean6);
34 |
35 | MODEL TEST:
36 | ! Omnibus Test of Session Mean Differences
37 | 0=mean6-mean1;
38 | 0=mean6-mean2;
39 | 0=mean6-mean3;
40 | 0=mean6-mean4;
41 | 0=mean6-mean5;
42 |
--------------------------------------------------------------------------------
/Chapters/03/MPLUS_Chapter3b/MPLUS_Chapter3b_cEq10_MultivRMANOVA.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Eq 3b.10: Multivariate Repeated Measures ANOVA
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter3b.csv;
6 | FORMAT = FREE;
7 |
8 | DATA LONGTOWIDE:
9 | LONG = rt;
10 | WIDE = rt1-rt6;
11 | IDVARIABLE = PersonID;
12 | REPETITION = session (1-6);
13 |
14 | DEFINE:
15 | ! Rescale original rt so Mplus will show all results
16 | rt = rt/10;
17 |
18 | VARIABLE:
19 | NAMES = PersonID session rt;
20 | USEVARIABLES = rt1-rt6;
21 | MISSING = ALL (-9999);
22 |
23 | ANALYSIS:
24 | ESTIMATOR = ML;
25 | PROCESSORS = 4;
26 |
27 | OUTPUT:
28 | STDYX;
29 |
30 | MODEL:
31 | rt1-rt6;
32 | rt1-rt6 WITH rt1-rt6;
33 | [rt1-rt6] (mean1-mean6);
34 |
35 | MODEL TEST:
36 | ! Omnibus Test of Session Mean Differences
37 | 0=mean6-mean1;
38 | 0=mean6-mean2;
39 | 0=mean6-mean3;
40 | 0=mean6-mean4;
41 | 0=mean6-mean5;
42 |
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/EmptyBP4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/EmptyBP4.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/EmptyBP5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/EmptyBP5.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/EmptyWP4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/EmptyWP4.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/EmptyWP5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/EmptyWP5.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/GraphingData0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/GraphingData0.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/GraphingData1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/GraphingData1.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/GraphingData2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/GraphingData2.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/GraphingData3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/GraphingData3.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/figure_rmd/StackData.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/R_Chapter3/figure_rmd/StackData.png
--------------------------------------------------------------------------------
/Chapters/03/R_Chapter3/slide308.R:
--------------------------------------------------------------------------------
1 | rm(list=ls(all=TRUE)) # clears environment
2 | cat("\014") # clears console
3 |
4 | library(dplyr)
5 | library(plyr)
6 | library(ggplot2)
7 | library(reshape2)
8 |
9 |
10 |
11 |
12 | # create a vector of data called Y containing numbers 4, 6, 5, 7, 8
13 | Y <- c(4, 6, 5, 7, 8)
14 |
15 | # at this moment Y is of class...
16 | class(Y)
17 |
18 | # we can make it a matrix using matric() function
19 | Y <- matrix(Y,5,1,byrow=TRUE) # matrix (data,#rows,#columns,...)
20 |
21 |
22 | # create six data vectors of length 5 , one for each person (i)
23 | i1 <- c(1, 11, 11.5, 11.8, 10.3, 9.5)
24 | i2 <- c(2, 9, 9.8, 9.7, 9.6, 9.3)
25 | i3 <- c(3, 9, 7.8, 8.1, 9.1, 7.8)
26 | i4 <- c(4, 6.8, 7.9, 7, 7.8, 6.8)
27 | i5 <- c(5, 6.4, 6.2, 6.8, 7.1, 7.2)
28 | i6 <- c(6, 4, 5.6, 4.5, 5.2, 6.8)
29 |
30 | # combine
31 | data <- cbind(i1, i2, i3, i4, i5, i6)
32 | data
33 |
34 | class(data)
35 | X <- matrix(data,6,6, byrow=TRUE)
36 | X
37 |
38 |
39 | i <- paste0("i",1:6)
40 | vars <- c("id",paste0("t",1:5))
41 | X
42 | rownames(X) <- i
43 | X
44 | colnames(X) <- vars
45 | X
46 |
47 | ds <- data.frame(X)
48 | ds
49 |
50 | p <- ggplot(ds, aes(x=1:6))
51 | p <- geom_line(aes(y=t1))
52 |
53 |
54 |
55 |
56 | dsLong <- reshape2::melt(ds, id.vars="id")
57 | dsLong <- dsLong[order(dsLong$id, dsLong$variable),]
58 | head(dsLong,12)
59 | dsLong$variable <- gsub(pattern="t", replacement='', x=dsLong$variable)
60 | head(dsLong,12)
61 | str(dsLong)
62 | dsLong$variable <- as.integer(dsLong$variable)
63 | str(dsLong)
64 | dsLong <- plyr::rename(dsLong,c("variable"="time", "value"="outcome"))
65 | ds <- dsLong
66 | head(ds)
67 |
68 | pathDir <- getwd()
69 | source(file.path(pathDir,"Scripts/Graphs/graphThemes.R"))
70 | p <- ggplot2::ggplot(ds,aes(x=time,y=outcome))
71 | p <- p + geom_line(aes(group=id, color=factor(id)))
72 | p <- p + geom_point(aes(group=id, color=factor(id)))
73 | p <- p + theme1
74 | p <- p + scale_x_continuous(limits=c(1,5), breaks=seq(0,6))
75 | p <- p + scale_y_continuous(limits=c(0,12),
76 | breaks=seq(0,13, by=2))
77 | p <- p + labs(list(
78 | title="Hypothetical trajectories from slide 308",
79 | x="Occasion", y="Outcome"))
80 | p
81 |
--------------------------------------------------------------------------------
/Chapters/03/SAS_Chapter3a/SAS_Chapter3a.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/SAS_Chapter3a/SAS_Chapter3a.sas7bdat
--------------------------------------------------------------------------------
/Chapters/03/SAS_Chapter3b/SAS_Chapter3b.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/03/SAS_Chapter3b/SAS_Chapter3b.sas7bdat
--------------------------------------------------------------------------------
/Chapters/04/Chapter4_LRTs.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/04/Chapter4_LRTs.xlsx
--------------------------------------------------------------------------------
/Chapters/04/MIDUS-NSDE.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/04/MIDUS-NSDE.txt
--------------------------------------------------------------------------------
/Chapters/04/SAS_Chapter4/SAS_Chapter4.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/04/SAS_Chapter4/SAS_Chapter4.sas7bdat
--------------------------------------------------------------------------------
/Chapters/05/Chapter5_LRTs_CIs_R2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/Chapter5_LRTs_CIs_R2.xlsx
--------------------------------------------------------------------------------
/Chapters/05/MPlus_Chapter5/Ch5_Mplus.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/MPlus_Chapter5/Ch5_Mplus.pdf
--------------------------------------------------------------------------------
/Chapters/05/MPlus_Chapter5/ELSA_MLMGROWTH_EMPTY.inp:
--------------------------------------------------------------------------------
1 | Title: ELSA MLM Hoffman Chapter 5 Extended Example
2 |
3 | Data: File is ELSA_LONG_n1000.dat ;
4 |
5 | Variable: Names are
6 | idauniq idahhw wgt year year2 wave wave2 age2
7 | dageyrs ddobyrs dyear0 dyrsobs dagefat dagemot
8 | dsex deduqual dethnic dhhsize dmarsta
9 |
10 | eclaind eclahh einchhg ejobfath edqualw1 eincind
11 | eclafath ewthphy ewthnfn ewthfin ewthinv ewthsav
12 | eincspn eincppn einchh eworksta
13 |
14 | balcupw0 balcamt0 bsmkqty bsmkevr bsmknow balcoft balcdlw
15 |
16 | hcvddia hrspdia hdigdia hmskdia hblddia hagdmoth
17 | hcodmoth hagdfath hcodfath hsrhscr hbminum hfvcltr
18 | hfevltr hlunglm hangdia hdibdia hcandia hpsydia
19 | hdgskgs hngskgs hmapprs hpulprs hdiaprs hsysprs
20 | hwlksec hcr5sec hiadsca hadlsca
21 |
22 | psspscr0 pc19sca pdepsca
23 |
24 | csrmscr cwrlnum caninum cprmscr cdwlnum;
25 |
26 | Missing are all (-9999);
27 |
28 | ! List of ALL variables used in model;
29 | USEVARIABLES ARE cdwlnum; ! Use in random int model;
30 | !USEVARIABLES ARE time cdwlnum; ! Use in linear time models;
31 |
32 | ! limit cases;
33 | ! USEOBSERVATIONS = ;
34 |
35 | ! Identify person-level nesting;
36 | CLUSTER = idauniq;
37 | ! Predictor variables measured within-persons (just time for now);
38 | WITHIN = ; ! Use in random int model;
39 | !WITHIN = time; ! Use in linear models;
40 |
41 | ! Predictor variables measured between-persons (none right now);
42 | BETWEEN = ;
43 |
44 | Define: age65=dageyrs-65;
45 | time=year;
46 |
47 | ANALYSIS: TYPE IS TWOLEVEL RANDOM; ! 2-level model with random slopes;
48 | ESTIMATOR IS ML;
49 | MODEL:
50 | !!!!! Model 1: Empty, Random Intercept Only Model;
51 | ! Level-1, time-level model;
52 | %WITHIN% ! Residual included by default;
53 | ;
54 | ! Level-2, person-level model;
55 | %BETWEEN%
56 | cdwlnum*; ! Random int included by default;
57 |
58 | !!!!! Model 2: Fixed Linear, Random Intercept Model;
59 | ! Level-1, time-level model;
60 | ! %WITHIN% ! Residual included by default;
61 | ! ? ! Fixed linear slope;
62 | ! Level-2, person-level model;
63 | ! %BETWEEN%
64 | ! cdwlnum* ! Random int included by default;
65 | ! ? ! No random linear variance;
66 |
67 | !!!!! Model 3: Random Linear Only Model;
68 | ! Level-1, time-level model;
69 | ! %WITHIN% ! Residual included by default;
70 | ! ? ! Fixed linear slope;
71 | ! Level-2, person-level model;
72 | ! %BETWEEN%
73 | ! cdwlnum* ! Random int included by default;
74 | ! ? ! Random linear variance;
75 | ! ? ! Int-Linear covariance;
76 |
77 | Output: sampstat;
78 |
79 |
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/.Rhistory:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | cat("\014")
4 | ## @knitr InstallPackage
5 | # source("./Scripts/Utility/InstallPackages.R")
6 | ## @knitr LoadPackages
7 | require(sas7bdat) # for inputting data
8 | library(dplyr) # for general data manipulation
9 | library(reshape2) # for data : wide <-> long
10 | library(psych) # data summary + etc
11 | library(ggplot2) # graphing
12 | library(nlme) # estimate mixed models | esp. gls()
13 | library(lme4) # estimate mixed models | esp. lmer()
14 | library(arm) # process model objects
15 | ## @knitr LoadData
16 | pathDir <- getwd() # get working directory, e.i. residence of .Rproj file
17 | pathFile <- file.path(pathDir,"Chapters/05/SAS_Chapter5/SAS_Chapter5.sas7bdat") # location of the file
18 | ds0 <- read.sas7bdat(pathFile, debug=TRUE) # import file
19 | # ds0 <- readRDS("~/GitHub/psy564/Data/Raw/ELSA/ds0_ELSA.rds")
20 | ds0 <- data.frame(ds0) # save as a data frame
21 | ## @knitr BasicDescriptive
22 | class(ds0) # what class?
23 | dim(ds0) # what dimensions?
24 | names(ds0) # what are column names?
25 | str(ds0) # what its structure?
26 | head(ds0) # what do first few lines look like?
27 | base::summary(ds0) # basic summary
28 | psych::describe(ds0) # summary by psych package
29 | table(ds0$wave)# one-way table
30 | ## @knitr StackData
31 | dsL <- ds0
32 | ## @knitr TweakLong
33 | dsM <- dsL
34 | ## @knitr dummyChunk
35 | #### Basic Graphs ####
36 | ## @knitr GraphingData0
37 | p <- ggplot2::ggplot(dsM,aes(x=wave,y=outcome)) # map data dimension
38 | p <- p + geom_line(aes(group=PersonID)) # draw lines and map unit of measurement
39 | p
40 | ## @knitr LoadGraphThemes
41 | baseSize <- 12 # set as the point of further reference
42 | theme1 <- ggplot2::theme_bw(base_size=baseSize) +
43 | ggplot2::theme(title=ggplot2::element_text(colour="gray20",size = baseSize+1)) +
44 | ggplot2::theme(axis.text=ggplot2::element_text(colour="gray40", size=baseSize-2)) +
45 | ggplot2::theme(axis.title=ggplot2::element_text(colour="gray40")) +
46 | ggplot2::theme(panel.border = ggplot2::element_rect(colour="gray80")) +
47 | ggplot2::theme(axis.ticks.length = grid::unit(0, "cm")) +
48 | ggplot2::theme(text = element_text(size =baseSize+7))
49 | ## @knitr GraphingData1
50 | p <- ggplot2::ggplot(dsM,aes(x=wave,y=outcome))
51 | p <- p + geom_line(aes(group=PersonID)) # draw lines
52 | p <- p + theme1
53 | p <- p + scale_x_continuous(limits=c(1,4), breaks=c(1:4)) # X axis
54 | p <- p + scale_y_continuous(limits=c(5,25),
55 | breaks=seq(5,25, by=5)) # Y axis
56 | p <- p + labs(list(
57 | title="Does outcome change over time?", # main title
58 | x="Wave of measurement", y="Performance on the outcome")) # axes titles
59 | p
60 | # remove all elements for a clean start
61 | rm(list=ls(all=TRUE))
62 | cat("\014")
63 | ## @knitr InstallPackage
64 | # source("./Scripts/Utility/InstallPackages.R")
65 | ## @knitr LoadPackages
66 | require(sas7bdat) # for inputting data
67 | library(dplyr) # for general data manipulation
68 | library(reshape2) # for data : wide <-> long
69 | library(psych) # data summary + etc
70 | library(ggplot2) # graphing
71 | library(nlme) # estimate mixed models | esp. gls()
72 | library(lme4) # estimate mixed models | esp. lmer()
73 | library(arm) # process model objects
74 | ## @knitr LoadData
75 | pathDir <- getwd() # get working directory, e.i. residence of .Rproj file
76 | pathFile <- file.path(pathDir,"Chapters/05/SAS_Chapter5/SAS_Chapter5.sas7bdat") # location of the file
77 | ds0 <- read.sas7bdat(pathFile, debug=TRUE) # import file
78 | # ds0 <- readRDS("~/GitHub/psy564/Data/Raw/ELSA/ds0_ELSA.rds")
79 | ds0 <- data.frame(ds0) # save as a data frame
80 | ## @knitr BasicDescriptive
81 | class(ds0) # what class?
82 | dim(ds0) # what dimensions?
83 | names(ds0) # what are column names?
84 | str(ds0) # what its structure?
85 | head(ds0) # what do first few lines look like?
86 | base::summary(ds0) # basic summary
87 | psych::describe(ds0) # summary by psych package
88 | table(ds0$wave)# one-way table
89 | pathFile
90 | ds0 <- read.sas7bdat(pathFile, debug=TRUE) # import file
91 |
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/SimpleExample_Key.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | cat("\014")
4 |
5 | library(dplyr)
6 | library(lme4)
7 | library(ggplot2)
8 |
9 | #### Data entry ####
10 | y <- c(2,3,2,1,2,1,5,5)
11 | id <- c(1,1,1,1,2,2,2,2)
12 | ds <- data.frame(cbind(id,y))
13 | ds
14 | ds$wave <- with(ds, ave( id, id, FUN = seq_along)) # sequential numbers
15 | ds
16 |
17 | ds1 <- ds[ds$id==1,]
18 | ds2 <- ds[ds$id==2,]
19 |
20 | lm(y ~ 1, ds1)
21 | lm(y ~ 1, ds2)
22 |
23 |
24 |
25 | # dplyr::group_by(ds,id) %>% dplyr::summarize(means = mean(y))
26 |
27 | mean(ds[ds$id==1,"y"])
28 | mean(ds[ds$id==2,"y"])
29 |
30 |
31 | head(ds)
32 |
33 | #### Model m00 ####
34 | m00 <- lm(y ~ 1 ,ds)
35 | ds$m00 <- predict(m00)
36 | ds
37 | #### Model m01 ####
38 | m01 <- lm(y ~ 1 + wave, ds)
39 | ds$m01 <- predict(m01)
40 | ds
41 | #### Model m0* ####
42 | m0_1 <- lm(y ~ 1, ds1)
43 | m0_2 <- lm(y ~ 1, ds2)
44 | # # Automating grouping with dplyr
45 | # results<-ds %.%
46 | # group_by(id) %.%
47 | # do(model =lm(y ~ 1 , data = .))
48 | # coef(results$model[[1]])
49 | # coef(results$model[[2]])
50 | ds1$m0_ <- predict(m0_1)
51 | ds2$m0_ <- predict(m0_2)
52 | dsa <- merge(ds, rbind(ds1,ds2))
53 | ds
54 |
55 |
56 | #### Model m1* ####
57 | m1_1 <- lm(y ~ 1 + wave, ds1)
58 | m1_2 <- lm(y ~ 1 + wave, ds2)
59 | # # Automating grouping with dplyr
60 | # results<-ds %.%
61 | # group_by(id) %.%
62 | # do(model =lm(y ~ 1 + wave , data = .))
63 | # coef(results$model[[1]])
64 | # round(coef(results$model[[2]]),2)
65 | ds1$m1_ <- predict(m1_1)
66 | ds2$m1_ <- predict(m1_2)
67 | ds <- merge(ds, rbind(ds1,ds2))
68 | ds
69 |
70 | #### Model m0 ####
71 | m0 <- lme4::lmer(y ~ 1 + (1|id) , data = ds)
72 | ranef(m0)
73 | fixef(m0)
74 | ds$m0 <- predict(m0)
75 | ds
76 |
77 | #### Model m0a ####
78 | m0a <- lme4::lmer(y ~ 1 + wave + (1|id) , data = ds)
79 | ranef(m0a)
80 | fixef(m0a)
81 | ds$m0a <- predict(m0a)
82 | ds
83 |
84 | #### Model m1 ####
85 | m1 <- lme4::lmer(y ~ 1 + wave + (1 + wave|id) , data = ds)
86 | ranef(m1)
87 | fixef(m1)
88 | ds$m1 <- predict(m1)
89 | ds
90 |
91 |
92 | #### Graphing ####
93 |
94 |
95 | baseSize <- 12 # set as the point of further reference
96 | theme1 <- ggplot2::theme_bw(base_size=baseSize) +
97 | ggplot2::theme(title=ggplot2::element_text(colour="gray20",size = baseSize+1)) +
98 | ggplot2::theme(axis.text=ggplot2::element_text(colour="gray40", size=baseSize-2)) +
99 | ggplot2::theme(axis.title=ggplot2::element_text(colour="gray40")) +
100 | ggplot2::theme(panel.border = ggplot2::element_rect(colour="gray80")) +
101 | ggplot2::theme(axis.ticks.length = grid::unit(0, "cm")) +
102 | ggplot2::theme(text = element_text(size =baseSize+7))
103 |
104 |
105 | ds
106 | g <- ggplot(ds, aes(x=wave,y=y, group=id))#, color=factor(id)))
107 | g <- g + geom_line()
108 | g <- g + geom_point(shape=21, size=4, fill="purple", alpha=.5)
109 | # g <- g + geom_line(aes(y=m1_), color="red", linetype="dashed", size=2)
110 | g <- g + geom_line(aes(y=m00, color=factor(id)), linetype="dashed", size=2)
111 | g <- g + scale_y_continuous(limits=c(0,6))
112 | g <- g + theme1
113 | g
114 |
115 |
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/SimpleExample_Key.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/SimpleExample_Key.xlsx
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/SimpleExample_studentCopy.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | cat("\014")
4 |
5 | library(dplyr)
6 | library(lme4)
7 | library(ggplot2)
8 |
9 | #### Data entry ####
10 | y <- c(2,3,2,1,2,1,5,5)
11 | id <- c(1,1,1,1,2,2,2,2)
12 | ds <-
13 |
14 |
15 | head(ds)
16 |
17 | #### Model m00 ####
18 |
19 |
20 |
21 | #### Model m01 ####
22 |
23 |
24 |
25 | #### Model m0* ####
26 |
27 |
28 |
29 | #### Model m1* ####
30 |
31 |
32 |
33 | #### Model m0 ####
34 |
35 |
36 |
37 | #### Model m0a ####
38 |
39 |
40 |
41 |
42 | #### Model m1 ####
43 |
44 |
45 |
46 |
47 |
48 | #### Graphing ####
49 |
50 |
51 | baseSize <- 12 # set as the point of further reference
52 | theme1 <- ggplot2::theme_bw(base_size=baseSize) +
53 | ggplot2::theme(title=ggplot2::element_text(colour="gray20",size = baseSize+1)) +
54 | ggplot2::theme(axis.text=ggplot2::element_text(colour="gray40", size=baseSize-2)) +
55 | ggplot2::theme(axis.title=ggplot2::element_text(colour="gray40")) +
56 | ggplot2::theme(panel.border = ggplot2::element_rect(colour="gray80")) +
57 | ggplot2::theme(axis.ticks.length = grid::unit(0, "cm")) +
58 | ggplot2::theme(text = element_text(size =baseSize+7))
59 |
60 |
61 | ds
62 | g <- ggplot(ds, aes(x=wave,y=y, group=id))#, color=factor(id)))
63 | g <- g + geom_line()
64 | g <- g + geom_point(shape=21, size=4, fill="purple", alpha=.5)
65 | # g <- g + geom_line(aes(y=m1_), color="red", linetype="dashed", size=2)
66 | g <- g + geom_line(aes(y=m00, color=factor(id)), linetype="dashed", size=2)
67 | g <- g + scale_y_continuous(limits=c(0,6))
68 | g <- g + theme1
69 | g
70 |
71 |
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/SimpleExample_studentCopy.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/SimpleExample_studentCopy.xlsx
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphM3_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphM3_1.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphM5_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphM5_1.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphM5_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphM5_3.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphM5_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphM5_5.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphingData0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphingData0.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphingData1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphingData1.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/figure_rmd/GraphingData2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/figure_rmd/GraphingData2.png
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/general.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/general.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/how to adapt CH5 script for ELSA study.txt:
--------------------------------------------------------------------------------
1 | How to adapt "hoffman-ch5.R" to analyze ELSA data
2 |
3 | 0. Input new data, replace line 22
4 |
5 | ds0 <- readRDS("~/GitHub/psy564/Data/Derived/ELSA/dsM_ELSA.rds")
6 |
7 | 1. Add on line 44
8 |
9 | dsM <- dplyr::filter(dsM, id %in% sample(unique(id),100))
10 |
11 |
12 | 2. Change all "PersonID" to "id"
13 |
14 | 3. Change all "outcome" to "irecall"
15 |
16 | 4. Change "limits=c(5,25)" to "limits=c(0,10)"
17 |
18 | 5. Change "breaks=seq(5,25, by=5)" to "breaks=seq(0,10, by=1)"
19 |
20 | 6. Add jitter for dots in the graphs
21 |
22 | change
23 |
24 | geom_point(size=3, shape=21, fill=NA, color="black", alpha=.6)
25 |
26 | into
27 |
28 | geom_point(size=3, shape=21, fill=NA, color="black", alpha=.6,
29 | position=position_jitter(h=.3,w=0))
30 |
31 |
32 | 7. Link new RMD to a new R file
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/general.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/general.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/m3.1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/m3.1.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/m5.1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/m5.1.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/m5.3.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/m5.3.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/m5.5.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/m5.5.JPG
--------------------------------------------------------------------------------
/Chapters/05/R_Chapter5/images/m5.5a.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/R_Chapter5/images/m5.5a.JPG
--------------------------------------------------------------------------------
/Chapters/05/SAS_Chapter5/SAS_Chapter5.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/05/SAS_Chapter5/SAS_Chapter5.sas7bdat
--------------------------------------------------------------------------------
/Chapters/06/CHAP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/06/CHAP.txt
--------------------------------------------------------------------------------
/Chapters/06/Chapter6_LRTs_CIs_R2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/06/Chapter6_LRTs_CIs_R2.xlsx
--------------------------------------------------------------------------------
/Chapters/06/MPlus_Chpater6/2b R(I) R(S).inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Ch 6: 2b: Random Linear Time Model
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter6.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! Rescale rt so Mplus will show all results
10 | rt = rt/10;
11 | time1 = session - 1;
12 |
13 | VARIABLE:
14 | NAMES = PersonID session rt;
15 | USEVARIABLES = rt time1;
16 | MISSING = ALL (-9999);
17 | CLUSTER = PersonID;
18 | WITHIN = time1;
19 |
20 | ANALYSIS:
21 | ESTIMATOR = ML;
22 | PROCESSORS = 4;
23 | TYPE = TWOLEVEL RANDOM;
24 |
25 | MODEL:
26 |
27 | %WITHIN%
28 | rt;
29 | linear | rt ON time1;
30 |
31 | %BETWEEN%
32 | [rt linear] (int btime1);
33 | rt linear;
34 | rt WITH linear;
35 |
36 | MODEL CONSTRAINT:
37 | NEW(est1-est6);
38 | ! est1: Intercept at Session=1 Time=0
39 | est1 = int*1 + btime1*0;
40 | ! est2: Intercept at Session=2 Time=1
41 | est2 = int*1 + btime1*1;
42 | ! est3: Intercept at Session=3 Time=2
43 | est3 = int*1 + btime1*2;
44 | ! est4: Intercept at Session=4 Time=3
45 | est4 = int*1 + btime1*3;
46 | ! est5: Intercept at Session=5 Time=4
47 | est5 = int*1 + btime1*4;
48 | ! est6: Intercept at Session=6 Time=5
49 | est6 = int*1 + btime1*5;
50 |
--------------------------------------------------------------------------------
/Chapters/06/MPlus_Chpater6/3A R(I) R(S) F(Q).inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Ch 6: 3a: Fixed Quadratic, Random Linear Time Model
3 |
4 | DATA:
5 | FILE = MPLUS_Chapter6.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! Rescale rt so Mplus will show all results
10 | rt = rt/10;
11 | time1 = (session - 1)/100;
12 | time1sq = time1*time1/100;
13 |
14 | VARIABLE:
15 | NAMES = PersonID session rt;
16 | USEVARIABLES = rt time1 time1sq;
17 | MISSING = ALL (-9999);
18 | CLUSTER = PersonID;
19 | WITHIN = time1 time1sq;
20 |
21 | ANALYSIS:
22 | ESTIMATOR = ML;
23 | PROCESSORS = 4;
24 | TYPE = TWOLEVEL RANDOM;
25 |
26 | MODEL:
27 |
28 | %WITHIN%
29 | rt;
30 | linear | rt ON time1;
31 | quad | rt ON time1sq;
32 |
33 | %BETWEEN%
34 | [rt linear quad] (int btime1 btime1sq);
35 | rt linear quad@0;
36 | rt WITH linear;
37 |
38 | MODEL CONSTRAINT:
39 | NEW(est1-est12);
40 | ! est1: Intercept at Session=1 Time=0
41 | est1 = int*1 + btime1*0 + btime1sq*0;
42 | ! est2: Intercept at Session=2 Time=1
43 | est2 = int*1 + btime1*1 + btime1sq*1;
44 | ! est3: Intercept at Session=3 Time=2
45 | est3 = int*1 + btime1*2 + btime1sq*4;
46 | ! est4: Intercept at Session=4 Time=3
47 | est4 = int*1 + btime1*3 + btime1sq*9;
48 | ! est5: Intercept at Session=5 Time=4
49 | est5 = int*1 + btime1*4 + btime1sq*16;
50 | ! est6: Intercept at Session=6 Time=5
51 | est6 = int*1 + btime1*5 + btime1sq*25;
52 | ! est7: Linear Slope at Session=1 Time=0
53 | est7 = btime1*1 + btime1sq*0;
54 | ! est8: Linear Slope at Session=2 Time=1
55 | est8 = btime1*1 + btime1sq*2;
56 | ! est9: Linear Slope at Session=3 Time=2
57 | est9 = btime1*1 + btime1sq*4;
58 | ! est10: Linear Slope at Session=4 Time=3
59 | est10 = btime1*1 + btime1sq*6;
60 | ! est11: Linear Slope at Session=5 Time=4
61 | est11 = btime1*1 + btime1sq*8;
62 | ! est12: Linear Slope at Session=6 Time=5
63 | est12 = btime1*1 + btime1sq*10;
64 |
--------------------------------------------------------------------------------
/Chapters/06/SAS_Chapter6/SAS_Chapter6.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/06/SAS_Chapter6/SAS_Chapter6.sas7bdat
--------------------------------------------------------------------------------
/Chapters/07/CHAP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/CHAP.txt
--------------------------------------------------------------------------------
/Chapters/07/Chapter7a_LRTs_CIs_R2_Regions.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/Chapter7a_LRTs_CIs_R2_Regions.xlsx
--------------------------------------------------------------------------------
/Chapters/07/Chapter7b_LRTs_CIs_R2_Figure.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/Chapter7b_LRTs_CIs_R2_Figure.xlsx
--------------------------------------------------------------------------------
/Chapters/07/FRP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/FRP.txt
--------------------------------------------------------------------------------
/Chapters/07/SAS_Chapter7a/SAS_Chapter7a.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/SAS_Chapter7a/SAS_Chapter7a.sas7bdat
--------------------------------------------------------------------------------
/Chapters/07/SAS_Chapter7b/SAS_Chapter7b.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/07/SAS_Chapter7b/SAS_Chapter7b.sas7bdat
--------------------------------------------------------------------------------
/Chapters/08/CHAP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/08/CHAP.txt
--------------------------------------------------------------------------------
/Chapters/08/Chapter8_LRTs_CIs_R2_Figures.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/08/Chapter8_LRTs_CIs_R2_Figures.xlsx
--------------------------------------------------------------------------------
/Chapters/08/SAS_Chapter8/SAS_Chapter8.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/08/SAS_Chapter8/SAS_Chapter8.sas7bdat
--------------------------------------------------------------------------------
/Chapters/09/Chapter9_LRTs_CIs_R2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/09/Chapter9_LRTs_CIs_R2.xlsx
--------------------------------------------------------------------------------
/Chapters/09/FRP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/09/FRP.txt
--------------------------------------------------------------------------------
/Chapters/09/SAS_Chapter9/SAS_Chapter9.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/09/SAS_Chapter9/SAS_Chapter9.sas7bdat
--------------------------------------------------------------------------------
/Chapters/10/CHAP.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/CHAP.txt
--------------------------------------------------------------------------------
/Chapters/10/Chapter10a_LRTs_CIs_Figures.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/Chapter10a_LRTs_CIs_Figures.xlsx
--------------------------------------------------------------------------------
/Chapters/10/Chapter10b_LRTs_CIs_Figures.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/Chapter10b_LRTs_CIs_Figures.xlsx
--------------------------------------------------------------------------------
/Chapters/10/OCTO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/OCTO.txt
--------------------------------------------------------------------------------
/Chapters/10/SAS_Chapter10a/SAS_Chapter10a.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/SAS_Chapter10a/SAS_Chapter10a.sas7bdat
--------------------------------------------------------------------------------
/Chapters/10/SAS_Chapter10b/SAS_Chapter10b.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/10/SAS_Chapter10b/SAS_Chapter10b.sas7bdat
--------------------------------------------------------------------------------
/Chapters/11/CPE.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/11/CPE.txt
--------------------------------------------------------------------------------
/Chapters/11/Chapter11a_LRTs_CIs_R2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/11/Chapter11a_LRTs_CIs_R2.xlsx
--------------------------------------------------------------------------------
/Chapters/11/Chapter11b_LRTs_R2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/11/Chapter11b_LRTs_R2.xlsx
--------------------------------------------------------------------------------
/Chapters/11/SAS_Chapter11a/SAS_Chapter11a.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/11/SAS_Chapter11a/SAS_Chapter11a.sas7bdat
--------------------------------------------------------------------------------
/Chapters/11/SAS_Chapter11b/SAS_Chapter11b.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/11/SAS_Chapter11b/SAS_Chapter11b.sas7bdat
--------------------------------------------------------------------------------
/Chapters/12/Chapter12_LRTs_CIs_R2_Figure.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/12/Chapter12_LRTs_CIs_R2_Figure.xlsx
--------------------------------------------------------------------------------
/Chapters/12/SAS_Chapter12/SAS_Chapter12.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Chapters/12/SAS_Chapter12/SAS_Chapter12.sas7bdat
--------------------------------------------------------------------------------
/Data/Derived/ELSA/dsL_ELSA.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Data/Derived/ELSA/dsL_ELSA.rds
--------------------------------------------------------------------------------
/Data/Raw/ELSA/ds0_ELSA.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Data/Raw/ELSA/ds0_ELSA.rds
--------------------------------------------------------------------------------
/Data/Raw/ELSA/dsELSA.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Data/Raw/ELSA/dsELSA.rds
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/ELSA_report.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Reporting Statistical Models (demo)"
3 | author: "Psyc 564"
4 | date: "Friday, January 30, 2015"
5 | output:
6 | html_document:
7 | css: ~/GitHub/psy564/libs/css/sidebar.css
8 | highlight: haddock
9 | theme: spacelab
10 | toc: yes
11 | ---
12 |
13 |
14 | ```{r, echo=F, message=F}
15 | library(knitr)
16 | opts_knit$set(root.dir='../../../') #Don't combine this call with any other chunk -especially one that uses file paths.
17 | ```
18 |
19 |
20 | ```{r, echo=F, message=T}
21 | require(knitr)
22 | opts_chunk$set(
23 | results='show',
24 | message = TRUE,
25 | comment = NA,
26 | tidy = FALSE,
27 | # fig.height = 4.8,
28 | # fig.width = 6.5,
29 | out.width = NULL,
30 | fig.path = 'figure_rmd/',
31 | dev = "png",
32 | dpi = 70
33 | )
34 | echoChunks <- FALSE
35 | warningChunks<- FALSE
36 | messageChunks<- FALSE
37 | outwidthChunks <- "130%"
38 | options(width=120) #So the output is 50% wider than the default.
39 | read_chunk("./Projects/ELSA/CogDecline/dsELSA.R") # the file to which knitr calls for the chunks
40 | ```
41 |
42 | ## LoadPackages
43 | ```{r LoadPackages}
44 |
45 | ```
46 |
47 |
48 | ## Load data
49 | ```{r LoadData}
50 |
51 | ```
52 |
53 |
54 | ## DataFilter
55 | ```{r DataFilter}
56 |
57 | ```
58 |
59 |
60 | ## DataFilter2
61 | ```{r DataFilter2}
62 |
63 | ```
64 |
65 | ## DataExportLong
66 | ```{r DataExportLong, eval=F}
67 |
68 | ```
69 |
70 | ## DataExportWide
71 | ```{r DataExportWide, eval=F,echo=F}
72 |
73 | ```
74 | NOTE: the export of the wide data is suppressed for brevity
75 |
76 | ## LoadGraphThemes
77 | ```{r LoadGraphThemes}
78 |
79 | ```
80 |
81 | ## CrossSectionDist
82 | ```{r CrossSectionDist, out.width="900px"}
83 |
84 | ```
85 |
86 | ## CrossSectionCount
87 | ```{r CrossSectionCount, out.width="900px"}
88 |
89 | ```
90 |
91 | ## MakeAgeBins
92 | ```{r MakeAgeBins}
93 |
94 | ```
95 |
96 | ## EasyData
97 | ```{r EasyData}
98 |
99 | ```
100 |
101 | ## BasicLinePlot
102 | ```{r BasicLinePlot, warning=F,out.width="900px"}
103 |
104 | ```
105 |
106 | ## DefineModelData
107 | ```{r DefineModelData, warning=F}
108 |
109 | ```
110 |
111 | ## ProtoLines
112 | ```{r ProtoLines, warning=F}
113 |
114 | ```
115 |
116 | ## IndividualPredictionsAge
117 | ```{r IndividualPredictionsAge, warning=F, out.width="900px"}
118 |
119 | ```
120 |
121 |
122 |
123 | ## DefineModelData2
124 | ```{r DefineModelData2, warning=F}
125 |
126 | ```
127 |
128 | ## ProtoLines2
129 | ```{r ProtoLines2, warning=F}
130 |
131 | ```
132 |
133 | ## IndividualPredictionsAge2
134 | ```{r IndividualPredictionsAge2, warning=F}
135 |
136 | ```
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/dsL_ELSA_varNames.csv:
--------------------------------------------------------------------------------
1 | "","V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13","V14","V15","V16","V17","V18","V19","V20","V21","V22","V23","V24","V25","V26","V27","V28","V29","V30","V31","V32"
2 | "1","id","dob","sex","age","edu","ht","db","htdb","nocase","ang1A","chf1A","mi1A","stk1A","cogflg1A","evrsmk1A","htnw1A","dmw1A","time","irecall","animal","prospect","drecall","age80","edu11","hptn","dbts","condition","wave","year","Age","waveF","female"
3 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/dsW_ELSA_varNames.csv:
--------------------------------------------------------------------------------
1 | "","V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13","V14","V15","V16","V17","V18","V19","V20","V21","V22","V23","V24","V25","V26","V27","V28","V29","V30","V31","V32","V33","V34","V35","V36","V37","V38","V39","V40","V41","V42","V43","V44"
2 | "1","id","dob","sex","age","edu","ht","db","htdb","nocase","angina","stroke","smoked","time_1","time_2","time_3","time_4","wave_1","wave_2","wave_3","wave_4","year_1","year_2","year_3","year_4","ageCur_1","ageCur_2","ageCur_3","ageCur_4","irecall_1","irecall_2","irecall_3","irecall_4","drecall_1","drecall_2","drecall_3","drecall_4","animal_1","animal_2","animal_3","animal_4","prospect_1","prospect_2","prospect_3","prospect_4"
3 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/extract from mplus.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | cat("\014")
4 |
5 | ## @knitr LoadPackages
6 | require(sas7bdat) # for inputting data
7 | library(dplyr) # for general data manipulation
8 | library(reshape2) # for data : wide <-> long
9 | library(psych) # data summary + etc
10 | library(ggplot2) # graphing
11 | library(nlme) # estimate fixed models | esp. gls()
12 | library(lme4) # estimate mixed models | esp. lmer()
13 | library(arm) # process model objects
14 |
15 | # source("./Scripts/Mplus/mplus.R")
16 | source("http://www.statmodel.com/mplus-R/mplus.R")
17 | ls() # list the availible function in mplus.R
18 |
19 | m0 <- "./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_nocovar.gh5"
20 | m1 <- "./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80.gh5"
21 | m2 <- "./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5"
22 | m3 <- "./Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5"
23 |
24 |
25 | mplus.view.plots(m3)
26 | model <- m3
27 |
28 | mplus.list.variables(m3)
29 |
30 | mplus.plot.histogram(model, "OUTCOME")
31 | mplus.plot.histogram(model, "TIMEL")
32 | mplus.plot.histogram(model, "EVRSMK1A")
33 | mplus.plot.histogram(model, "EDU11")
34 | mplus.plot.histogram(model, "AGE80")
35 | mplus.plot.histogram(model, "LINEAR")
36 | mplus.plot.histogram(model, "B_OUTCOME")
37 |
38 | # extract raw data
39 | a <- mplus.get.data(m2,"OUTCOME")
40 | b <- mplus.get.data(m2,"TIMEL")
41 | c <- mplus.get.data(m2,"EDU11")
42 | d <- mplus.get.data(m2,"AGE80")
43 | e <- mplus.get.data(m2,"LINEAR")
44 | f <- mplus.get.data(m2,"B_OUTCOME")
45 | g <- mplus.get.data(m2,"ID")
46 |
47 | ds <- data.frame(cbind(a, b, c, d, e, f, g))
48 | names(ds) <- c("OUTCOME", "TIMEL","EDU11","AGE80","LINEAR","B_OUTCOME","ID")
49 |
50 | head(ds)
51 |
52 |
53 |
54 | ###### ########
55 | mplus.load(m1)
56 | mplus.plot.loop(m1, ypred)
57 |
58 | source("http://www.statmodel.com/mplus-R/mplus.R")
59 | ls() # list the availible function in mplus.R
60 |
61 | # create objects containing the paths to gh5 files
62 | model_basic <- './Projects/HRS/Various/HRS_BASIC.gh5'
63 | model_growth <- './Projects/HRS/Various/hrs_lgmgrowth.gh5'
64 |
65 | # choose what model to work with
66 | model <- model_basic
67 | model <- model_growth
68 |
69 |
70 | mplus.list.variables(model)
71 | mplus.plot.histogram(model,'CDWR1')
72 | mplus.plot.histogram(model,'I')
73 | mplus.plot.histogram(model,'S')
74 |
75 | mplus.plot.loop(model)
76 |
77 | mplus.plot.scatterplot('HRS_BASIC.gh5','CDWRSCR4','DAGEYRS4')
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/BasicLinePlot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/BasicLinePlot-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/CrossSectionCount-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/CrossSectionCount-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/CrossSectionDist-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/CrossSectionDist-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/IndividualPredictionsAge-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/IndividualPredictionsAge-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/IndividualPredictionsAge2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/IndividualPredictionsAge2-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/ProtoLines-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/ProtoLines-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/figure_rmd/ProtoLines2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/figure_rmd/ProtoLines2-1.png
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(I)_r(S)_(IS)Age80.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave - 1;
11 | ! choose the outcome
12 | outcome = irecall;
13 |
14 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
15 | VARIABLE:
16 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
17 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
18 | dbts condition wave year Age waveF female;
19 | USEVARIABLES = age80 outcome timeL ;
20 | MISSING = ALL (-9999);
21 | CLUSTER = id;
22 | WITHIN = timeL;
23 | BETWEEN = age80;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 |
38 | %BETWEEN%
39 | [outcome linear ] (int btimeL );
40 | outcome linear ;
41 | outcome WITH linear ;
42 | outcome linear ON age80 ;
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(I)_r(S)_(IS)Age80_(IS)Edu11.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave - 1;
11 | ! choose the outcome
12 | outcome = irecall;
13 |
14 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
15 | VARIABLE:
16 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
17 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
18 | dbts condition wave year Age waveF female;
19 | USEVARIABLES = edu11 age80 outcome timeL ;
20 | MISSING = ALL (-9999);
21 | CLUSTER = id;
22 | WITHIN = timeL;
23 | BETWEEN = edu11 age80;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 |
38 | %BETWEEN%
39 | [outcome linear ] (int btimeL );
40 | outcome linear ;
41 | outcome WITH linear ;
42 | outcome linear ON age80 ;
43 | outcome linear ON edu11 ;
44 |
45 | PLOT:
46 | type = plot1;
47 | type = plot2;
48 | type = plot3;
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(I)_r(S)_(IS)Age80_(IS)Edu11_(IS)Smoked.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave - 1;
11 | ! choose the outcome
12 | outcome = irecall;
13 |
14 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
15 | VARIABLE:
16 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
17 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
18 | dbts condition wave year Age waveF female;
19 | USEVARIABLES = evrsmk1A edu11 age80 outcome timeL ;
20 | MISSING = ALL (-9999);
21 | CLUSTER = id;
22 | WITHIN = timeL;
23 | BETWEEN = evrsmk1A edu11 age80;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 |
38 | %BETWEEN%
39 | [outcome linear ] (int btimeL );
40 | outcome linear ;
41 | outcome WITH linear ;
42 | outcome linear ON age80 ;
43 | outcome linear ON edu11 ;
44 | outcome linear ON evrsmk1A ;
45 |
46 | PLOT:
47 | type = plot1;
48 | type = plot2;
49 | type = plot3;
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(I)_r(S)_NoCovar.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave - 1;
11 | ! choose the outcome
12 | outcome = irecall;
13 |
14 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
15 | VARIABLE:
16 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
17 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
18 | dbts condition wave year Age waveF female;
19 | USEVARIABLES = outcome timeL ;
20 | MISSING = ALL (-9999);
21 | CLUSTER = id;
22 | WITHIN = timeL;
23 | ! BETWEEN = age80;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 |
38 | %BETWEEN%
39 | [outcome linear ] (int btimeL );
40 | outcome linear ;
41 | outcome WITH linear ;
42 |
43 | OUTPUT: TECH1 TECH8;
44 | !PLOT:
45 | ! TYPE = plot2;
46 | ! SERIES = outcome(*) ;
47 |
48 | !MODEL CONSTRAINT:
49 | ! PLOT (ypred);
50 | ! LOOP (age80,-10,10,1) :
51 | ! ypred = btimeL*age80;
52 |
53 | !SAVEDATA: FSCORES ;
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80.gh5
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11.gh5
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_(is)age80_(is)edu11_(is)smoked.gh5
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_nocovar.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/ELSA/CogDecline/irecall/irecall_r(i)_r(s)_nocovar.gh5
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/results.dat:
--------------------------------------------------------------------------------
1 | 0.15629333E+01 -0.19000806E-01 0.58720625E+01 0.92817729E-02 0.52573595E-01 0.90631180E+00
2 | 0.21012824E-01 0.76298482E-02 0.24247442E-01 0.74243829E-02 0.19889780E-01 0.69388549E-01
3 | -0.40299902E+05 0.60000000E+01 0.80611803E+05 0.80659828E+05 0.80640760E+05
4 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_0r_1f_2x_x.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | ! timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = outcome timeL;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL ;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome on timeL;
37 |
38 |
39 | %BETWEEN%
40 | [outcome linear] (int btimeL);
41 | outcome linear@0;
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_f2_x.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 | quad | outcome ON timeQ;
38 |
39 |
40 | %BETWEEN%
41 | [outcome linear quad] (int btimeL btimeQ);
42 | outcome linear quad@0;
43 | outcome WITH linear;
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_012age80.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = age80 outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 | BETWEEN = age80;
25 |
26 |
27 |
28 | ANALYSIS:
29 | ESTIMATOR = ML;
30 | PROCESSORS = 4;
31 | TYPE = TWOLEVEL RANDOM;
32 |
33 | MODEL:
34 |
35 | %WITHIN%
36 | outcome;
37 | linear | outcome ON timeL;
38 | quad | outcome ON timeQ;
39 |
40 |
41 | %BETWEEN%
42 | [outcome linear quad] (int btimeL btimeQ);
43 | outcome linear quad;
44 | outcome linear quad WITH outcome linear quad;
45 | outcome linear quad ON age80 (bage80I bage80S bage80Q);
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_012age80_0edu11.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = age80 edu11 outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 | BETWEEN = age80 edu11;
25 |
26 |
27 |
28 | ANALYSIS:
29 | ESTIMATOR = ML;
30 | PROCESSORS = 4;
31 | TYPE = TWOLEVEL RANDOM;
32 |
33 | MODEL:
34 |
35 | %WITHIN%
36 | outcome;
37 | linear | outcome ON timeL;
38 | quad | outcome ON timeQ;
39 |
40 | %BETWEEN%
41 | [outcome linear quad] (int btimeL btimeQ);
42 | outcome linear quad;
43 | outcome linear quad WITH outcome linear quad;
44 | outcome linear quad ON age80 (bage80I bage80S bage80Q);
45 | outcome linear ON edu11 (bedu11I);
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_01age80.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = age80 outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 | BETWEEN = age80;
25 |
26 |
27 |
28 | ANALYSIS:
29 | ESTIMATOR = ML;
30 | PROCESSORS = 4;
31 | TYPE = TWOLEVEL RANDOM;
32 |
33 | MODEL:
34 |
35 | %WITHIN%
36 | outcome;
37 | linear | outcome ON timeL;
38 | quad | outcome ON timeQ;
39 |
40 |
41 | %BETWEEN%
42 | [outcome linear quad] (int btimeL btimeQ);
43 | outcome linear quad;
44 | outcome linear quad WITH outcome linear quad;
45 | outcome linear ON age80 (bage80in bage80lin);
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_0age80.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = age80 outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 | BETWEEN = age80;
25 |
26 |
27 |
28 | ANALYSIS:
29 | ESTIMATOR = ML;
30 | PROCESSORS = 4;
31 | TYPE = TWOLEVEL RANDOM;
32 |
33 | MODEL:
34 |
35 | %WITHIN%
36 | outcome;
37 | linear | outcome ON timeL;
38 | quad | outcome ON timeQ;
39 |
40 |
41 | %BETWEEN%
42 | [outcome linear quad] (int btimeL btimeQ);
43 | outcome linear quad;
44 | outcome linear quad WITH outcome linear quad;
45 | outcome ON age80 (bage80);
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_age012.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | linear = wave;
10 | quad = wave*wave;
11 | y = irecall;
12 |
13 |
14 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
15 | VARIABLE:
16 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
17 | evrsmk1A htnw1A dmw1A time irecall animal prospect drecall age80 edu11 hptn
18 | dbts condition wave year Age waveF female;
19 | USEVARIABLES = id age80 y linear quad;
20 | MISSING = ALL (NA);
21 | CLUSTER = id;
22 | WITHIN = linear quad;
23 |
24 | ANALYSIS:
25 | ESTIMATOR = ML;
26 | PROCESSORS = 4;
27 | TYPE = TWOLEVEL RANDOM;
28 |
29 | MODEL:
30 |
31 | %WITHIN%
32 | y;
33 | linear | y ON age80;
34 | quad | y ON age80;
35 |
36 | %BETWEEN%
37 | [y linear quad] (int bagec18 bagesq);
38 | y linear quad;
39 | y linear quad WITH y linear quad;
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_age012.out:
--------------------------------------------------------------------------------
1 | Mplus VERSION 7.3
2 | MUTHEN & MUTHEN
3 | 03/06/2015 10:10 AM
4 |
5 | INPUT INSTRUCTIONS
6 |
7 | TITLE:
8 | Modeling Cognitive Decline in ELSA study: irecall
9 |
10 | DATA:
11 | FILE = dsL_ELSA.csv;
12 | FORMAT = FREE;
13 |
14 | DEFINE:
15 | linear = wave;
16 | quad = wave*wave;
17 | y = irecall;
18 |
19 |
20 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
21 | VARIABLE:
22 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
23 | evrsmk1A htnw1A dmw1A time irecall animal prospect drecall age80 edu11 hptn
24 | dbts condition wave year Age waveF female;
25 | USEVARIABLES = id age80 y linear quad;
26 | MISSING = ALL (NA);
27 | CLUSTER = id;
28 | WITHIN = linear quad;
29 |
30 | ANALYSIS:
31 | ESTIMATOR = ML;
32 | PROCESSORS = 4;
33 | TYPE = TWOLEVEL RANDOM;
34 |
35 | MODEL:
36 |
37 | %WITHIN%
38 | y;
39 | linear | y ON age80;
40 | quad | y ON age80;
41 |
42 | %BETWEEN%
43 | [y linear quad] (int bagec18 bagesq);
44 | y linear quad;
45 | y linear quad WITH y linear quad;
46 |
47 |
48 |
49 | *** ERROR
50 | Invalid missing value: NA
51 |
52 |
53 | MUTHEN & MUTHEN
54 | 3463 Stoner Ave.
55 | Los Angeles, CA 90066
56 |
57 | Tel: (310) 391-9971
58 | Fax: (310) 391-8971
59 | Web: www.StatModel.com
60 | Support: Support@StatModel.com
61 |
62 | Copyright (c) 1998-2014 Muthen & Muthen
63 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_r2_x.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = outcome timeL timeQ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL timeQ;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome ON timeL;
37 | quad | outcome ON timeQ;
38 |
39 |
40 | %BETWEEN%
41 | [outcome linear quad] (int btimeL btimeQ);
42 | outcome linear quad;
43 | outcome linear quad WITH outcome linear quad;
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_r1_x2_x.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | timeL = wave;
11 | ! timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = outcome timeL;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | WITHIN = timeL ;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 | linear | outcome on timeL;
37 |
38 |
39 | %BETWEEN%
40 | [outcome linear] (int btimeL);
41 | outcome linear;
42 | outcome WITH linear;
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Projects/ELSA/CogDecline/irecall/retired/irecall_r0_x1_x2_x.inp:
--------------------------------------------------------------------------------
1 | TITLE:
2 | Modeling Cognitive Decline in ELSA study: irecall
3 |
4 | DATA:
5 | FILE = dsL_ELSA.csv;
6 | FORMAT = FREE;
7 |
8 | DEFINE:
9 | ! choose the metric of time
10 | ! timeL = wave;
11 | ! timeQ = wave*wave;
12 | ! choose the outcome
13 | outcome = irecall;
14 |
15 | !123456789!123456789!123456789!123456789!123456789!123456789!123456789!123456789!
16 | VARIABLE:
17 | NAMES = id dob sex age1B edu ht db htdb nocase ang1A chf1A mi1A stk1A cogflg1A
18 | evrsmk1A htnw1A dmw1A timeToIn irecall animal prospect drecall age80 edu11 hptn
19 | dbts condition wave year Age waveF female;
20 | USEVARIABLES = id outcome ;
21 | MISSING = ALL (-9999);
22 | CLUSTER = id;
23 | ! WITHIN = timeL ;
24 |
25 |
26 |
27 | ANALYSIS:
28 | ESTIMATOR = ML;
29 | PROCESSORS = 4;
30 | TYPE = TWOLEVEL RANDOM;
31 |
32 | MODEL:
33 |
34 | %WITHIN%
35 | outcome;
36 |
37 |
38 | %BETWEEN%
39 | [outcome] ;
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Projects/HRS/HRS.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/HRS.zip
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_BASIC.inp:
--------------------------------------------------------------------------------
1 | Title: HRS_WIDE_BASIC;
2 | Data:
3 | File is HRS_WIDE_n2000.dat ;
4 | Variable:
5 | Names are
6 | secu idstrat idstudy idcohort
7 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
8 |
9 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
10 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
11 | dsex dedudgr deduyrs
12 | dracehsp dracecnt dracewht draceblk draceoth
13 |
14 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
15 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
16 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
17 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
18 |
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 |
25 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
26 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
27 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
28 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
29 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
30 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
31 |
32 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
33 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
34 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
35 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
36 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
37 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
38 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
39 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
40 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
41 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
42 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
43 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
44 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
45 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
46 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
47 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
48 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
49 |
50 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
51 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
52 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
53 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
54 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
55 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
56 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
57 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
58 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
59 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
60 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
61 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
62 |
63 | t1_age t2_age t3_age t4_age t5_age
64 | t1_time t2_time t3_time t4_time t5_time
65 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
66 |
67 | pn hhid hhidpn;
68 |
69 | MISSING are all (-9999) ;
70 |
71 | USEVAR are cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
72 | dageyrs4 female;
73 |
74 | DEFINE: female=dsex-1;
75 |
76 | Output: SAMPSTAT PATTERNS;
77 |
78 | PLOT:
79 | Type is Plot2 Plot3;
80 | Series is cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8(*);
81 |
82 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_General Information.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/Various/HRS_General Information.docx
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_General_VariableList.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/Various/HRS_General_VariableList.xlsx
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_LGMGROWTH.inp:
--------------------------------------------------------------------------------
1 | Title: HRS_SEMGROWTH
2 | Data:
3 | File is HRS_WIDE_n2000.dat ;
4 | Variable:
5 | Names are
6 | secu idstrat idstudy idcohort
7 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
8 |
9 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
10 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
11 | dsex dedudgr deduyrs
12 | dracehsp dracecnt dracewht draceblk draceoth
13 |
14 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
15 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
16 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
17 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
18 |
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 |
25 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
26 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
27 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
28 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
29 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
30 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
31 |
32 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
33 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
34 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
35 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
36 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
37 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
38 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
39 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
40 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
41 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
42 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
43 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
44 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
45 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
46 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
47 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
48 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
49 |
50 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
51 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
52 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
53 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
54 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
55 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
56 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
57 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
58 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
59 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
60 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
61 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
62 |
63 | t1age t2age t3age t4age t5age
64 | t1 t2 t3 t4 t5
65 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
66 |
67 | pn hhid hhidpn;
68 |
69 | Missing are all (-9999) ;
70 | Missing are all (-999) ;
71 |
72 | USEVAR are t1 t2 t3 t4 t5
73 | CDWR1 CDWR2 CDWR3 CDWR4 CDWR5 ;! age65 female agefem;
74 |
75 | TSCORES = t1 t2 t3 t4 t5;
76 |
77 | Define: age65=dagecnt4; female=dsex-1; agefem=age65*female;
78 | CDWR1=cdwrscr4; CDWR2=cdwrscr5; CDWR3=cdwrscr6; CDWR4=cdwrscr7; CDWR5=cdwrscr8;
79 |
80 | Analysis:
81 | Type = RANDOM;
82 |
83 | Model: I S | cdwr1-cdwr5 AT t1-t5;
84 |
85 | CDWR1(2);
86 | CDWR2(2);
87 | CDWR3(2);
88 | CDWR4(2);
89 | CDWR5(2);
90 |
91 | PLOT:
92 | Type is Plot1 Plot2 Plot3;
93 | Series is CDWR1-CDWR5(*);
94 |
95 |
96 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_LGMGROWTH_ExampWriteup.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/Various/HRS_LGMGROWTH_ExampWriteup.docx
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_LGMGROWTH_age.inp:
--------------------------------------------------------------------------------
1 | Title: HRS_SEMGROWTH
2 | Data:
3 | File is HRS_WIDE_n2000.dat ;
4 | Variable:
5 | Names are
6 | secu idstrat idstudy idcohort
7 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
8 |
9 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
10 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
11 | dsex dedudgr deduyrs
12 | dracehsp dracecnt dracewht draceblk draceoth
13 |
14 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
15 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
16 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
17 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
18 |
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 |
25 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
26 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
27 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
28 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
29 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
30 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
31 |
32 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
33 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
34 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
35 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
36 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
37 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
38 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
39 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
40 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
41 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
42 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
43 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
44 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
45 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
46 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
47 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
48 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
49 |
50 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
51 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
52 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
53 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
54 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
55 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
56 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
57 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
58 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
59 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
60 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
61 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
62 |
63 | t1age t2age t3age t4age t5age
64 | t1 t2 t3 t4 t5
65 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
66 |
67 | pn hhid hhidpn;
68 |
69 | Missing are all (-9999) ;
70 |
71 | USEVAR are dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
72 | CDWR1 CDWR2 CDWR3 CDWR4 CDWR5 age65; ! female agefem;
73 |
74 | TSCORES = dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8 ;
75 |
76 | Define: age65=dagecnt4; female=dsex-1; agefem=age65*female;
77 | CDWR1=cdwrscr4; CDWR2=cdwrscr5; CDWR3=cdwrscr6; CDWR4=cdwrscr7; CDWR5=cdwrscr8;
78 |
79 | Analysis:
80 | Type = RANDOM;
81 |
82 | Model: I S | cdwr1-cdwr5 AT dagecnt4-dagecnt8 ;
83 |
84 | CDWR1(2);
85 | CDWR2(2);
86 | CDWR3(2);
87 | CDWR4(2);
88 | CDWR5(2);
89 |
90 | I ON age65;
91 | S ON age65;
92 |
93 | Output:
94 |
95 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_LGMGROWTH_piecewise.inp:
--------------------------------------------------------------------------------
1 | Title: HRS_SEMGROWTH
2 | Data:
3 | File is HRS_WIDE_n2000.dat ;
4 | Variable:
5 | Names are
6 | secu idstrat idstudy idcohort
7 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
8 |
9 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
10 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
11 | dsex dedudgr deduyrs
12 | dracehsp dracecnt dracewht draceblk draceoth
13 |
14 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
15 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
16 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
17 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
18 |
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 |
25 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
26 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
27 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
28 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
29 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
30 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
31 |
32 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
33 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
34 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
35 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
36 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
37 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
38 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
39 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
40 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
41 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
42 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
43 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
44 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
45 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
46 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
47 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
48 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
49 |
50 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
51 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
52 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
53 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
54 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
55 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
56 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
57 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
58 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
59 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
60 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
61 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
62 |
63 | t1age t2age t3age t4age t5age
64 | t1 t2 t3 t4 t5
65 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
66 |
67 | pn hhid hhidpn;
68 |
69 | Missing are all (-9999) ;
70 |
71 | USEVAR are CDWR1 CDWR2 CDWR3 CDWR4 CDWR5 age65; ! female agefem;
72 |
73 | Define: age65=dagecnt4; female=dsex-1; agefem=age65*female;
74 | CDWR1=cdwrscr4; CDWR2=cdwrscr5; CDWR3=cdwrscr6; CDWR4=cdwrscr7; CDWR5=cdwrscr8;
75 |
76 | Analysis:
77 | Type = RANDOM;
78 |
79 | Model:
80 |
81 | ! I S1 | cdwr1@0 cdwr2@2 cdwr3@2 cdwr4@2 cdwr5@2; !S1 and S2;
82 | ! I S2 | cdwr1@0 cdwr2@0 cdwr3@2 cdwr4@4 cdwr5@6;
83 |
84 | I S1 | cdwr1@0 cdwr2@2 cdwr3@4 cdwr4@6 cdwr5@8; !Slope & Deviation Slope;
85 | I S2 | cdwr1@0 cdwr2@0 cdwr3@2 cdwr4@4 cdwr5@6;
86 |
87 | CDWR1(2);
88 | CDWR2(2);
89 | CDWR3(2);
90 | CDWR4(2);
91 | CDWR5(2);
92 |
93 | I ON age65;
94 | S1 ON age65;
95 | S2 ON age65;
96 |
97 | Output:
98 |
99 |
100 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/HRS_LGMGROWTH_timestudy.inp:
--------------------------------------------------------------------------------
1 | Title: HRS_SEMGROWTH
2 | Data:
3 | File is HRS_WIDE_n2000.dat ;
4 | Variable:
5 | Names are
6 | secu idstrat idstudy idcohort
7 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
8 |
9 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
10 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
11 | dsex dedudgr deduyrs
12 | dracehsp dracecnt dracewht draceblk draceoth
13 |
14 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
15 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
16 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
17 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
18 |
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 |
25 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
26 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
27 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
28 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
29 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
30 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
31 |
32 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
33 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
34 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
35 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
36 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
37 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
38 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
39 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
40 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
41 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
42 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
43 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
44 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
45 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
46 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
47 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
48 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
49 |
50 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
51 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
52 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
53 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
54 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
55 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
56 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
57 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
58 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
59 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
60 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
61 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
62 |
63 | t1age t2age t3age t4age t5age
64 | t1 t2 t3 t4 t5
65 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
66 |
67 | pn hhid hhidpn;
68 |
69 | Missing are all (-9999) ;
70 |
71 | USEVAR are t1 t2 t3 t4 t5
72 | CDWR1 CDWR2 CDWR3 CDWR4 CDWR5 age65; ! female agefem;
73 |
74 | TSCORES = t1 t2 t3 t4 t5;
75 |
76 | Define: age65=dagecnt4; female=dsex-1; agefem=age65*female;
77 | CDWR1=cdwrscr4; CDWR2=cdwrscr5; CDWR3=cdwrscr6; CDWR4=cdwrscr7; CDWR5=cdwrscr8;
78 |
79 | Analysis:
80 | Type = RANDOM;
81 |
82 | Model: I S | cdwr1-cdwr5 AT t1-t5;
83 |
84 | CDWR1(2);
85 | CDWR2(2);
86 | CDWR3(2);
87 | CDWR4(2);
88 | CDWR5(2);
89 |
90 | I ON age65;
91 | S ON age65;
92 |
93 | Output:
94 |
95 |
96 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/dsHRS.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 | cat("\014")
4 |
5 |
6 | ## @knitr InstallPackage
7 | # source("./Scripts/Utility/InstallPackages.R")
8 |
9 |
10 |
11 | ## @knitr LoadPackages
12 | require(sas7bdat) # for inputting data
13 | library(dplyr) # for general data manipulation
14 | # library(reshape2) # for data : wide <-> long
15 | # library(psych) # data summary + etc
16 | library(ggplot2) # graphing
17 | # library(nlme) # estimate fixed models | esp. gls()
18 | # library(lme4) # estimate mixed models | esp. lmer()
19 | # library(arm) # process model objects
20 |
21 |
22 | ## @knitr LoadData
23 | ds0 <- read.csv("~/GitHub/psy564/Data/Raw/HRS/HRS_WIDE_n2000.dat", header=F)
24 | dim(ds0)
25 |
26 | # namesare <- read.table("./Projects/HRS/HRS/namesare.txt", sep=" ")
27 | namesarePath <- "./Projects/HRS/Various/namesare.txt"
28 | namesare <- scan (namesarePath, what="character", sep=" ")
29 | names(ds0) <- namesare
30 |
31 | selectVars <- c()
--------------------------------------------------------------------------------
/Projects/HRS/Various/hrs_basic.dgm:
--------------------------------------------------------------------------------
1 | VERSION 1.1.0
2 | INPUT
3 | TITLE:
4 | HRS_WIDE_BASIC;
5 | DATA:
6 | File is HRS_WIDE_n2000.dat ;
7 | VARIABLE:
8 | Names are
9 | secu idstrat idstudy idcohort
10 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
11 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
12 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
13 | dsex dedudgr deduyrs
14 | dracehsp dracecnt dracewht draceblk draceoth
15 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
16 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
17 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
18 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
25 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
26 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
27 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
28 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
29 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
30 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
31 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
32 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
33 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
34 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
35 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
36 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
37 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
38 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
39 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
40 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
41 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
42 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
43 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
44 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
45 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
46 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
47 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
48 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
49 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
50 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
51 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
52 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
53 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
54 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
55 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
56 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
57 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
58 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
59 | t1_age t2_age t3_age t4_age t5_age
60 | t1_time t2_time t3_time t4_time t5_time
61 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
62 | pn hhid hhidpn;
63 | MISSING are all (-9999) ;
64 | USEVAR are cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
65 | dageyrs4 female;
66 | DEFINE:
67 | female=dsex-1;
68 | OUTPUT:
69 | SAMPSTAT PATTERNS;
70 | PLOT:
71 | Type is Plot2 Plot3;
72 | Series is cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8(*);
73 | INPUT_END
74 | 2
75 | 0
76 | 0
77 | 0
78 | ML
79 | 1
80 | GENERAL
81 | 0
82 | 7
83 | 0
84 | 0
85 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8 dageyrs4 female
86 | 1
87 | 0 0 0 0 0 0 0
88 | 0
89 | 0
90 | 5 1 cdwrscr4 5.060 0.200
91 | 5 1 cdwrscr5 4.526 0.189
92 | 5 1 cdwrscr6 4.784 0.211
93 | 5 1 cdwrscr7 3.912 0.162
94 | 5 1 cdwrscr8 4.320 0.185
95 | 5 1 dageyrs4 122.295 4.599
96 | 5 1 female 0.247 0.008
97 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/hrs_basic.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/Various/hrs_basic.gh5
--------------------------------------------------------------------------------
/Projects/HRS/Various/hrs_lgmgrowth.dgm:
--------------------------------------------------------------------------------
1 | VERSION 1.1.0
2 | INPUT
3 | TITLE:
4 | HRS_SEMGROWTH
5 | DATA:
6 | File is HRS_WIDE_n2000.dat ;
7 | VARIABLE:
8 | Names are
9 | secu idstrat idstudy idcohort
10 | wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos
11 | ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint
12 | dintmth4 dintmth5 dintmth6 dintmth7 dintmth8
13 | dsex dedudgr deduyrs
14 | dracehsp dracecnt dracewht draceblk draceoth
15 | dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8
16 | dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8
17 | dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8
18 | dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8
19 | dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8
20 | dmarint4 dmarint5 dmarint6 dmarint7 dmarint8
21 | ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8
22 | eincind4 einchh4 eincind5 einchh5 eincind6 einchh6
23 | eincind7 einchh7 eincind8 einchh8
24 | bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8
25 | bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8
26 | bsmknow4 bsmknow5 bsmknow6 bsmknow7 bsmknow8
27 | balcevr4 balcevr5 balcevr6 balcevr7 balcevr8
28 | balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8
29 | balcddy4 balcddy5 balcddy6 balcddy7 balcddy8
30 | hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8
31 | hbmi4 hbmi5 hbmi6 hbmi7 hbmi8
32 | hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8
33 | hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8
34 | hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8
35 | hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8
36 | hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8
37 | hcandia4 hcandia5 hcandia6 hcandia7 hcandia8
38 | hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8
39 | hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8
40 | hartdia4 hartdia5 hartdia6 hartdia7 hartdia8
41 | hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8
42 | hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8
43 | hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8
44 | hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8
45 | hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8
46 | hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8
47 | pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8
48 | csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8
49 | cticlow4 cticlow5 cticlow6 cticlow7 cticlow8
50 | ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8
51 | ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8
52 | cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8
53 | ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8
54 | cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8
55 | cssstd4 cssstd5 cssstd6 cssstd7 cssstd8
56 | cssscr4 cssscr5 cssscr6 cssscr7 cssscr8
57 | cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8
58 | cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8
59 | t1age t2age t3age t4age t5age
60 | t1 t2 t3 t4 t5
61 | t1_time2 t2_time2 t3_time2 t4_time2 t5_time2
62 | pn hhid hhidpn;
63 | Missing are all (-9999) ;
64 | Missing are all (-999) ;
65 | USEVAR are t1 t2 t3 t4 t5
66 | CDWR1 CDWR2 CDWR3 CDWR4 CDWR5 ;
67 | TSCORES = t1 t2 t3 t4 t5;
68 | DEFINE:
69 | age65=dagecnt4; female=dsex-1; agefem=age65*female;
70 | CDWR1=cdwrscr4; CDWR2=cdwrscr5; CDWR3=cdwrscr6; CDWR4=cdwrscr7; CDWR5=cdwrscr8;
71 | ANALYSIS:
72 | Type = RANDOM;
73 | PLOT:
74 | Type is Plot1 Plot2 Plot3;
75 | Series is CDWR1-CDWR5(*);
76 | MODEL:
77 | I S | cdwr1-cdwr5 AT t1-t5;
78 | CDWR1(2);
79 | CDWR2(2);
80 | CDWR3(2);
81 | CDWR4(2);
82 | CDWR5(2);
83 | INPUT_END
84 | 2
85 | 0
86 | 0
87 | 0
88 | MLR
89 | 1
90 | GENERAL
91 | 0
92 | 5
93 | 2
94 | 0
95 | cdwr1 cdwr2 cdwr3 cdwr4 cdwr5 i s
96 | 2
97 | 1 1 1 1 1 0 0
98 | 0
99 | 0
100 | 6 1 i cdwr1 1
101 | 6 1 s cdwr1 t1
102 | 6 1 i cdwr2 1
103 | 6 1 s cdwr2 t2
104 | 6 1 i cdwr3 1
105 | 6 1 s cdwr3 t3
106 | 6 1 i cdwr4 1
107 | 6 1 s cdwr4 t4
108 | 6 1 i cdwr5 1
109 | 6 1 s cdwr5 t5
110 | 2 1 s i -0.048 0.021
111 | 4 1 cdwr1 2.126 0.084
112 | 4 1 cdwr2 2.126 0.084
113 | 4 1 cdwr3 2.126 0.084
114 | 4 1 cdwr4 2.126 0.084
115 | 4 1 cdwr5 2.126 0.084
116 | 5 1 i 2.733 0.170
117 | 5 1 s 0.012 0.004
118 |
--------------------------------------------------------------------------------
/Projects/HRS/Various/hrs_lgmgrowth.gh5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/HRS/Various/hrs_lgmgrowth.gh5
--------------------------------------------------------------------------------
/Projects/HRS/Various/namesare.txt:
--------------------------------------------------------------------------------
1 | secu idstrat idstudy idcohort wgtr4 wgtr5 wgtr6 wgtr7 wgtr8 wgtrbase wgt_pos ddobmth ddobyr dndimtch dndimth dndiyr ddodyrs ddthflg dfrstint dintmth4 dintmth5 dintmth6 dintmth7 dintmth8 dsex dedudgr deduyrs dracehsp dracecnt dracewht draceblk draceoth dageyrs4 dageyrs5 dageyrs6 dageyrs7 dageyrs8 dagecnt4 dagecnt5 dagecnt6 dagecnt7 dagecnt8 dagesqr4 dagesqr5 dagesqr6 dagesqr7 dagesqr8 dagec2_4 dagec2_5 dagec2_6 dagec2_7 dagec2_8 dhhsize4 dhhsize5 dhhsize6 dhhsize7 dhhsize8 dmarint4 dmarint5 dmarint6 dmarint7 dmarint8 ewthfin4 ewthfin5 ewthfin6 ewthfin7 ewthfin8 eincind4 einchh4 eincind5 einchh5 eincind6 einchh6 eincind7 einchh7 eincind8 einchh8 bexcfrq4 bexcfrq5 bexcfrq6 bexcfrq7 bexcfrq8 bsmkevr4 bsmkevr5 bsmkevr6 bsmkevr7 bsmkevr8 bsmknow4 bsmknow5 smknow6 bsmknow7 bsmknow8 balcevr4 balcevr5 balcevr6 balcevr7 balcevr8 balcdwk4 balcdwk5 balcdwk6 balcdwk7 balcdwk8 balcddy4 balcddy5 balcddy6 balcddy7 balcddy8 hvtlsts4 hvtlsts5 hvtlsts6 hvtlsts7 hvtlsts8 hbmi4 hbmi5 hbmi6 hbmi7 hbmi8 hsrhscr4 hsrhscr5 hsrhscr6 hsrhscr7 hsrhscr8 hbrkhip4 hbrkhip5 hbrkhip6 hbrkhip7 hbrkhip8 hbcksym4 hbcksym5 hbcksym6 hbcksym7 hbcksym8 hhbpdia4 hhbpdia5 hhbpdia6 hhbpdia7 hhbpdia8 hdibdia4 hdibdia5 hdibdia6 hdibdia7 hdibdia8 hcandia4 hcandia5 hcandia6 hcandia7 hcandia8 hlngdia4 hlngdia5 hlngdia6 hlngdia7 hlngdia8 hpsydia4 hpsydia5 hpsydia6 hpsydia7 hpsydia8 hartdia4 hartdia5 hartdia6 hartdia7 hartdia8 hstkdia4 hstkdia5 hstkdia6 hstkdia7 hstkdia8 hhrtdia4 hhrtdia5 hhrtdia6 hhrtdia7 hhrtdia8 hiad3pt4 hiad3pt5 hiad3pt6 hiad3pt7 hiad3pt8 hiad5pt4 hiad5pt5 hiad5pt6 hiad5pt7 hiad5pt8 hadl3pt4 hadl3pt5 hadl3pt6 hadl3pt7 hadl3pt8 hadl5pt4 hadl5pt5 hadl5pt6 hadl5pt7 hadl5pt8 pcsdsum4 pcsdsum5 pcsdsum6 pcsdsum7 pcsdsum8 csrmscr4 csrmscr5 csrmscr6 csrmscr7 csrmscr8 cticlow4 cticlow5 cticlow6 cticlow7 cticlow8 ctic9pt4 ctic9pt5 ctic9pt6 ctic9pt7 ctic9pt8 ciwrstd4 ciwrstd5 ciwrstd6 ciwrstd7 ciwrstd8 cdwrstd4 cdwrstd5 cdwrstd6 cdwrstd7 cdwrstd8 ciwrscr4 ciwrscr5 ciwrscr6 ciwrscr7 ciwrscr8 cdwrscr4 cdwrscr5 cdwrscr6 cdwrscr7 cdwrscr8 cssstd4 cssstd5 cssstd6 cssstd7 cssstd8 cssscr4 cssscr5 cssscr6 cssscr7 cssscr8 cvcbstd4 cvcbstd5 cvcbstd6 cvcbstd7 cvcbstd8 cvcbscr4 cvcbscr5 cvcbscr6 cvcbscr7 cvcbscr8 t1_age t2_age t3_age t4_age t5_age t1_time t2_time t3_time t4_time t5_time t1_time2 t2_time2 t3_time2 t4_time2 t5_time2 pn hhid hhidpn
--------------------------------------------------------------------------------
/Projects/LMG_Mplus_primer.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andkov/psy564/204e0a747ad2c05642a591844b45397df4e8c946/Projects/LMG_Mplus_primer.pdf
--------------------------------------------------------------------------------
/Projects/README.md:
--------------------------------------------------------------------------------
1 | Integrating Mplus and R
2 | ----
3 |
4 | ## Plotting using GH5 files
5 |
6 | The official jumping board into plotting GH5 is at [www.statmodel.com/mplus-R](http://www.statmodel.com/mplus-R/)
7 |
8 | Plots can be created in R using the GH5 files generated by Mplus and containing plot information. See [description of GH5 files](http://statmodel2.com/mplus-R/GH5_R.shtml).
9 |
10 | Functions that extract the needed information are stored in a separate script [mplus.R](http://www.statmodel.com/mplus-R/mplus.R)
11 |
12 | [Tutorial on how to work with mplus.R](http://www.statmodel.com/mplus-R/Mplus%20R%20tutorial.pdf) created by Muthen & Muthen.
13 |
14 | The R package that works with HDF5 (data format in which GH5 are stored) is [rhdf5](http://www.bioconductor.org/packages/release/bioc/vignettes/rhdf5/inst/doc/rhdf5.pdf)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Longitudinal Modeling
2 | ============
3 | Scripts and libraries to accompany a graduate course on longitudinal modeling (PSY-564) taught at the University of Victoria in the spring of 2015 by Scott Hofer and Andriy Koval.
4 |
--------------------------------------------------------------------------------
/Scripts/Data/LabelingFactorLevels.R:
--------------------------------------------------------------------------------
1 | # The following script declares the factor labels to be used with **dsL**
2 | #
3 | ###########################################################################
4 |
5 | #### SCALES ####
6 |
7 | ## sex ###################################################################
8 | sexLevels<- c(1,2,0)
9 | sexLabels<- c("Male","Female","No Information")
10 |
11 | varlist<-c("sex")
12 | for(i in varlist){
13 | dsF[,paste0(i,"F")]<-ordered(dsF[,i],
14 | levels = sexLevels,
15 | labels = sexLabels)
16 | }
17 | ## race ##################################################################
18 | raceLevels<- c(1,2,3,4)
19 | raceLabels<- c("Black","Hispanic","Mixed (Non-H)","Non-B/Non-H")
20 |
21 | varlist<-c("race")
22 | for(i in varlist){
23 | dsF[,paste0(i,"F")]<-ordered(dsF[,i],
24 | levels = raceLevels,
25 | labels = raceLabels)
26 | }
27 | ## birth month ###########################################################
28 | bmonthLevels<- c(1:12)
29 | bmonthLabels<- c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
30 |
31 | varlist<-c("bmonth")
32 | for(i in varlist){
33 | dsF[,paste0(i,"F")]<-ordered(dsF[,i],
34 | levels = bmonthLevels,
35 | labels = bmonthLabels)
36 | }
37 |
38 | ## church attendance #####################################################
39 | attendLevels<- c(1:8)
40 | attendLabelsShort<-c("Never",
41 | "Once or Twice",
42 | "< once/month",
43 | "~ once/month",
44 | "~ twice/month",
45 | "~ once/week",
46 | "Several times/week",
47 | "Everyday")
48 | attendLabels<-c( "Never",
49 | "Once or Twice",
50 | "Less than once/month",
51 | "About once/month",
52 | "About twice/month",
53 | "About once/week",
54 | "Several times/week",
55 | "Everyday")
56 | varlist<- c("attend")
57 | for(i in varlist){
58 | dsF[,paste0(i,"F")]<-ordered(dsF[,i],
59 | levels = attendLevels,
60 | labels = attendLabels)
61 | }
62 | # The color scale developed for this variable
63 | attcol8<-c("Never"="#4575b4",
64 | "Once or Twice"="#74add1",
65 | "Less than once/month"="#abd9e9",
66 | "About once/month"="#e0f3f8",
67 | "About twice/month"="#fee090",
68 | "About once/week"="#fdae61",
69 | "Several times/week"="#f46d43",
70 | "Everyday"="#d73027")
71 |
72 |
73 | # ADD MORE VARIABLES HERE
74 |
75 | # Now data set contains a set of ghost Factor variables that can be used in graphing and modeling
--------------------------------------------------------------------------------
/Scripts/Data/dsL.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 |
4 | ## @knitr LoadPackages
5 | require(sas7bdat)
6 | require(Hmisc)
7 |
8 | ## @knitr LoadData
9 | pathDir <- getwd()
10 | pathFileSAS <- file.path(pathDir,"Chapters/02/SAS_Chapter2/SAS_Chapter2.sas7bdat")
11 | pathFileSPSS <- file.path(pathDir,"Chapters/02/SPSS_Chapter2/SPSS_Chapter2.sav")
12 |
13 | path_ds0 <- file.path(pathDir, "Data/Derived/02/ds0.Rds")
14 | path_dsL <- file.path(pathDir, "Data/Derived/02/dsL.Rds")
15 |
16 |
17 | ds0SAS <- read.sas7bdat(pathFileSAS, debug=TRUE) # Use this when running for the first time
18 | ds0SPSS <- Hmisc::spss.get(pathFileSPSS, use.value.labels = TRUE)
19 |
20 | saveRDS(object=ds0, file=path_ds0, compress="xz") # Use this when running for the first time
21 | ### Either use ds0 definition above or below.
22 | ds0<-readRDS(path_ds0) # This saves time # Use for subsequent run
23 |
--------------------------------------------------------------------------------
/Scripts/Data/loadChapterDatasets.R:
--------------------------------------------------------------------------------
1 | # remove all elements for a clean start
2 | rm(list=ls(all=TRUE))
3 |
4 | ## @knitr LoadPackages
5 | require(sas7bdat)
6 |
7 | ## @knitr LoadData
8 | pathDir <- getwd()
9 | pathCh2 <- file.path(pathDir,"Chapters/02/SAS_Chapter2/SAS_Chapter2.sas7bdat")
10 | pathCh3a <- file.path(pathDir,"Chapters/03/SAS_Chapter3a/SAS_Chapter3a.sas7bdat")
11 | pathCh3b <- file.path(pathDir,"Chapters/03/SAS_Chapter3b/SAS_Chapter3b.sas7bdat")
12 | pathCh4 <- file.path(pathDir,"Chapters/04/SAS_Chapter4/SAS_Chapter4.sas7bdat")
13 | pathCh5 <- file.path(pathDir,"Chapters/05/SAS_Chapter4/SAS_Chapter5.sas7bdat")
14 | pathCh6 <- file.path(pathDir,"Chapters/06/SAS_Chapter6/SAS_Chapter6.sas7bdat")
15 | pathCh7a <- file.path(pathDir,"Chapters/07/SAS_Chapter7a/SAS_Chapter7a.sas7bdat")
16 | pathCh7b <- file.path(pathDir,"Chapters/07/SAS_Chapter7b/SAS_Chapter7b.sas7bdat")
17 | pathCh8 <- file.path(pathDir,"Chapters/08/SAS_Chapter8/SAS_Chapter8.sas7bdat")
18 | pathCh9 <- file.path(pathDir,"Chapters/09/SAS_Chapter9/SAS_Chapter9.sas7bdat")
19 | pathCh10a <- file.path(pathDir,"Chapters/10/SAS_Chapter10a/SAS_Chapter10a.sas7bdat")
20 | pathCh10b <- file.path(pathDir,"Chapters/10/SAS_Chapter10b/SAS_Chapter10b.sas7bdat")
21 | pathCh11a <- file.path(pathDir,"Chapters/11/SAS_Chapter11a/SAS_Chapter11a.sas7bdat")
22 | pathCh11b <- file.path(pathDir,"Chapters/11/SAS_Chapter11b/SAS_Chapter11b.sas7bdat")
23 | pathCh12 <- file.path(pathDir,"Chapters/12/SAS_Chapter12/SAS_Chapter12.sas7bdat")
24 |
25 |
26 |
27 | dsL2 <- read.sas7bdat(pathCh2, debug=TRUE)
28 | dsL3a <- read.sas7bdat(pathCh3a, debug=TRUE)
29 | dsL3b <- read.sas7bdat(pathCh3b, debug=TRUE)
30 | dsL4 <- read.sas7bdat(pathCh4, debug=TRUE)
31 | dsL5 <- read.sas7bdat(pathCh5, debug=TRUE)
32 | dsL6 <- read.sas7bdat(pathCh6, debug=TRUE)
33 | dsL7a <- read.sas7bdat(pathCh7a, debug=TRUE)
34 | dsL7b <- read.sas7bdat(pathCh7b, debug=TRUE)
35 | dsL8 <- read.sas7bdat(pathCh8, debug=TRUE)
36 | dsL9 <- read.sas7bdat(pathCh9, debug=TRUE)
37 | dsL10a <- read.sas7bdat(pathCh10a, debug=TRUE)
38 | dsL10b <- read.sas7bdat(pathCh10b, debug=TRUE)
39 | dsL11a <- read.sas7bdat(pathCh11a, debug=TRUE)
40 | dsL11b <- read.sas7bdat(pathCh11b, debug=TRUE)
41 | dsL12 <- read.sas7bdat(pathCh12, debug=TRUE)
42 |
43 | # # path_dsL2 <- file.path(pathDir, "Data/Derived/02/dsL.Rds")
44 | # saveRDS(object=ds0, file=path_ds0, compress="xz") # Use this when running for the first time
45 | # ### Either use ds0 definition above or below.
46 | # ds0<-readRDS(path_ds0) # This saves time # Use for subsequent run
47 |
48 |
49 | write.csv(dsL6, file="Data/Derived/MPLUS_Chpater6.csv")
50 |
--------------------------------------------------------------------------------
/Scripts/Graphs/AesDefine.R:
--------------------------------------------------------------------------------
1 | # Definitions of of aesthetics used in reports
2 |
3 |
4 | # COLORS
5 | ## the colors for response categories of item "attend"
6 | attendCol8<-c("Never"="#4575b4",
7 | "Once or Twice"="#74add1",
8 | "Less than once/month"="#abd9e9",
9 | "About once/month"="#e0f3f8",
10 | "About twice/month"="#fee090",
11 | "About once/week"="#fdae61",
12 | "Several times/week"="#f46d43",
13 | "Everyday"="#d73027")
14 |
15 | ## The color of cohorts
16 | byearCol5<- c("1980"="#9ecae1",
17 | "1981"="#6baed6",
18 | "1982"="#4292c6",
19 | "1983"="#2171b5",
20 | "1984"="#084594")
21 |
22 |
23 | ## the color of missing values
24 | NACol<- "#f9f9f9" #"#636363"
25 |
26 |
27 | # SIZES
28 | # guides and legends, but not axes and title
29 | baseSize<- 12
30 |
31 |
32 | # SHAPES
33 |
34 | # GROUPS
35 |
36 | # Variables that DO NOT change with time, TI - time invariant
37 | TIvars<-c("sample", "id", "sex","race", "bmonth","byear", 'attendPR', "relprefPR", "relraisedPR")
38 |
39 | # Variables that DO change with time, TV - time variant
40 | TVvars<- c("agemon", "ageyear", "famrel", "attend",
41 | "values","todo", "obeyed","pray", "decisions",
42 | "relpref", "bornagain", "faith",
43 | "calm", "blue", "happy", "depressed","nervous",
44 | "tv", "computer", "internet")
45 |
46 | # Service
47 | counterAge<- c("0"="white","1"="#23c8b2")
48 |
49 | basicDark<- "#4f8a83"
50 |
51 | ####
52 | # All defined elements
53 | aesDefs<- list("attendCol8" = attendCol8,
54 | "byearCol5" = byearCol5,
55 | "NACol" = NACol,
56 | "baseSize"= baseSize,
57 | "TIvars"=TIvars,
58 | "TVvars"=TVvars)
59 |
60 | colorFixed <- "blue"
61 | colorRandom <- "red"
62 |
--------------------------------------------------------------------------------
/Scripts/Graphs/basicTrajectory.R:
--------------------------------------------------------------------------------
1 | p <- ggplot2::ggplot(dsM,aes(x=time,y=attend, group=id))
2 | p <- p + geom_line()
3 | p <- p + geom_point(pch=20, size=2.5)
4 | p <- p + plotTheme
5 | p <- p + scale_x_continuous(limits=c(0,11),
6 | breaks=c(0:11))
7 | p <- p + scale_y_continuous(limits=c(0,8),
8 | breaks=seq(1,8, by=1))
9 | p <- p + labs(list(
10 | title="How often did you attend worship last year?",
11 | x="Time scale: years since 2000", y="Church attendance"))
12 |
--------------------------------------------------------------------------------
/Scripts/Graphs/basicTrajectory300.R:
--------------------------------------------------------------------------------
1 | # p <- ggplot2::ggplot(dsM,aes(x=time,y=attend, group=id))
2 | # p <- p + geom_line()
3 | # p <- p + geom_point(pch=20, size=2.5)
4 | # p <- p + plotTheme
5 | # p <- p + scale_x_continuous(limits=c(0,11),
6 | # breaks=c(0:11))
7 | # p <- p + scale_y_continuous(limits=c(1,8),
8 | # breaks=seq(1,8, by=1))
9 | # p <- p + labs(list(
10 | # title="How often did you attend worship last year?",
11 | # x="Time scale: years since 2000", y="Church attendance"))
12 |
13 |
14 | # dsM <- dplyr::filter(dsL, id <=300,
15 | # raceF != "Mixed (Non-H)") %>%
16 | # dplyr::select(id,sexF,raceF,year,attend,attendF) %>%
17 | # dplyr::mutate(yearc = year - 2000)
18 | #
19 | p <- ggplot2::ggplot(dsM,aes(x=time,y=attend))
20 | p <- p + geom_line(aes(group=id), color='firebrick',
21 | alpha=.2,
22 | position=position_jitter(w=0.3, h=0.3))
23 | p <- p + geom_point(shape=1, color="black", fill=NA,
24 | alpha=.4, size=2,
25 | position=position_jitter(w=0.3, h=0.3))
26 | p <- p + plotTheme
27 | p <- p + scale_x_continuous(limits=c(0,11),
28 | breaks=c(0:11))
29 | p <- p + scale_y_continuous(limits=c(0,8),
30 | breaks=seq(1,8, by=1))
31 | p <- p + labs(list(
32 | title="How often did you attend worship last year?",
33 | x="Time scale: years since 2000", y="Church attendance"))
34 | p
35 |
--------------------------------------------------------------------------------
/Scripts/Graphs/graphThemes.R:
--------------------------------------------------------------------------------
1 | baseSize <- 12
2 |
3 | theme1 <- ggplot2::theme_bw(base_size=baseSize) +
4 | ggplot2::theme(title=ggplot2::element_text(colour="gray20",size = baseSize+1)) +
5 | ggplot2::theme(axis.text=ggplot2::element_text(colour="gray40", size=baseSize-2)) +
6 | ggplot2::theme(axis.title=ggplot2::element_text(colour="gray40")) +
7 | ggplot2::theme(panel.border = ggplot2::element_rect(colour="gray80")) +
8 | ggplot2::theme(axis.ticks.length = grid::unit(0, "cm")) +
9 | ggplot2::theme(text = element_text(size =baseSize+7))
10 |
11 |
12 | barFitTheme <- theme_bw() +
13 | theme(axis.text = element_text(colour="gray40", size=15)) +
14 | theme(axis.text.x = element_text(angle=90, vjust = .5)) +
15 | theme(axis.title = element_text(colour="gray40")) +
16 | theme(panel.border = element_rect(colour="gray80")) +
17 | theme(panel.grid.major.x = element_blank()) +
18 | # theme(axis.ticks = element_line(colour="gray80")) +
19 | theme(axis.ticks.length = grid::unit(0, "cm")) +
20 | theme(legend.position=c(.85,.8), legend.justification=c(0,0)) +
21 | # theme(legend.background = element_rect(fill = '#99999933')) +
22 | theme(legend.background = element_rect(fill = NA)) +
23 | theme(legend.text = element_text(colour = 'gray40'))
24 |
25 |
26 | barFitTheme2 <- theme_bw() +
27 | theme(axis.text = element_text(colour="gray40", size=15)) +
28 | theme(axis.text.x = element_text(angle=0, vjust = .5)) +
29 | theme(axis.title = element_text(colour="gray40")) +
30 | theme(panel.border = element_rect(colour="gray80")) +
31 | theme(panel.grid.major.x = element_blank()) +
32 | # theme(axis.ticks = element_line(colour="gray80")) +
33 | theme(axis.ticks.length = grid::unit(0, "cm")) +
34 | theme(legend.position=c(.85,.8), legend.justification=c(0,0)) +
35 | # theme(legend.background = element_rect(fill = '#99999933')) +
36 | theme(legend.background = element_rect(fill = NA)) +
37 | theme(legend.text = element_text(colour = 'gray40'))
38 |
--------------------------------------------------------------------------------
/Scripts/Graphs/line_graph_trajectories.R:
--------------------------------------------------------------------------------
1 | # rm(list=ls(all=TRUE)) #Clear the memory of variables from previous run. This is not called by knitr, because it's above the first chunk.
2 |
3 | require(ggplot2)
4 | require(dplyr)
5 | require(reshape2)
6 |
7 | BuildLine <- function( ) {
8 |
9 | baseSize <- 12
10 | ###
11 | plotTheme <- ggplot2::theme_bw() +
12 | ###
13 | ggplot2::theme_bw(base_size=baseSize)+
14 | ggplot2::theme(title=ggplot2::element_text(colour="gray20",size = baseSize + 3)) +
15 | ggplot2::theme(axis.text=ggplot2::element_text(colour="gray40", size= baseSize - 2))+
16 | ggplot2::theme(axis.title.x=ggplot2::element_text(colour="gray40", size = baseSize + 2, vjust=-.3))+
17 | ggplot2::theme(axis.title.y=ggplot2::element_text(colour="gray40", size = baseSize + 2, vjust=1.3))+
18 | ggplot2::theme(panel.border = ggplot2::element_rect(colour="gray80"))+
19 | ggplot2::theme(axis.ticks.length = grid::unit(0, "cm"))#+
20 | # ggplot2::theme(panel.background=element_rect(fill=bgColour,colour=NA)) +
21 | # ggplot2::theme(legend.position=c(.95,.90),legend.direction="vertical") +
22 | # ggplot2::theme(legend.background = element_rect(fill=NA)) +
23 | # ggplot2::theme(legend.text = element_text(size = 15),legend.title.align =(-3.3))# +
24 | # ggplot2::theme(panel.grid = element_line(linetype = 1,size=rel(3)))
25 | dsM<- dsL %>% dplyr::filter(id %in% c(1,23))
26 | # ds<- dsp
27 | # head(ds)
28 | p <- ggplot2::ggplot(dsM,aes(x=year,y=attend, group=id))
29 | p <- p + geom_line() + geom_point() + plotTheme
30 | p <- p + scale_x_continuous(limits=c(2000,2011),
31 | breaks=c(2000:2011))
32 | p <- p + scale_y_continuous(limits=c(1,8),
33 | breaks=seq(1,8, by=1))
34 | p <- p + labs(list(
35 | title="How often did you attend worship last year?",
36 | x="Year of observation", y="Church attendance"))
37 | p
38 | return( p )
39 |
40 | }
41 |
42 | gLine <- BuildLine(
43 | p <- p + abline(a=0,b=1))
44 | print(gLine)
45 |
46 |
47 | # BuildLine("m7F")
48 | # BuildLine("m7R1")
49 | # BuildLine("m7R2")
50 |
--------------------------------------------------------------------------------
/Scripts/Utility/InstallPackages.R:
--------------------------------------------------------------------------------
1 | #This code checks the user's installed packages against a list of packages (that we've manually compiled)
2 | # necessary for the graphs to be rendered. Missing packages are installed, while existing packages are not.
3 | # If anyone sees a package that should be on there, please tell me.
4 | rm(list=ls(all=TRUE)) #Clear the memory for any variables set from any previous runs.
5 |
6 | packagesToInstall <- c(
7 | "arm" # for working with model objects, by Gelman & Hill
8 | , "colorspace" #Explicit control over the HCL color scheme
9 | , "devtools" #package development
10 | , "dplyr" # for general data manipulation
11 | , "ggplot2" #Graphing
12 | , "ggthemes" #Extra themes, scales and geoms for ggplot
13 | , "ggmap" #Maps & graphics, based on ggplot
14 | , "googleVis" #JavaScript-based visualizations, like scrollable tables
15 | , "grid" #The underlying framework for the graphics
16 | , "gridExtra" #for table FERE graphs
17 | , "gridBase" #Additional grid functions
18 | , "knitr" #For creating dynamic reports
19 | , "lme4" # used for Random Coefficient Modeling
20 | , "lubridate" #Consistent/convienent function signatures for manipulating dates
21 | , "minqa"
22 | , "nlme" # used for Fixed Effect modeling
23 | , "plyr" #Important for most of our data manipulation
24 | , "psych" # data summary + other useful function
25 | , "RColorBrewer" #Explicit control over the Color Brewer colors. See http://colorbrewer2.org/
26 | , "reshape2" #Data manipulation not covered in plyr, wide <-> long
27 | , "RJSONIO" # for processing jason files
28 | , "roxygen2" #Creates documentation Rd file from (well-formed) comments
29 | , "RODBC"
30 | , "sas7bdat" # Imports SAS formatted data files
31 | , "stringr"
32 | , "testit" #has the useful `assert()` function
33 | , "testthat" #Heavier testing framework that's good for package development
34 | , "yaml" #for gh-pages production
35 | , "rhdf5"
36 |
37 | )
38 |
39 |
40 |
41 |
42 |
43 | for( packageName in packagesToInstall ) {
44 | available <- require(packageName, character.only=TRUE) #Loads the packages, and indicates if it's available
45 | if( !available ) {
46 | install.packages(packageName, dependencies=TRUE)
47 | require( packageName, character.only=TRUE)
48 | }
49 | }
50 |
51 | update.packages(ask="graphics", checkBuilt=TRUE)
52 |
53 | #There will be a warning message for every package that's called but not installed. It will look like:
54 | # Warning message:
55 | # In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
56 | # there is no package called 'bootstrap'
57 | #If you see the message (either in here or in another piece of the project's code),
58 | # then run this again to make sure everything is installed. You shouldn't get a warning again.
--------------------------------------------------------------------------------
/Scripts/Utility/runAll.R:
--------------------------------------------------------------------------------
1 | rm(list=ls(all=TRUE))
2 | ########## Production of reports from .Rmd files ###
3 |
4 | patternToBuild <- "(?= 90] <- "A+"
8 | grades$letter[percent >= 85 & percent <= 89] <- "A"
9 | grades$letter[percent >= 80 & percent <= 84] <- "A-"
10 | grades$letter[percent >= 77 & percent <= 79] <- "B+"
11 | grades$letter[percent >= 73 & percent <= 76] <- "B"
12 | grades$letter[percent >= 70 & percent <= 72] <- "B-"
13 | grades$letter[percent >= 65 & percent <= 69] <- "C+"
14 | grades$letter[percent >= 60 & percent <= 64] <- "C"
15 | grades$letter[percent >= 50 & percent <= 59] <- "D"
16 | grades$letter[percent < 50 ] <- "F"
17 | detach(grades)
18 |
19 | head(grades)
20 | table(grades$letter)
--------------------------------------------------------------------------------
/libs/css/sidebar.css:
--------------------------------------------------------------------------------
1 | #TOC {
2 | position: fixed;
3 | left: 0;
4 | top: 0;
5 | width: 250px;
6 | height: 100%;
7 | overflow:auto;
8 | line-height:200%;
9 | }
10 |
11 | .emphasized {
12 | font-size: 1.2em;
13 | color: red;
14 | }
15 |
--------------------------------------------------------------------------------
/psy564.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
--------------------------------------------------------------------------------