OpenMx Frühling Rijsdijk.

Slides:



Advertisements
Similar presentations
Multivariate Twin Analysis
Advertisements

Multilevel analysis with EQS. Castello2004 Data is datamlevel.xls, datamlevel.sav, datamlevel.ess.
Fitting Bivariate Models October 21, 2014 Elizabeth Prom-Wormley & Hermine Maes
Elizabeth Prom-Wormley & Hermine Maes
Univariate Model Fitting
Summarizing Variation Matrix Algebra & Mx Michael C Neale PhD Virginia Institute for Psychiatric and Behavioral Genetics Virginia Commonwealth University.
(Re)introduction to OpenMx Sarah Medland. Starting at the beginning  Opening R Gui – double click Unix/Terminal – type R  Closing R Gui – click on the.
Path Analysis Danielle Dick Boulder Path Analysis Allows us to represent linear models for the relationships between variables in diagrammatic form.
(Re)introduction to Mx Sarah Medland. KiwiChinese Gooseberry.
Multivariate Analysis Nick Martin, Hermine Maes TC21 March 2008 HGEN619 10/20/03.
Multivariate Genetic Analysis: Introduction(II) Frühling Rijsdijk & Shaun Purcell Wednesday March 6, 2002.
Extended sibships Danielle Posthuma Kate Morley Files: \\danielle\ExtSibs.
Summarizing Variation Michael C Neale PhD Virginia Institute for Psychiatric and Behavioral Genetics Virginia Commonwealth University.
Summarizing Data Nick Martin, Hermine Maes TC21 March 2008.
Developmental models. Multivariate analysis choleski models factor models –y =  f + u genetic factor models –P j = h G j + c C j + e E j –common pathway.
ACDE model and estimability Why can’t we estimate (co)variances due to A, C, D and E simultaneously in a standard twin design?
Heterogeneity Hermine Maes TC19 March Files to Copy to your Computer Faculty/hmaes/tc19/maes/heterogeneity  ozbmi.rec  ozbmi.dat  ozbmiysat(4)(5).mx.
(Re)introduction to Mx. Starting at the beginning Data preparation Mx expects 1 line per case/family Almost limitless number of families and variables.
Univariate Analysis in Mx Boulder, Group Structure Title Type: Data/ Calculation/ Constraint Reading Data Matrices Declaration Assigning Specifications/
Multivariate Analysis Hermine Maes TC19 March 2006 HGEN619 10/20/03.
Univariate Analysis Hermine Maes TC19 March 2006.
Path Analysis Frühling Rijsdijk SGDP Centre Institute of Psychiatry King’s College London, UK.
Introduction to Multivariate Genetic Analysis Kate Morley and Frühling Rijsdijk 21st Twin and Family Methodology Workshop, March 2008.
Path Analysis Frühling Rijsdijk. Biometrical Genetic Theory Aims of session:  Derivation of Predicted Var/Cov matrices Using: (1)Path Tracing Rules (2)Covariance.
Raw data analysis S. Purcell & M. C. Neale Twin Workshop, IBG Colorado, March 2002.
Power and Sample Size Adapted from: Boulder 2004 Benjamin Neale Shaun Purcell I HAVE THE POWER!!!
Path Analysis HGEN619 class Method of Path Analysis allows us to represent linear models for the relationship between variables in diagrammatic.
What is R By: Wase Siddiqui. Introduction R is a programming language which is used for statistical computing and graphics. “R is a language and environment.
Karri Silventoinen University of Helsinki Osaka University.
Karri Silventoinen University of Helsinki Osaka University.
Confirmatory Factor Analysis Using OpenMx & R
Karri Silventoinen University of Helsinki Osaka University.
Institute of Psychiatry King’s College London, UK
Introduction to Multivariate Genetic Analysis (2) Marleen de Moor, Kees-Jan Kan & Nick Martin March 7, 20121M. de Moor, Twin Workshop Boulder.
Introduction to OpenMx Sarah Medland. What is OpenMx? Free, Open-source, full–featured SEM package Software which runs on Windows, Mac OSX, and Linux.
Univariate modeling Sarah Medland. Starting at the beginning… Data preparation – The algebra style used in Mx expects 1 line per case/family – (Almost)
Power and Sample Size Boulder 2004 Benjamin Neale Shaun Purcell.
Statistics. A two-dimensional random variable with a uniform distribution.
Univariate Analysis Hermine Maes TC21 March 2008.
Mx modeling of methylation data: twin correlations [means, SD, correlation] ACE / ADE latent factor model regression [sex and age] genetic association.
Mx Practical TC20, 2007 Hermine H. Maes Nick Martin, Dorret Boomsma.
Frühling Rijsdijk & Kate Morley
Categorical Data Frühling Rijsdijk 1 & Caroline van Baal 2 1 IoP, London 2 Vrije Universiteit, A’dam Twin Workshop, Boulder Tuesday March 2, 2004.
Model building & assumptions Matt Keller, Sarah Medland, Hermine Maes TC21 March 2008.
Welcome  Log on using the username and password you received at registration  Copy the folder: F:/sarah/mon-morning To your H drive.
More on thresholds Sarah Medland. A plug for OpenMx? Very few packages can handle ordinal data adequately… OpenMx can also be used for more than just.
Introduction to Multivariate Genetic Analysis Danielle Posthuma & Meike Bartels.
QTL Mapping Using Mx Michael C Neale Virginia Institute for Psychiatric and Behavioral Genetics Virginia Commonwealth University.
March 7, 2012M. de Moor, Twin Workshop Boulder1 Copy files Go to Faculty\marleen\Boulder2012\Multivariate Copy all files to your own directory Go to Faculty\kees\Boulder2012\Multivariate.
Multivariate Genetic Analysis (Introduction) Frühling Rijsdijk Wednesday March 8, 2006.
R Brown-Bag Seminar 2.1 Topic: Introduction to R Presenter: Faith Musili ICRAF-Geoscience Lab.
Multivariate Analysis
Probability Theory and Parameter Estimation I
Univariate Twin Analysis
Introduction to OpenMx
Introduction to Multivariate Genetic Analysis
Re-introduction to openMx
Univariate Analysis HGEN619 class 2006.
MRC SGDP Centre, Institute of Psychiatry, Psychology & Neuroscience
Path Analysis Danielle Dick Boulder 2008
Introduction to R.
Univariate modeling Sarah Medland.
(Re)introduction to Mx Sarah Medland
CSCI N207 Data Analysis Using Spreadsheet
Sarah Medland faculty/sarah/2018/Tuesday
Lucía Colodro Conde Sarah Medland & Matt Keller
BOULDER WORKSHOP STATISTICS REVIEWED: LIKELIHOOD MODELS
Multivariate Genetic Analysis: Introduction
Presentation transcript:

OpenMx Frühling Rijsdijk

OpenMx Models Steven Boker1 Michael Neale2 Hermine Maes2 Paras Mehta3 Michael Wilde4 Timothy Brick1 Jerey Spies1 Michael Spiegel1 Ryne Estabrook1 Sarah Kenny4 John Fox5 Timothy Bates6 1University of Virginia; 2Virginia Commonwealth University; 3University of Houston; 4University of Chicago, Argonne National Labs; 5McMasters University; 6University of Edinburgh

Open Mx is OpenMx is free open source software for fitting Structural Equation Models (SEM) to observed data. OpenMx offers the features you would expect in an SEM software package, but OpenMx works in ways that will make your modeling jobs easier and will allow you to do things that other SEM packages don't. Integration with R OpenMx works as an integral part of the R statistical software system. You have available the full power of the R statistical software system for data manipulation, graphics, simulation, and report generation http://openmx.psyc.virginia.edu

Open Mx is 1. A free, full-featured, open source SEM package. 2. Runs on Windows, Mac OS-X, and Linux. 3. Runs inside the R statistical programming environment. OpenMx features: 1. A new approach to model specification. 2. Allows both path-style and matrix-style scripting. 3. Web-based forums, tutorials, and a wiki. http://openmx.psyc.virginia.edu

Install OpenMx What computers run OpenMx? You can run OpenMx on computers using Windows XP, Windows Vista, Mac (Intel or PPC) OS-X 10.5 or later, and varieties of Linux (32 and 64 bit). What do I need to do first? In order to install OpenMx, you will need R version 2.9.x or 2.10.1. How do I install OpenMx? Open up an R session and copy the following line into the R command line: source('http://openmx.psyc.virginia.edu/getOpenMx.R') execute line A few lines of R output will scroll by and your OpenMx (and snow and Matrix) library will be installed

model building SEM Biometrical Genetic Theory Twin Model Covariance Observed Data model building Twin Model Summary Statistics System of Linear Equations Path Diagrams Covariance Algebra Path Tracing Rules Predicted Var/Cov of the Model Observed Var/Cov of the Data SEM

Path Diagrams for the Classical ACE Twin Model

Model for MZ or DZ Pairs Reared Together 1 1 /.5 E C A A C E 1 1 1 1 1 1 e c a a c e PTwin 1 PTwin 2

Predicted Var-Cov Matrices Tw1 Tw2 Tw1 Tw2 Tw1 Tw2 Tw1 Tw2

Saturated Twin Model To get Twin correlations (MZ and DZ) Testing e.g. equality in means and variances across Twin 1 and 2 and MZ and DZ groups

Variance / Covariance Stand 2x2 r Diag 2x2 L1 L2 S1 S2 V1tw1 V1tw2 Mean1 Mean2

Variance / Covariance r * * V1tw1 V1tw2 L1 L2 Mean1 Mean2 S1 S2 V1T1 V1T2 V1T1 S12 S1 * r * S2 V1T2 S1 * r * S2 S22

Means and Variances Multinormal Probability Density Function: -|2πΣ |-n/2 e -.5((xi - μ) Σ-1 (xi - μ)’) make use of all available data get unbiased estimates if missing data are missing at random Use Maximum Likelihood to estimate free Parameters: 2 means, 2 variances, 1 covariance

ACEuniv.R require(OpenMx) source("GenEpiHelperFunctions.R") # ----------------------------------------------------------------------- # Prepare Data NCdata <- read.table ('N-CortisolNA.csv', header=T, sep=',') names (NCdata) str(NCdata) nv <- 1 ntv <- nv*2 Vars <-('ncomp') selVars <- c('ncomp1','ncomp2') summary(NCdata) mzData <- subset(NCdata, zyg==1, selVars) dzData <- subset(NCdata, zyg==2, selVars) summary(mzData) summary(dzData) colMeans(mzData,na.rm=TRUE) cov(mzData,use="complete") colMeans(dzData,na.rm=TRUE) cov(dzData,use="complete")

Specify and Run Saturated Model with RawData and Matrix-style Input twinSatModel <- mxModel("twinSat", mxModel("MZ", mxMatrix(type="Full", nrow=1, ncol=ntv, free=T, values=c(30,30), name="expMeanMZ"), mxMatrix(type="Diag", nrow=ntv, ncol=ntv, free=TRUE, values=8, lbound=.001, name="expSDMZ" ), mxMatrix(type="Stand", nrow=ntv, ncol=ntv, free=TRUE, values=.8, lbound=-.99, ubound=.99, name="expCorMZ" ), mxAlgebra( expression= expSDMZ %*% expCorMZ %*% expSDMZ, name="expCovMZ" ), mxData(mzData, type="raw"), mxFIMLObjective("expCovMZ", "expMeanMZ", selVars)), mxModel("DZ", mxMatrix("Full", 1, 2, T, 30, name="expMeanDZ"), mxMatrix(type="Diag", nrow=ntv, ncol=ntv, free=TRUE, values=8, lbound=.001, name="expSDDZ" ), mxMatrix(type="Stand", nrow=ntv, ncol=ntv, free=TRUE, values=.6, lbound=-.99, ubound=.99, name="expCorDZ" ), mxAlgebra( expression= expSDDZ %*% expCorDZ %*% expSDDZ, name="expCovDZ" ), mxData(dzData, type="raw"), mxFIMLObjective("expCovDZ", "expMeanDZ", selVars)), mxAlgebra(MZ.objective + DZ.objective, name="-2sumLL"), mxAlgebraObjective("-2sumLL")) twinSatFit <- mxRun(twinSatModel) r L1 L2 S1 S2 V1tw1 V1tw2 Mean1 Mean2

TESTS ASSUMPTION OF EQUAL VARIANCES # ------------------------------------------------------------------------------------------------------------------ # Specify and Run Saturated SubModel 1 equating Variances ACROSS TWINS # ---------------------------------------------------------------------------------------------------------------- twinSatModelSub1 <- twinSatModel twinSatModelSub1$MZ$expSDMZ <- mxMatrix("Diag", 2, 2, T, 8, "sdMZ", name="expSDMZ") twinSatModelSub1$DZ$expSDDZ <- mxMatrix("Diag", 2, 2, T, 8, "sdDZ", name="expSDDZ") twinSatFitSub1 <- mxRun(twinSatModelSub1) #Check!! ExpSDMZ <- mxEval(MZ.expSDMZ, twinSatFitSub1) ExpSDMZ ExpSDDZ <- mxEval(DZ.expSDDZ, twinSatFitSub1) ExpSDDZ

