xmu_make_mxData: Upgrade a dataframe to an mxData type.

Description Usage Arguments Value See Also Examples

View source: R/xmu.R

Description

xmu_make_mxData is an internal function to upgrade a dataframe to mxData. It can also drop variables from the dataframe.

The most common use will be to give it a dataframe, and get back an mxData object of type raw, cov, cor (WLS is just raw).

Usage

1
2
3
4
5
6
7
xmu_make_mxData(
  data = NULL,
  type = c("Auto", "FIML", "cov", "cor", "WLS", "DWLS", "ULS"),
  manifests = NULL,
  numObs = NULL,
  verbose = FALSE
)

Arguments

data

A data.frame() or mxData()

type

What data type is wanted out c("Auto", "FIML", "cov", "cor", 'WLS', 'DWLS', 'ULS')

manifests

If set, only these variables will be retained.

numObs

Only needed if you pass in a cov/cor matrix wanting this to be upgraded to mxData

verbose

If verbose, report on columns kept and dropped (default FALSE)

Value

See Also

Other xmu internal not for end user: umxModel(), umxTwinMaker(), umx_APA_pval(), umx_fun_mean_sd(), umx_get_bracket_addresses(), umx_make(), umx_standardize(), umx_string_to_algebra(), umx, xmuDefBetasInTop(), xmuDefMeanInDataGroup(), xmuHasSquareBrackets(), xmuLabel_MATRIX_Model(), xmuLabel_Matrix(), xmuLabel_RAM_Model(), xmuMI(), xmuMakeDeviationThresholdsMatrices(), xmuMakeOneHeadedPathsFromPathList(), xmuMakeTwoHeadedPathsFromPathList(), xmuMaxLevels(), xmuMinLevels(), xmuPropagateLabels(), xmuRAM2Ordinal(), xmu_CI_merge(), xmu_CI_stash(), xmu_DF_to_mxData_TypeCov(), xmu_PadAndPruneForDefVars(), xmu_assemble_twin_supermodel(), xmu_cell_is_on(), xmu_check_levels_identical(), xmu_check_needs_means(), xmu_check_variance(), xmu_clean_label(), xmu_data_swap_a_block(), xmu_describe_data_WLS(), xmu_dot_make_paths(), xmu_dot_make_residuals(), xmu_dot_maker(), xmu_dot_move_ranks(), xmu_dot_rank_str(), xmu_get_CI(), xmu_lavaan_process_group(), xmu_make_TwinSuperModel(), xmu_make_bin_cont_pair_data(), xmu_make_top_twin(), xmu_match.arg(), xmu_name_from_lavaan_str(), xmu_path2twin(), xmu_path_regex(), xmu_safe_run_summary(), xmu_set_sep_from_suffix(), xmu_show_fit_or_comparison(), xmu_simplex_corner(), xmu_standardize_ACEcov(), xmu_standardize_ACEv(), xmu_standardize_ACE(), xmu_standardize_CP(), xmu_standardize_IP(), xmu_standardize_RAM(), xmu_standardize_SexLim(), xmu_standardize_Simplex(), xmu_start_value_list(), xmu_starts(), xmu_twin_check()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# =========================
# = Continuous ML example =
# =========================
manVars = c("mpg", "cyl", "disp")
tmp = xmu_make_mxData(data= mtcars, type = "Auto"); # class(tmp); # "MxDataStatic"
# names(tmp$observed) # "mpg"  "cyl"  "disp"
tmp = xmu_make_mxData(data= mtcars, type = "Auto", manifests = manVars); 
tmp$type == "raw" # TRUE

# ==============================
# = All continuous WLS example =
# ==============================
tmp = xmu_make_mxData(data= mtcars, type = "WLS" , manifests = manVars, verbose= TRUE)
tmp$type == "raw" # TRUE (WLS is triggered by the fit function, not the data type)

# ============================
# = Missing data WLS example =
# ============================
tmp = mtcars; tmp[1, "mpg"] = NA # add NA
tmp = xmu_make_mxData(data= tmp, type = "WLS", manifests = manVars, verbose= TRUE)

# ==========================
# = already mxData example =
# ==========================
m1 = umxRAM("auto", data = mxData(mtcars, type = "raw"),
umxPath(var= "wt"),
umxPath(mean=  "wt")
)

# ========================
# = Cov and cor examples =
# ========================
tmp = xmu_make_mxData(data= mtcars, type = "cov", manifests = c("mpg", "cyl"))
tmp = xmu_make_mxData(data= mtcars, type = "cor", manifests = c("mpg", "cyl"))
tmp = xmu_make_mxData(data= cov(mtcars[, c("mpg", "cyl")]), 
        type = "cov", manifests = c("mpg", "cyl"), numObs=200)

# mxData input examples
tmp = mxData(cov(mtcars[, c("mpg", "cyl")]), type = "cov", numObs= 100)
xmu_make_mxData(data= tmp, type = "cor", manifests = c("mpg", "cyl")) # consume mxData
xmu_make_mxData(data= tmp, type = "cor", manifests = c("mpg"))        # trim existing mxData
xmu_make_mxData(data= tmp, type = "cor") # no manifests specified (use all)
xmu_make_mxData(data= tmp, manifests = c("mpg", "cyl")) # auto

# =======================
# = Pass string through =
# =======================
xmu_make_mxData(data= c("a", "b", "c"), type = "Auto")

tbates/umx documentation built on March 30, 2020, 7:56 a.m.