Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More random effects #8

Open
Yansen0515 opened this issue Nov 23, 2022 · 5 comments
Open

More random effects #8

Yansen0515 opened this issue Nov 23, 2022 · 5 comments

Comments

@Yansen0515
Copy link

Hi Debiel E. Runcie,
My model consists of three random effects. Does your algorithm support more randoms effects?
According to my check, only two random effects, genetic and residual, can be included in the model.
I'm not sure my view is correct, maybe I'm missing something.
So please reply me.

Kind Regards,
Yansen

@deruncie
Copy link
Owner

Hi Yansen,

Yes, you can by specifying a model like ~(1|Family) + (1|ID) + .... Each (1|X) term specifies a random effect with group X. Each random effect can be linked to a covariance matrix with the relmat argument (relmat = list(Family = K_fam, ID = K_ID)). If you want two random effects both at the ID level but with different covariance matrices, you have to create duplicate ID columns in your data (ID1, ID2,...), and then each can be linked to its own relmat matrix.

However, a warning - each additional random effect you include will make the memory and computation increase exponentially. The model forms a grid with run_parameters$h2_divisions points per random effect, so if the grid has size 20, it'll work with 20 levels for 1 random effect, but 8,000 with 3 random effects. You can use the function: estimate_memory_initialization_MegaLMM(MegaLMM_state) to estimate the memory requirements before calling initialize_MegaLMM(MegaLMM_state,verbose = T) to make sure your system can handle it.

Finally, depending on your model, you may be able to specify it in such a way that you get additional random effects as columns of your data instead which is much more efficient.

Dan

@Yansen0515
Copy link
Author

Hi Dan,
Thank you for your reply. You are right, the two random effects (except residual) both at the ID level but with different covariance matrices.
My model is a repeatability model. I have three random effects, which are additive genetic (AG, link to ID), permanent environment (PE, also link to ID, cope to duplicate_ID), and residual.
So I will use the "relmat= list(AG=ID, PE=duplicate_ID)".

Thanks again,
Yansen

@deruncie
Copy link
Owner

Are AG and PE both covariance matrices with #rows and #columns equal to the number of levels of ID? If so you'd want to switch around the arguments: formula = ~(1|ID) + (1|duplicate_ID),relmat = list(ID = AG, duplicate_ID = PE)

@Yansen0515
Copy link
Author

Hi Dan,
Not yet. Only the covariance matrices of "AG" with rows and columns equal the number of levels of ID. The covariance matrices of "PE" with rows and columns equal the number of records and levels of ID, respectively.
So, I don't know how to set such parameters.

Yansen

@Yansen0515
Copy link
Author

Hi Daniel,
Sorry, your explanation is correct. I misunderstood.
Thank you very much for your help.

Kind regards,
Yansen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants