Timeline for What are the steps to simulate data for a linear model with random slopes and random intercepts
Current License: CC BY-SA 4.0
19 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 21, 2020 at 7:18 | vote | accept | camhsdoc | ||
| Sep 20, 2020 at 21:00 | history | tweeted | twitter.com/StackStats/status/1307786623741026306 | ||
| Sep 20, 2020 at 20:25 | history | edited | Robert Long | edited tags | |
| Sep 20, 2020 at 18:35 | comment | added | Robert Long | @whuber Thanks for reopening. I've posted an answer. Hopefully it's what the OP is looking for, but I would be interested in your comments, if you have any ! | |
| Sep 20, 2020 at 18:30 | answer | added | Robert Long | timeline score: 16 | |
| Sep 20, 2020 at 15:28 | comment | added | Robert Long | @whuber ......basically the steps for a mixed model are to compute $X\beta$ as above, simulate some random effects $u$ based on the number of groups, their variances and covariances (some people find this a bit tricky), then form the model matrix $Z$ for the random effects (which is the very tricky part), then compute $Zu$ and add the residuals. I guess this kind of answers the question, but since they want to do it from scratch some details about how to form $Z$ when there are random slopes and random intercepts will need quite a lot of thought. | |
| Sep 20, 2020 at 15:23 | history | reopened | mdewey mkt Robert Long whuber♦ | ||
| Sep 20, 2020 at 15:20 | comment | added | Robert Long | @whuber I agree that the question could do with some more focus. I don't really see the list you quoted as steps though, I see them as parts of a fitted model. They need to take the parts and put them together, which requires statistical understanding. If it were a linear model they would specify a model matrix $X$, a fixed effects coefficient vector $\beta$, compute $X\beta$ then simulate the outcome by adding residuals drawn from some distribution. With a mixed model it's similar but the presence of the random effects makes it quite a bit harder to do from scratch... | |
| Sep 20, 2020 at 14:58 | comment | added | whuber♦ | @Robert Could you explain what might be missing from the steps listed in "specify the fixed effects, number of groups, sample size, variances of the random effects (and the correlation between them), and simulate a dataset accordingly"? That might help give this question some focus. | |
| Sep 20, 2020 at 13:11 | review | Reopen votes | |||
| Sep 20, 2020 at 15:23 | |||||
| Sep 20, 2020 at 12:51 | history | edited | camhsdoc | CC BY-SA 4.0 | Explaining that I needed to know the steps of how to do the simulation |
| Sep 20, 2020 at 12:48 | comment | added | camhsdoc | Yes this is correct. I don't know what the steps are for doing it. | |
| Sep 19, 2020 at 19:22 | comment | added | Robert Long | @whuber they appear to not know what the steps that you refer to are. They know about the components of a mixed model, but they don't seem to know how to formulate the steps. The steps are based on a statisitical understanding of mixed models, so it seems like a completely statistical question to me. I'm not sure how it is off topic ? | |
| Sep 19, 2020 at 14:01 | history | closed | whuber♦ | Not suitable for this site | |
| Sep 19, 2020 at 14:01 | comment | added | whuber♦ | Your question answers itself: you simply execute all the steps you list in R. For help with any particular step, work out the code and if it fails, post it on Stack Overflow with a description of what's going wrong and what you need it to do. | |
| Sep 19, 2020 at 12:42 | comment | added | camhsdoc | Yes I want to do it from scratch. I am using R if that is relevant. | |
| Sep 19, 2020 at 12:12 | comment | added | Robert Long | What do you mean by "do it myself" ? This kind of simulation needs a quite complicated design matrix for the random effects. Do you want to form that matrix by yourself or are you happy using a mixed model package to do that part for you ? If the former, then it's quite easy, but the latter you will be in a world of pain. | |
| Sep 19, 2020 at 9:26 | review | First posts | |||
| Sep 19, 2020 at 9:28 | |||||
| Sep 19, 2020 at 9:24 | history | asked | camhsdoc | CC BY-SA 4.0 |