Skip to content

Instantly share code, notes, and snippets.

@tbates
Created August 22, 2014 15:02
Show Gist options
  • Save tbates/e9470ff83e233e6481c3 to your computer and use it in GitHub Desktop.
Save tbates/e9470ff83e233e6481c3 to your computer and use it in GitHub Desktop.
names are a hassle here
require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
m1 <- 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=FALSE, values=1.0),
mxData(cov(demoOneFactor), type="cov", numObs=500)
)
m2 = umxLabel(m1)
m1 <- mxRun(m1)
s1 <- summary(m1)$parameters
z1 <- mxStandardizeRAMpaths(m1)
merge(s1, z1, by = "name")
# name matrix.x row.x col.x Estimate Std.Error lbound ubound lboundMet uboundMet label matrix.y row.y col.y Raw.Value Std.Value Std.SE
# 1 One Factor.A[1,6] A x1 G 0.39715183 0.015549747 NA NA FALSE FALSE <NA> A x1 G 0.39715183 0.89130932 NA
# 2 One Factor.A[2,6] A x2 G 0.50366067 0.018232473 NA NA FALSE FALSE <NA> A x2 G 0.50366067 0.93255458 NA
# 3 One Factor.A[3,6] A x3 G 0.57724094 0.020448359 NA NA FALSE FALSE <NA> A x3 G 0.57724094 0.94384664 NA
# 4 One Factor.A[4,6] A x4 G 0.70277324 0.024011372 NA NA FALSE FALSE <NA> A x4 G 0.70277324 0.96236250 NA
# 5 One Factor.A[5,6] A x5 G 0.79624937 0.026669402 NA NA FALSE FALSE <NA> A x5 G 0.79624937 0.97255562 NA
# 6 One Factor.S[1,1] S x1 x1 0.04081418 0.002812716 NA NA FALSE FALSE <NA> S x1 x1 0.04081418 0.20556770 NA
# 7 One Factor.S[2,2] S x2 x2 0.03801997 0.002805790 NA NA FALSE FALSE <NA> S x2 x2 0.03801997 0.13034196 NA
# 8 One Factor.S[3,3] S x3 x3 0.04082716 0.003152305 NA NA FALSE FALSE <NA> S x3 x3 0.04082716 0.10915352 NA
# 9 One Factor.S[4,4] S x4 x4 0.03938701 0.003408869 NA NA FALSE FALSE <NA> S x4 x4 0.03938701 0.07385841 NA
# 10 One Factor.S[5,5] S x5 x5 0.03628708 0.003678556 NA NA FALSE FALSE <NA> S x5 x5 0.03628708 0.05413557 NA
m2 = umxLabel(m1); m2 <- mxRun(m2)
s2 <- summary(m2)$parameters
z2 <- mxStandardizeRAMpaths(m2)
merge(s2, z2, by="name")
# [1] name matrix.x row.x col.x Estimate Std.Error lbound ubound lboundMet uboundMet label matrix.y row.y col.y Raw.Value
# [16] Std.Value Std.SE
# <0 rows> (or 0-length row.names)
# >
@mhunter1
Copy link

merge(s2, z2, by=c("matrix", "row", "col"))

@mhunter1
Copy link

Even better

merge(s2, z2, by.x=c("matrix", "row", "col", "Estimate"), by.y=c("matrix", "row", "col", "Raw.Value"))

@tbates
Copy link
Author

tbates commented Aug 22, 2014

speedy gonzales :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment