Page 1 of 1

urgent

Posted: Sat Nov 17, 2018 10:27 pm
by awnudino
Hello, I have a problem with the output,i want to do on children nutritional status,i have three dependent continuous variables,haz,waz and whz,that i want to fit multivariate multilevel model using r2mlwin with r code. With level-1 variable correlation between the dependent,level 2 children,and level 3 as region,but it says ur covariance matrix is not positive definit.Many thanks.
My code is library(R2MLwiN)
# 1 Path to MLwiN executable
mlwin <- "C:\\Program Files (x86)\\MLwiN trial\\i386"

# 2 variables containing IDs
levID <- c("region", "childid")

# 3 Distribution to be modelled
D <- "Multivariate Normal"

# 4 Method of estimation (1 = MCMC)
estoptions <- list(EstM = 1)

# 5 The data file
indata <- cd
# 6 The model

f1 <- c(WHZ, HAZ, WAZ) ~ 1 + (1 | region) + (1 | childid)

mod1 <- runMLwiN(f1, data = cd, MLwiNPath = mlwin, D = D)
Am i right?
pls help me since its an urgent case i can send my data too!!!
And when i make region as level 1 variable it says its repeated generate unique id,but also i dont know how to generate the factor variable region!

Re: urgent

Posted: Mon Nov 19, 2018 3:05 pm
by ChrisCharlton
One possible cause of this is that you don't appear to have specified the level-1 identifier. You could do this as follows:

Code: Select all

# Generate a vector numbers 1..number of rows in the data
cd$id <- 1:nrow(cd)
and then adjust the model formula to include this:

Code: Select all

f1 <- c(WHZ, HAZ, WAZ) ~ 1 + (1 | region) + (1 | childid) + (1 | id)
You could also take a look at the models results fitted with (R)IGLS, as these are by default used as the starting values for MCMC, to see whether these look sensible. If not you could try specifying the starting values manually (see chapter 5 on http://www.bristol.ac.uk/cmm/software/r2mlwin/examples/).