[R-sig-ME] Simulatig data for mixed-effects model with predefined parameter
bl@zej@mrozin@ki @ending from gm@il@com
Wed Aug 22 13:27:56 CEST 2018
Good morning group,
yesterday I posted a question on simulating mixed-effects data set at
and Ben Bolker was kind enough to give me a solution, that for some reason
is not working.
If you don't mind I would like to keep this post here as well, as there are
some unsolved issues and questions that are not suitable for SO commenting
To sum up:
I'm trying to simulate data sets following some strict parameters.
For a simple example, for a given nSubjects and nObs I'd like to get a
two-level repeated-measure data, where a continuous level-2 predictor
predicts a continuous level-1 outcome, eg. happiness ~ self-esteem + (1 |
subject), where self-esteem is measured across subjects, and happiness
across occasions (e.g. days) within each subject. The catch here is, I'd
like to define in advance the random variance ratio - for example: given an
unconditional model happiness ~ 1 + (1|subject) the ratio of between
subject variance to within subjcet variance is 50 / 50 (or any other of my
If the above is possible I would like to know how to extend the simplest
model to one that includes predictors at both levels of measurement (e.g.
self-esteem at subject level, daily stress at observation level) with a
possibility to control variance ratios beforehand.
I would really appreciate some help here.
Ben's solution (https://stackoverflow.com/a/51940024/6925293) looks very
elegant but it doesnt work on my end ( Error in setParams(object,
newparams) : length mismatch in beta (2!=3) ) and I'm not entirely sure how
I can control parameters.
Please note that I'm comfortable with greek equations as long as they don't
go two far (e.g I know whats going on here: https://i.imgur.com/A37oAok.png
PhD candidate at University of Social Sciences and Humanities in Warsaw,
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models