View source: R/create.mxModel.R
create.mxModel | R Documentation |
It creates a mxModel from a RAM object.
create.mxModel(model.name="mxModel", RAM=NULL, data=NULL,
Cov=NULL, means=NULL, numObs,
intervals.type=c("z", "LB"), startvalues=NULL,
replace.constraints=FALSE, mxModel.Args=NULL,
run=TRUE, silent=TRUE, ...)
model.name |
A string for the model name in |
RAM |
A RAM object including a list of matrices of the model
returned from |
data |
A data frame or matrix of data. |
Cov |
A covariance matrix may also be used if |
means |
A named vector of means (options) if |
numObs |
If |
intervals.type |
Either |
startvalues |
A list of named starting values of the free parameters, e.g., list(a=1, b=2) |
replace.constraints |
Logical. If |
mxModel.Args |
A list of arguments passed to |
run |
Logical. If |
silent |
Logical. An argument is passed to either
|
... |
Further arguments will be passed to either
|
An object of class mxRAMmodel
when there are constraints with replace.constraints=TRUE
and intervals.type="LB"
, it returns an error because some parameters in the model are replaced with the new parameters in the constraints. However, the names of these new parameters are not captured in the CI object. Users are advised to use intervals.type="z"
before it is fixed.
Mike W.-L. Cheung <mikewlcheung@nus.edu.sg>
## Generate data
set.seed(100)
n <- 100
x <- rnorm(n)
y <- 0.5*x + rnorm(n, mean=0, sd=sqrt(1-0.5^2))
my.df <- data.frame(y=y, x=x)
## A regression model
model <- "y ~ x # Regress y on x
y ~ 1 # Intercept of y
x ~ 1 # Mean of x"
plot(model)
RAM <- lavaan2RAM(model, obs.variables=c("y", "x"))
my.fit <- create.mxModel(RAM=RAM, data=my.df)
summary(my.fit)
## A meta-analysis
model <- "f =~ 1*yi
f ~ mu*1 ## Average effect
f ~~ tau2*f ## Heterogeneity variance
yi ~~ data.vi*yi ## Known sampling variance"
plot(model)
## Do not standardize the latent variable (f): std.lv=FALSE
RAM <- lavaan2RAM(model, obs.variables="yi", std.lv=FALSE)
## Use likelihood-based CI
my.fit <- create.mxModel(RAM=RAM, data=Hox02, intervals="LB")
summary(my.fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.