Published on *OpenMx* (http://openmx.psyc.virginia.edu)

By *tbates*

Created *08/13/2009 - 18:07*

Thu, 08/13/2009 - 18:07 — tbates [1]

Hi, I was wanting to get the diagonal of an openmx output matrix and tried "diag()" as shown below with the matrix.

Question: should (can?) we overload "standard" R functions, or is there to be an mxDiag() equivalent?

If the latter, it would be nice if where possible it worked (to parameters) as the {base} library functions do.

I guess that it would be VERY helpful if code like

a = mxRun(factorModel) round(diag(a$S), 2) # worked, i.e, output a matrix rounded to 2 decimal places

> diag(a$S) Error in y[1L + 0L:(m - 1L) * (n + 1L)] <- x : incompatible types (from S4 to double) in subassignment type fix > a$S SymmMatrix 'S' Labels matrix: No labels assigned. Values matrix: [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.04081422 0.00000000 0.0000000 0.00000000 0.00000000 0 [2,] 0.00000000 0.03802001 0.0000000 0.00000000 0.00000000 0 [3,] 0.00000000 0.00000000 0.0408272 0.00000000 0.00000000 0 [4,] 0.00000000 0.00000000 0.0000000 0.03938708 0.00000000 0 [5,] 0.00000000 0.00000000 0.0000000 0.00000000 0.03628711 0 [6,] 0.00000000 0.00000000 0.0000000 0.00000000 0.00000000 1

**Links:**

[1] http://openmx.psyc.virginia.edu/users/tbates

[2] http://openmx.psyc.virginia.edu/thread/39-can-model-contain-free-parameter-and-fixed-parameter-same-name

[3] http://openmx.psyc.virginia.edu/thread/58-provide-warning-when-data-includes-variables-which-are-not-modeled

[4] http://openmx.psyc.virginia.edu/forums/openmx-developer-forums/r-functions-and-user-interface