If you don't specify the file in specifyModel
it will attempt to read from the standard input stream (stdin
) -- while this may be possible within knitr
I think it would be easier to read the model specifications in from a file.
For example
model <- readLines(con = textConnection('F1 -> X1, lam1, NA
F1 -> X2, lam2, NA
F1 -> X3, lam3, NA
F2 -> X4, lam4, NA
F2 -> X5, lam5, NA
F2 -> X6, lam6, NA
X1 <-> X1, e1, NA
X2 <-> X2, e2, NA
X3 <-> X3, e3, NA
X4 <-> X4, e4, NA
X5 <-> X5, e5, NA
X6 <-> X6, e6, NA
F1 <-> F1, NA, 1
F2 <-> F2, NA, 1
F1 <-> F2, F1F2, NA'))
cat(model, file = 'model.spec', sep = '\n')
model.mydata <- specifyModel(file = 'model.spec')
Alternatively you could simply create the model.spec
file and read it in.