## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 5
)
library(umx)
library(OpenMx)
umx_set_auto_plot(FALSE)

## ----load_data, message=FALSE, warning=FALSE----------------------------------
# Load data
data(demoOneFactor)
manifests = names(demoOneFactor)

# Fit model
m1 = umxRAM("One_Factor_Model", data = demoOneFactor, 
	umxPath("g", to = manifests),
	umxPath(v.m. = manifests),
	umxPath(v1m0 = "g")
)

## ----summary_SE, message=FALSE------------------------------------------------
umxSummary(m1, std = TRUE, uncertainty = "SE")

## ----robust_Robust, message=FALSE---------------------------------------------
umxSummary(m1, std = TRUE, uncertainty = "MLR")

## ----imxRobust_se, message=FALSE----------------------------------------------
m1Robust = imxRobustSE(m1)

## ----compare_se, message=FALSE------------------------------------------------
stdSE = m1$output$standardErrors
compareSE = data.frame(
	Parameter = row.names(stdSE),
	Standard_ML_SE = round(as.numeric(stdSE), 4),
	Robust_SE = round(as.numeric(m1Robust), 4)
)
print(compareSE)

## ----profile_ci_specific, message = FALSE, warning = FALSE--------------------
m1CI = umxConfint(m1, parm = c("g_to_x1", "g_to_x2"), run = TRUE)
umxSummary(m1CI, uncertainty = "CI", refModels = FALSE)

