Skip to content

R questions

3 messages · Iasonas Lamprianou, Gavin Simpson, John Maindonald

#
Dear friends, 

in this web page http://cran.r-project.org/src/contrib/Views/Psychometrics.html, I read: A multilevel Rasch model can be estimated using the package lme4 with functions for mixed-effects models with crossed or partially crossed random effects. How can this be done? Is there an example to read?

Also, why are the random effects (BLUPS  usinf the ranef fucnction) and the fixed effects estimates the same most pf the time?

Thanks

jason
 
Dr. Iasonas Lamprianou
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044 161 275 3485
iasonas.lamprianou at manchester.ac.uk


----- Original Message ----
From: "r-sig-mixed-models-request at r-project.org" <r-sig-mixed-models-request at r-project.org>
To: r-sig-mixed-models at r-project.org
Sent: Thursday, 2 August, 2007 1:00:22 PM
Subject: R-sig-mixed-models Digest, Vol 8, Issue 1


Send R-sig-mixed-models mailing list submissions to
    r-sig-mixed-models at r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
    https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
or, via email, send a message with subject or body 'help' to
    r-sig-mixed-models-request at r-project.org

You can reach the person managing the list at
    r-sig-mixed-models-owner at r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-mixed-models digest..."


Today's Topics:

   1. simulate() fails for poisson lmer fits (William Valdar)
   2. Re: simulate() fails for poisson lmer fits (William Valdar)


----------------------------------------------------------------------

Message: 1
Date: Wed, 1 Aug 2007 18:49:58 +0100 (BST)
From: William Valdar <valdar at well.ox.ac.uk>
Subject: [R-sig-ME] simulate() fails for poisson lmer fits
To: R-SIG-Mixed-Models <r-sig-mixed-models at r-project.org>
Message-ID: <Pine.LNX.4.64.0708011822100.8824 at zeon.well.ox.ac.uk>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

Hello,

I wish to simulate() from a fitted Poisson GLMM. Both lmer() and lmer2() 
from lme4 (version info at the bottom) fail, apparently due to bugs. 
Here's a test case:

counts <- data.frame(
         count  = c(8, 3, 0, 3, 0, 9, 0, 11, 4, 7, 0, 0, 0, 4, 3, 6, 3,
                 15, 11, 9),
         batch = c(3.1, 3.1, 3.1, 3.3, 3.3, 3.3, 3.2, 3.12, 3.8, 3.11,
                 3.4, 3.4, 3.4, 3.4, 3.5, 3.5, 3.5, 3.5, 3.6, 3.6),
         weight = c(324.4, 372.5, 352.7, 379.6, 388.1, 431, 448.4, 377.3,
                 376.5, 358.4, 356, 351.4, 350.8, 332.1, 334.5, 392, 370.5,
                 409.7, 375, 318.5))

fit <- lmer(count ~ weight + (1|batch),  family=poisson, data=counts)
# Error: inherits(object, "lmer") is not TRUE

fit <- lmer2(count ~ weight + (1|batch),  family=poisson, data=counts)
simulate(fit)
# CHOLMOD error: X and/or Y have wrong dimensions
# Error in crossprod(object at ZXyt, c(unlist(lapply(seq_along(re), 
# function(k) (t(cholL[[k]]) %*%  :
#        Cholmod error 'X and/or Y have wrong dimensions' at 
# file:../MatrixOps/cholmod_sdmult.c, line 90

Is there a quick fix for either of these two? Otherwise, is there an 
alternative (I've checked objects produced by nlme, glmmPQL, GLMMGibbs 
with no luck)? I am using lme4 0.99875-6 version R 2.5.1 on Windows XP.

Many thanks,

Will

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dr William Valdar               ++44 (0)1865 287 589
Wellcome Trust Centre           valdar at well.ox.ac.uk
for Human Genetics, Oxford      www.well.ox.ac.uk/~valdar



------------------------------

Message: 2
Date: Thu, 2 Aug 2007 00:23:07 +0100 (BST)
From: William Valdar <valdar at well.ox.ac.uk>
Subject: Re: [R-sig-ME] simulate() fails for poisson lmer fits
To: R-SIG-Mixed-Models <r-sig-mixed-models at r-project.org>
Message-ID: <Pine.LNX.4.64.0708020021210.7087 at zeon.well.ox.ac.uk>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed


I missed out a line in the code below. The line that throws the error is 
not the fitting but the subsequent simulation, ie:

fit <- lmer(count ~ weight + (1|batch),  family=poisson, data=counts)
simulate(fit)
# Error: inherits(object, "lmer") is not TRUE
On Wed, 1 Aug 2007, William Valdar wrote:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dr William Valdar               ++44 (0)1865 287 589
Wellcome Trust Centre           valdar at well.ox.ac.uk
for Human Genetics, Oxford      www.well.ox.ac.uk/~valdar



------------------------------

_______________________________________________
R-sig-mixed-models mailing list
R-sig-mixed-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models


End of R-sig-mixed-models Digest, Vol 8, Issue 1
************************************************


      ___________________________________________________________
#
On Fri, 2007-08-03 at 00:46 -0700, Iasonas Lamprianou wrote:
You might take a look at Doran et al (2006; Vol 20 issue 2 of the
Journal Of Statistical Software - link below), which discusses Rasch
models with lme4.

http://www.jstatsoft.org/index.php?vol=20

HTH

G
<snip />
#
Whether or not the BLUPs are very similar to the means depends
on the relative magnitudes of the relevant components of variance.
Try the following code (from p.309 of the 2nd edn of my book with
John Braun):

ant111b.lmer <- lmer(harvwt ~ 1 + (1 | site), data=ant111b)
options(digits=4)

ant111b.lmer

##           Fitted values and residuals in \texttt{lmer()}
s2W <- 0.578; s2L <- 2.37; n <- 4
sitemeans <- with(ant111b, sapply(split(harvwt, site), mean))
grandmean <- mean(sitemeans)
shrinkage <- (n*s2L)/(n*s2L+s2W)
grandmean + shrinkage*(sitemeans - grandmean)
##
## More directly, use fitted() with the lmer object
unique(fitted(ant111b.lmer))
##
## Compare with site means
sitemeans


John Maindonald             email: john.maindonald at anu.edu.au
phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
On 3 Aug 2007, at 5:46 PM, Iasonas Lamprianou wrote: