首页 > 代码库 > MplusAutomation包的使用 二
MplusAutomation包的使用 二
---恢复内容开始---
1、提取总结表格
showSummaryTable(summaryStats, keepCols=c("Title", "LL", "AIC", "BIC", "CFI"), sortBy="AIC")
showSummaryTable(summaryStats, dropCols=c("InputInstructions", "Observations", "Parameters"), sortBy="CFI")
2、提取单独参数估计结果
standardizedResults <- modelResults[["stdyx.standardized"]] unstandardizedResults <- modelResults$unstandardized
3、提取一组参数估计结果
allModelParameters <- extractModelParameters("C:/Data_Analysis/ComparingLCAvCFA", recursive=TRUE) The names of the returned list elements would be based on the directory and ?le names of each ?le
(note that spaces, slashes, and the minus sign have been replaced by periods to be compatible with R naming conventions): > names(allModelParameters) ComparingLCAvCFA.LCA.1.class.LCA.out
ComparingLCAvCFA.LCA.2.class.LCA.out
ComparingLCAvCFA.LCA.3.class.LCA.out
ComparingLCAvCFA.CFA.1.factor.CFA.out
ComparingLCAvCFA.CFA.2.factor.CFA.out
ComparingLCAvCFA.CFA.3.factor.CFA.out So, to extract the STDYX standardized results for the 2-factor CFA, one would access that data.frame as follows: TwoFacCFA.STDYX <- allModelParameters$ComparingLCAvCFA.CFA.2.factor.CFA.out$stdyx.standardized
4、 Comparing summaries and parameters across models
parallelModels <- readModels("10_14_Harsh_SelfCon_Impul") > compareModels(parallelModels[["backport.from.grand.model.out"]],
parallelModels[["backport.from.grand.model.slopesonw1.out"]],
show=c("diff", "pdiff", "summaries", "unique"), equalityMargin=c(param=.05, pvalue=http://www.mamicode.com/.02),
sort="type", diffTest=TRUE, showNS=FALSE)
5、 Creating a group of models from an Mplus template ?le (createModels)从模板文件创造一组模型
The createModels function converts a single Mplus template ?le into a set of related Mplus input ?les。
Mplus template syntax ?les are divided into two sections: the init section and the body section.
A Complete Example Here, we provide a complex complete example of a template ?le that generates 480 input ?les in numerous subfolders.
This is probably overkill for most applications, but it gives a sense of what the language is capable of.
The application here is growth mixture modeling for symptoms of DSM-IV personality disorders over time.
There are 10 personality disorders and two groups of participants: high risk and low risk.
In addition, one question of interest is whether a class constrained to 0 at the ?rst measurement occasion with 0 growth captures a subgroup of participants.
In addition, one might be interested in comparing whether these count data are better modeled by a continuous normal model versus a Poisson model, and whether Poisson GMM provides a better ?t than Poission latent class growth analysis (LCGA).
All of these considerations are re?ected in this single template ?le. As a sane default, we chose to generate models that vary between 1 and 4 latent trajectory classes. [[init]] iterators = outcome group model classes zeroclass;
outcome = 1:10;
group = 2 5;
model = 1:3;
classes = 1:4;
zeroclass = 1:2; outcomenames#outcome = Paranoid Schizoid Schizotypal Antisocial Borderline Histrionic Narcissistic Avoidant Dependent OCPD; groupnames#group = "Low Risk" "High Risk"; modelnames#model = "Normal LGCM" "Poisson GMM" "Poisson LCGA"; zeroclassnames#zeroclass = "" " with zero class"; #wave names are with respect to the outcome iterator w1name#outcome = Paran1 Szoid1 Sztyp1 Anti1 Border1 Hist1 Narc1 Avoid1 Depend1 OCPD1;
w2name#outcome = Paran2 Szoid2 Sztyp2 Anti2 Border2 Hist2 Narc2 Avoid2 Depend2 OCPD2;
w3name#outcome = Paran3 Szoid3 Sztyp3 Anti3 Border3 Hist3 Narc3 Avoid3 Depend3 OCPD3; filename = "[[classes]]-class [[groupnames#group]] [[outcomenames#outcome]] [[modelnames#model]][[zeroclassnames#zeroclass]].inp";
outputDirectory = "PD GMM/[[outcomenames#outcome]]/[[groupnames#group]]/Unconditional_Models/[[modelnames#model]]";
[[/init]] TITLE: [[classes]]-class [[outcomenames#outcome]] [[groupnames#group]] [[modelnames#model]] Unconditional Model[[zeroclassnames#zeroclass]]
DATA: FILE = "personality_mplus.dat"; VARIABLE: NAMES ARE id group sex age Paran1 Szoid1 Sztyp1 Anti1 Border1 Hist1 Narc1 Avoid1 Depend1 OCPD1 PaAg1 Sadist1 SelfDef1 Paran2 Szoid2 Sztyp2 Anti2 Border2 Hist2 Narc2 Avoid2 Depend2 OCPD2 Paran3 Szoid3 Sztyp3 Anti3 Border3 Hist3 Narc3 Avoid3 Depend3 OCPD3; MISSING ARE .;
USEVARIABLES ARE [[w1name#outcome]] [[w2name#outcome]] [[w3name#outcome]];
USEOBSERVATIONS ARE group EQ [[group]]; ![[groupnames#group]] Only [[model > 1]] COUNT ARE [[w1name#outcome]] [[w2name#outcome]] [[w3name#outcome]];
[[/model > 1]] CLASSES = c ([[classes]]); ANALYSIS: TYPE = MIXTURE; STARTS = 1000 10;
K-1STARTS = 750 6; PROCESSORS = 4;
[[model = 2]] ALGORITHM = INTEGRATION;
[[/model = 2]] MODEL: %OVERALL% Int Slope | [[w1name#outcome]]@0 [[w2name#outcome]]@0.97 [[w3name#outcome]]@2.77; [[classes > 1]] [[zeroclass = 2]] !creates a class with all zeros at all time points [[model=1]] %c#2% [Int@0 Slope@0];
Int@0 Slope@0;
[[/model=1]] [[model>1]] %c#2% [Int@-15 Slope@-15]; Int@0 Slope@0; [[/model>1]] [[/zeroclass = 2]] [[/classes > 1]] PLOT: Type = PLOT3;
Series = [[w1name#outcome]] (0) [[w2name#outcome]] (0.97) [[w3name#outcome]] (2.77);
OUTPUT: TECH1 TECH4 [[model != 1]]TECH10 [[/model != 1]][[classes > 1]]TECH11 TECH14 [[/classes > 1]]STANDARDIZED RESIDUAL;
MplusAutomation包的使用 二
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。