# NOT RUN {
## 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)
## 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 <- "yi ~~ tau2*yi
yi ~ mu*1"
RAM <- lavaan2RAM(model, obs.variables=c("yi"))
## Create a v-known matrix
Vmatrix <- as.mxMatrix("0*data.vi", name="Vmatrix")
my.fit <- create.mxModel(RAM=RAM, Vmatrix=Vmatrix, data=Hox02)
summary(my.fit)
# }
Run the code above in your browser using DataLab