Hi,
The number of higher level observations are not correct when comparing Mlwin and R2mlwin output.
Mlwin (in debug mode): 26 cases
R2mlwin in subsequent output:66 cases
Is there a quick fix for this?
Thanks
Adel
PS: tried to attach images but uploads fail for some reason...
The number of higher level observations are not correct
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: The number of higher level observations are not correct
I haven't seen this before, can you provide more information about the model structure? If you can replicate the problem with one of the sample data files then this would help me track down the problem.
Re: The number of higher level observations are not correct
Sure:
# load tutorial
demo(MCMCGuide03)
# Read tutorial data
data(tutorial, package = "R2MLwiN")
# The highest level comes first, then the second highest and so on
(mymodel1 <- runMLwiN(normexam ~ 1 + standlrt + (1 | school) + (1 | student), estoptions = list(EstM = 0), data = tutorial))
summary(mymodel1)
# check data
summary(tutorial) # standlrt has no missing; create some missing
# set a complete school to standlrt = NA
tutorial1 <- tutorial
tutorial1$standlrt1 <- ifelse(tutorial1$school == 65, NA, tutorial1$standlrt)
# should give 64 schools
(mymodel2 <- runMLwiN(normexam ~ 1 + standlrt1 + (1 | school) + (1 | student),
estoptions = list(EstM = 0), data = tutorial1))
summary(tutorial2)
# ==> shows 65
# check hierarchy viewer in debugg mode
(mymodel2 <- runMLwiN(normexam ~ 1 + standlrt1 + (1 | school) + (1 | student),
estoptions = list(EstM = 0, debugmode=T), data = tutorial1))
# ==> hierarchy viewer shows 64 schools!
# Hence, the R2mlwin output about valid higher level cases is wrong
# load tutorial
demo(MCMCGuide03)
# Read tutorial data
data(tutorial, package = "R2MLwiN")
# The highest level comes first, then the second highest and so on
(mymodel1 <- runMLwiN(normexam ~ 1 + standlrt + (1 | school) + (1 | student), estoptions = list(EstM = 0), data = tutorial))
summary(mymodel1)
# check data
summary(tutorial) # standlrt has no missing; create some missing
# set a complete school to standlrt = NA
tutorial1 <- tutorial
tutorial1$standlrt1 <- ifelse(tutorial1$school == 65, NA, tutorial1$standlrt)
# should give 64 schools
(mymodel2 <- runMLwiN(normexam ~ 1 + standlrt1 + (1 | school) + (1 | student),
estoptions = list(EstM = 0), data = tutorial1))
summary(tutorial2)
# ==> shows 65
# check hierarchy viewer in debugg mode
(mymodel2 <- runMLwiN(normexam ~ 1 + standlrt1 + (1 | school) + (1 | student),
estoptions = list(EstM = 0, debugmode=T), data = tutorial1))
# ==> hierarchy viewer shows 64 schools!
# Hence, the R2mlwin output about valid higher level cases is wrong
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: The number of higher level observations are not correct
Thanks for this example, there were a couple of bugs here:
- The cross-classification flag was not being checked correctly, so it was assuming that the IDs were unique across all groups.
- Unused factors were not being dropped after reducing the data to complete cases. This meant that although you made school 65 completely missing there was still a factor label associated with it after the records had been dropped.
Re: The number of higher level observations are not correct
Thanks very much for the prompt fix, Chris.
I will install the development version asap.
I will install the development version asap.