| | Grouping ||
| First Header | Second Header | Third Header |
|---|---|---|
| Content | Long Cell | |
| Content | Cell | Cell |
| New section | More | Data | | And more | And more || [ Table Caption ]
| | Grouping ||
| First Header | Second Header | Third Header |
|---|---|---|
| Content | Long Cell | |
| Content | Cell | Cell |
| New section | More | Data | | And more | And more || [ Table Caption ]
| # umxRun now detects raw RAM, and runs sat and ind. worth speeding this bit up a bit? | |
| m3 <- mxModel("independence", | |
| # TODO: slightly inefficient, as this has an analytic solution | |
| mxMatrix(name = "variableLoadings" , type="Diag", nrow = nVar, ncol = nVar, free=T, values = independenceStarts), | |
| # labels = loadingsLabels), | |
| mxAlgebra(name = "expCov", expression = variableLoadings %*% t(variableLoadings)), | |
| mxMatrix(name = "expMean", type = "Full", nrow = 1, ncol = nVar, values = dataMeans, free = T, labels = meansLabels), | |
| mxFIMLObjective(covariance = "expCov", means = "expMean", dimnames = manifests), | |
| mxData(theData, type = "raw") | |
| ) |
| # Things you should learn in school: Be able to answer any question of the form: | |
| # "Which has more gravitational pull on a baby as it is born: the midwife, or the planet Jupiter?" | |
| # baby ~ 5 kg | |
| # Distance and mass of [Jupiter](http://en.wikipedia.org/wiki/Jupiter) | |
| gravitationalAttraction <- function(G = 6.674E-11, m1, m2, r){ | |
| # G = 6.674E-11 # [Gravitational constant](http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation): N m^2 kg^-2 | |
| G * (m1 * m2)/r^2 | |
| } |
| # mixture distribution.. | |
| n = 100000; | |
| distOne = rnorm(n, 50, 10) | |
| distTwo = rnorm(n, 120, 15) | |
| x = c(distOne,distTwo) | |
| hist(x) | |
| psych::kurtosi(x);psych::skew(x); | |
| # DV <- sum of unobserved IVs | |
| x = distOne + distTwo |
| # Generate a 25-item test | |
| nItems = 25 | |
| nOptions = 4 | |
| passCriterion = 3 # or better | |
| correct_answers = sample(c(1:nOptions), nItems, replace = TRUE) | |
| # =================================== | |
| # = Generate 10000 random responses = | |
| # =================================== |
| # http://openmx.psyc.virginia.edu/getOpenMx.R | |
| # run this as | |
| # source_gist(11294078) | |
| if (.Platform$OS.type == "windows") { | |
| if (!is.null(.Platform$r_arch) && .Platform$r_arch == "x64") { | |
| repos <- c('http://openmx.psyc.virginia.edu/packages/') | |
| } else { | |
| repos <- c('http://openmx.psyc.virginia.edu/32bit/') | |
| } | |
| install.packages(pkgs = c('OpenMx'), repos = repos) |
| # http://openmx.psyc.virginia.edu/getOpenMxBeta.R | |
| if(version$major < 3) { | |
| stop("We don't have beta for R 2.15 or below. Consider upgrading to R 3.1?\n | |
| You can get this from http://cran.r-project.org/") | |
| } | |
| if (.Platform$OS.type == "windows") { | |
| if (!is.null(.Platform$r_arch) && .Platform$r_arch == "x64") { | |
| repos <- c('http://openmx.psyc.virginia.edu/testing/') | |
| } else { |
| message("load me with devtools::source_gist('11326436')") |
| # R version 3.0.3 (2014-03-06) -- "Warm Puppy" | |
| source("http://openmx.psyc.virginia.edu/getOpenMxBeta.R") | |
| library("OpenMx") | |
| packageVersion("OpenMx") # [1] ‘999.0.0.3473’ | |
| data(demoOneFactor) | |
| manifests <- names(demoOneFactor) | |
| latents <- c("G") | |
| model <- mxModel(model="One Factor", type="RAM", |
| library(OpenMx) | |
| manifests = c("mpg", "disp", "gear") | |
| # ============================= | |
| # = simple independence model = | |
| # ============================= | |
| m1 <- mxModel("ind", type = "RAM", | |
| manifestVars = manifests, | |
| mxPath(from = manifests, arrows = 2), | |
| mxPath(from = "one", to = manifests), |