DOC PREVIEW
VCU HGEN 619 - OpenMx Introduction

This preview shows page 1-2-3-4-5 out of 15 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

OpenMxIntroductionSeptember 2010Wednesday, September 29, 2010OpenMx Team•OpenMx: An Open Source and Extensible SEM Framework•Steven Boker1, Michael Neale2, Hermine Maes2, Paras Mehta3, Michael Wilde4, Timothy Brick1, Jeffrey Spies1, Michael Spiegel1, Ryne Estabrook1, Michael Hunter1, Sarah Kenny4, John Fox5, Timothy Bates6•1:University of Virginia, 2:Virginia Commonwealth University, 3:University of Houston, 4:University of Chicago, Argonne National Labs, 5:McMasters University, 6:University of EdinburghWednesday, September 29, 2010What is OpenMx•A free, full–featured, open source SEM package•Runs on Windows, Mac OS-X, and Linux•Runs inside the R statistical programming environment•Funded by the NIH Roadmap InitiativeWednesday, September 29, 2010OpenMx Features•A new approach to model specification•Allows both path-style and matrix-style scripting•Flexible optimization including nonlinear constraints•Web–based forums, tutorials, and a wiki•Support for most popular types of modeling•Advanced features not found in other SEM packages•An active development team.Wednesday, September 29, 2010OpenMx Models•Multivariate Normal Structural Equation Models•Multigroup Models, e.g. Behavior Genetic•Full Information Maximum Likelihood•Mixed Effects and Multilevel•Multivariate Categorical Data with Thresholds•Dynamical Systems Models•Nonlinear Constraints•User–supplied Matrix Algebra, Objective FunctionsWednesday, September 29, 2010OpenMx CommandsWednesday, September 29, 2010demoOneFactor -PathFirstOpenMxScript.R [1]# One Factor Model -Path-Style Input # ———————————————————————————————————-require(OpenMx)data(demoOneFactor)manifests <- names(demoOneFactor)latents <- c("G")factorModel <- mxModel("One Factor", type="RAM", manifestVars=manifests, latentVars=latents, mxPath(from=latents, to=manifests), mxPath(from=manifests, arrows=2), mxPath(from=latents, arrows=2, free=F, values=1.0), mxData(cov(demoOneFactor), type="cov", numObs=500))summary(mxRun(factorModel)Wednesday, September 29, 2010demoOneFactor -MatrixFirstOpenMxScript.R [2]# One Factor Model -Matrix-Style Input# ———————————————————————————————————-require(OpenMx)data(demoOneFactor)manifestVars <- names(demoOneFactor)factorModel <- mxModel("One Factor", mxMatrix("Full", 5, 1, values=0.2, free=T, name="A"), mxMatrix("Symm", 1, 1, values=1, free=F, name="L"), mxMatrix("Diag", 5, 5, values=1, free=T, name="U"), mxAlgebra(A %*% L %*% t(A) + U, name="R"), mxMLObjective("R", dimnames = manifestVars), mxData(cov(demoOneFactor), type="cov", numObs=500))summary(mxRun(factorModel)Wednesday, September 29, 2010OpenMx ProcessmxModel( name="myModelName" ) testModelmxRun( )mxMatrix(),mxMatrix(),mxConstraint(),mxAlgebra(),mxModel(),mxMatrix(),mxData(),mxObjective(), testModel testFitmxEval( algebra, ) testFitoutputMxModel R ObjectsR ObjectstestSummsummary( ) testFitWednesday, September 29, 2010Matrix Algebra•Matrices•AlgebrasWednesday, September 29, 2010Matrix Algebra ExampleFirstOpenMxScript.R [3]# Specify Model Matrices and Algebra# ———————————————————————————————————-algebraModel <- mxModel(“Algebra”, mxMatrix( type="Full", nrow=3, ncol=1, values=c(1,2,3), name='A' ), mxMatrix( type="Full", nrow=3, ncol=1, values=c(1,2,3), name='B' ), mxAlgebra( A + B, name='q1' ), # addition mxAlgebra( A * A, name='q2' ), # dot multiplication mxAlgebra( t(A), name='q3' ), # transpose mxAlgebra( A %*% t(A), name='q4' ), # inner product mxAlgebra( t(A) %*% A, name='q5' ) # outer product)# Run Model and Generate Output# ———————————————————————————————————-algebraFit <- mxRun(algebraModel)algebraFit@algebrasresult <- mxEval(list(q1,q2,q3,q4,q5),algebraFit)Wednesday, September 29, 2010Optimization•Estimate Correlation between X & Y•Test whether Correlation = ZeroX1μxσ2xYσ2yμyσxyX1μxσ2xYσ2yμyWednesday, September 29, 2010Optimization ExampleFirstOpenMxScript.R [4]# Simulate Data: two standardized variables X & Y with correlation of .5# ———————————————————————————————————-require(MASS)set.seed(200)rs=.5xy <- mvrnorm (1000, c(0,0), matrix(c(1,rs,rs,1),2,2))testData <- xyselVars <- c('X','Y')dimnames(testData) <- list(NULL, selVars)summary(testData)cov(testData)Wednesday, September 29, 20102 Correlated VariablesFirstOpenMxScript.R [5]# Fit Saturated Model with Raw Data and Matrix-style Input# ———————————————————————————————————-bivCorModel <- mxModel("bivCor", mxMatrix( type="Full", nrow=1, ncol=2, free=TRUE, values=c(0,0), name="expMean" ), mxMatrix( type="Lower", nrow=2, ncol=2, free=TRUE, values=.5, name="Chol" ), mxAlgebra( expression=Chol %*% t(Chol), name="expCov" ), mxData( observed=testData, type="raw" ), mxFIMLObjective( covariance="expCov", means="expMean", dimnames=selVars) )# Run Model and Generate Output# ———————————————————————————————————-bivCorFit <- mxRun(bivCorModel)EM <- mxEval(expMean, bivCorFit)EC <- mxEval(expCov, bivCorFit)LL <- mxEval(objective, bivCorFit)Wednesday, September 29, 2010Test Hypothesis r=0FirstOpenMxScript.R [6]# Specify SubModel testing Covariance=Zero# ———————————————————————————————————-bivCorModelSub <-mxModel(bivCorModel, name="bivCorZero", mxMatrix( type="Lower", nrow=2, ncol=2, free=c(T,F,T), name="Chol" ) )#orbivCorModelSub <-mxModel(bivCorModel, name="bivCorZero", mxMatrix( type="Diag", nrow=2, ncol=2, free=TRUE, name="Chol" ) )# Run Model and Generate Output# ———————————————————————————————————-bivCorFitSub <- mxRun(bivCorModelSub)EMs <- mxEval(expMean, bivCorFitSub)ECs <- mxEval(expCov, bivCorFitSub)LLs <- mxEval(objective, bivCorFitSub)Chi= LLs-LL;LRT= rbind(LL,LLs,Chi); LRTWednesday, September 29,


View Full Document

VCU HGEN 619 - OpenMx Introduction

Documents in this Course
Load more
Download OpenMx Introduction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view OpenMx Introduction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view OpenMx Introduction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?