[R-sig-ME] Force the random effects variances to be the same
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Fri May 13 20:00:20 CEST 2022
Doesn't lme4qtl allow nAGQ > 1 ?
https://github.com/variani/lme4qtl/blob/0c173ea8d8386b205f62ad642698519a861650b4/R/relmatGlmer.R#L22-L24
I can't quite see what your groups look like since HTML structure
gets thrown away by the mailing list ... is each of the random effect
scalar (i.e. variance among females, variance among males?)
Something *approximately* like
glmod <- glFormula(..., data = ..., family = binomial)
devfun <- do.call(mkGlmerDevfun, glmod)
opt <- optimizeGlmer(devfun)
devfun <- updateGlmerDevfun(devfun, glmod$reTrms)
(These first four steps are just repeating what's in ?lme4:modular))
At this point it gets slightly trickier.
Write a wrapper function that repeats the first element of the given
parameter vector, then passes it to devfun (in general the random
effects parameters are at the beginning of the parameter vector); the
parameter vector for this will be one shorter than the parameter for the
full model.
devfun2 <- function(p) {
devfun(c(p[1], p))
}
nfixed <- ## figure out the number of fixed-effect parameters
opt <- nloptwrap(par = c(opt$par[-1], rep(0, nfixed)), fn = devfun2,
lower = c(0, rep(-Inf, nfixed))
This should give you the answer, it might take a little more fussing
to put it back into a merMod object (something like):
opt$par <- c(opt$par[1], opt$par) ## augment parameter vector
mkMerMod(environment(devfun), opt, glmod$reTrms, fr = glmod$fr)
I'm not sure all of that is right, but it might be.
cheers
Ben Bolker
On 2022-05-13 3:36 a.m., Thierry Onkelinx via R-sig-mixed-models wrote:
> Why would you want to do that?
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkelinx using inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
> ///////////////////////////////////////////////////////////////////////////////////////////
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
> ///////////////////////////////////////////////////////////////////////////////////////////
>
> <https://www.inbo.be>
>
>
> Op do 12 mei 2022 om 23:29 schreef pluo244 using aucklanduni.ac.nz <
> pluo244 using aucklanduni.ac.nz>:
>
>> Hi,
>> I would like to use lme4::glmer to fit a model of the form
>> y ~ x + (0+m|group) + (0+f|group)
>>
>> where a group looks like
>> m f1 00 11/2 1/21/2 1/2
>> 1/2 1/2
>>
>> I was wondering if it is possible to force the variances of the random
>> effects to be the same?
>> Many thanks,Zoe
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
More information about the R-sig-mixed-models
mailing list