TESTS ASSUMPTION OF EQUAL VARIANCES # ------------------------------------------------------------------------------------------------------------------ # Specify and Run Saturated SubModel 1 equating Variances ACROSS TWINS and ZYG # ---------------------------------------------------------------------------------------------------------------- twinSatModelSub1 <- twinSatModel twinSatModelSub1$MZ$expSDMZ <- mxMatrix("Diag", 2, 2, T, 8, "sd", name="expSDMZ") twinSatModelSub1$DZ$expSDDZ <- mxMatrix("Diag", 2, 2, T, 8, "sd", name="expSDDZ") twinSatFitSub1 <- mxRun(twinSatModelSub1) #Check!! ExpSDMZ <- mxEval(MZ.expSDMZ, twinSatFitSub1) ExpSDMZ ExpSDDZ <- mxEval(DZ.expSDDZ, twinSatFitSub1) ExpSDDZ

SPECIFY AND RUN ACE MODEL WITH RAWDATA AND MATRIX STYLE INPUT univACEModel <- mxModel("univACE", mxModel("ACE", # Matrix for expected means vector for MZ and DZ twins mxMatrix("Full", 1, 2, T, 20, "mean", name="expMean"), # Matrices a11, c11, and e11 to store the a, c, and e path coefficients mxMatrix("Full", nrow=1, ncol=1, free=TRUE, values=3, label="a11", name="a"), mxMatrix("Full", nrow=1, ncol=1, free=TRUE, values=3, label="c11", name="c"), mxMatrix("Full", nrow=1, ncol=1, free=TRUE, values=3, label="e11", name="e"), # Matrices A, C, and E to compute variance components mxAlgebra(a * t(a), name="A"), mxAlgebra(c * t(c), name="C"), mxAlgebra(e * t(e), name="E"), # Algebra to compute total variances and SD mxAlgebra( expression=A+C+E, name="V" ), mxMatrix( type="Iden", nrow=nv, ncol=nv, name="I"), mxAlgebra( expression=solve(sqrt(I*V)), name="sd"), # Algebra to model expected variance/covariance matrix in MZ mxAlgebra(rbind (cbind(A+C+E , A+C), cbind(A+C , A+C+E)), name="expCovMZ"), # Algebra to model expected variance/covariance matrix in DZ mxAlgebra(rbind (cbind(A+C+E , .5%x%A+C), cbind(.5%x%A+C , A+C+E)), name="expCovDZ") ), PTwin 1 E C A 1 e a c

mxData(mzData, type="raw"), mxModel("MZ", mxData(mzData, type="raw"), mxFIMLObjective("ACE.expCovMZ", "ACE.expMean",selVars) ), mxModel("DZ", mxData(dzData, type="raw"), mxFIMLObjective("ACE.expCovDZ", "ACE.expMean",selVars) mxAlgebra(MZ.objective + DZ.objective, name="-2sumLL"), mxAlgebraObjective("-2sumLL") ) # end of model univACE univACEFit <- mxRun(univACEModel) # ----------------------------------------------------------------------- # Generate ACE Model Output LL_ACE <- mxEval(objective, univACEFit) LL_ACE

Extract Information all information in MxModel fitted object list of algebras of container model specific algebra list of all items in all child models list of all items in specific child model list of all matrices in specific child model specific matrix in specific child model list of all algebras in specific child model specific algebra in specific child model objective of specific child model data of specific child model univTwinSatFit univTwinSatFit@algebras univTwinSatFit@algebras$’-2sumll’ univTwinSatFit@submodels univTwinSatFit@submodels$MZ =univTwinSatFit$MZ univTwinSatFit$MZ@matrices univTwinSatFit$MZ@matrices$CholMZ =univTwinSatFit$MZ$CholMZ univTwinSatFit$MZ@algebras univTwinSatFit$MZ@algebras$expCovMZ =univTwinSatFit$MZ$expCovMZ univTwinSatFit$MZ$objective univTwinSatFit$MZ$data

R Matrix Operators For example: Mx OpenMx Inverse ~ solve() http://openmx.psyc.virginia.edu/wiki/matrix-operators-and-functions For example: Mx OpenMx Inverse ~ solve() Transpose ‘ t() Row x col * %*% Dot Prod . * Kronecker Prod @ %x% Vert adhesion _ rbind() Hor adhesion | cbind()

GenEpiHelperFunctions.R Function "parameterSpecifations()" prints labels of a MxMatrix with square brackets surrounding free parameters; returns a matrix of strings Function "expectedMeansCovariances()" prints expected means and expected covariance matrices for all submodels Function "formatOutputMatrices()" prints matrix with specified labels and number of decimals Function "formatMatrix()" returns a matrix with specified dimnames and of decimal places Function "tableFitStatistics()" prints fit statistics with labels for Full Model and list of Nested Models