Revision of helper-functions from Sun, 09/27/2009 - 17:22

The revisions let you track differences between multiple versions of a post.

Wiki home page

Table of Contents 

Ideas and example functions that extend OpenMx, encapsulate tedious work, and make scripts easier to write or more compact.

You will probably define helper functions, especially for summarising the output of model you use frequently.

If you have questions not answers, then add those here: That's how a wiki works. Please add material here as you learn...

Read a Lower triangle file

source

readLowerTriangle <- function(file, nrows, fill=TRUE) {
    xvector <- scan(file)
    X <- matrix(NA, nrows, nrows)
    i <- 1
    for(row in 1:nrows) {
        for(col in 1:nrows) {
            if(col>row) next
            X[row,col] <- xvector[i]
            i <- i + 1
            if (fill)
                X[col,row] <- X[row,col]
        }
    }
    return(X)
}