# \donttest{
## 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)
# }
Run the code above in your browser using DataLab