I would like to generate data with the simsem package in R. So far, I've done this:
# create data with simsem package
## factor loadings
loading <- matrix(0, 7)
loading[1,1] <- NA
LY2 <- bind(loading, 1)
## residual correlation matrix
latent.cor <- matrix(NA, 1, 1)
diag(latent.cor) <- 1
RPS2 <- binds(latent.cor, 0.5)
# measurement error corr matrix
RTE2 <- binds(diag(7))
# total variance of indicators
VY2 <- bind(rep(NA,7),2)
CFA.Model2 <- model(LY = LY2, RPS = RPS2, RTE = RTE2, modelType = "CFA")
# generate data
dist <- bindDist("norm", list(mean = 4, sd = 1))
dat <- generate(CFA.Model2, n = 50, indDist = dist)
I was hoping to create item responses for 7 items that range from 1 to 5. The data that I create however looks like this:
head(dat, 4)
y1 y2 y3 y4 y5
1 -0.3042082 -0.009703124 0.070651822 1.9138537 -0.02754102
2 0.9574723 -1.691375825 0.441645186 -0.1770509 -0.35793280
3 -2.1808565 1.467395026 -0.350395973 -0.1660219 -0.42191898
4 -0.2367881 0.003594693 -0.002771362 -0.1323401 -1.44860960
y6 y7
1 -1.2557268 -1.52874138
2 -0.9963241 0.87807237
3 -1.7527848 0.31383091
4 1.2102580 0.03469505
How can I create data that ranges from 1 to 5? I would want the result to be the following:
head(dat, 4)
y1 y2 y3 y4 y5 y6 y7
1 3 5 3 5 5 5 5
2 5 5 5 5 5 3 5
3 3 4 1 2 2 2 4
4 5 4 1 2 4 5 4