Open sinushelf opened 1 year ago
This usually reflects poor convergence, can you look at the variance components of your random effects? 2-4 observations within so many levels is not ideal, and may be leading to negative Chi-squared, which yields the error.
Jonathan S. Lefcheck, Ph.D. Tennenbaum Coordinating Scientist MarineGEO: https://marinegeo.si.edu/ Smithsonian Institution Phone: +1 (443) 482-2443 www.jonlefcheck.nethttp://www.jonlefcheck.net
From: @.> Sent: Thursday, March 23, 2023 9:50 AM To: @.> Cc: @.***> Subject: [jslefche/piecewiseSEM] Warning: log-likelihood estimates lead to negative Chi-squared (Issue #276)
External Email - Exercise Caution
Hi, I run a piecewise SEM with the package piecewiseSEM.
lmer(variable1 ~ variable2 + (1 | location), data) lm(variable2~ variable3, data) Because I had 18 different locations with 2 or 4 samples each, I specified location as random effect. In total I have 52 samples.
In this model the warning message "Check model convergence: log-likelihood estimates lead to negative Chi-squared!" appeared. And I get "Chi-Squared = NA with P-value = NA and on 1 degrees of freedom". How can I handle this?
Thanks!
— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjslefche%2FpiecewiseSEM%2Fissues%2F276&data=05%7C01%7Clefcheckj%40si.edu%7Cb3f23abfa7a24fd444de08db2ba58e2b%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638151762277441023%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=D%2BSW6F8bY00%2BzZO3US0HwTj477FrvQ6VYOmG3wUKKGk%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAR4AV3TXP2KGR4OQWQPXNLW5RIKBANCNFSM6AAAAAAWFHKTUQ&data=05%7C01%7Clefcheckj%40si.edu%7Cb3f23abfa7a24fd444de08db2ba58e2b%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638151762277441023%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Pm%2BAHDRvprpef4qxBtuqAnHZDvrJTCOFB0tW2pSTL%2FI%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>
I don't know how to get the total variance out of psem(). These are only the variances from "lmer(variable1 ~ variable2 + (1 | location), data)": $var.fixed [1] 0.1582051 $var.random [1] 0.1519673 $var.residual [1] 0.6895046 $var.distribution [1] 0.6895046 $var.dispersion [1] 0
Try running VarCorr
on your lmer object, and that will tell you the variance/SD associated with the random effects. See if any are close to zero. Another option is to try another optimizer with lmerControl =
argument
HTH
Jonathan S. Lefcheck, Ph.D. Tennenbaum Coordinating Scientist MarineGEO: https://marinegeo.si.edu/ Smithsonian Institution Phone: +1 (443) 482-2443 www.jonlefcheck.nethttp://www.jonlefcheck.net
From: @.> Sent: Friday, March 24, 2023 3:14 AM To: @.> Cc: Lefcheck, @.>; @.> Subject: Re: [jslefche/piecewiseSEM] Warning: log-likelihood estimates lead to negative Chi-squared (Issue #276)
External Email - Exercise Caution
I don't know how to get the total variance out of psem(). These are only the variances from "lmer(variable1 ~ variable2 + (1 | location), data)": $var.fixed [1] 0.1582051 $var.random [1] 0.1519673 $var.residual [1] 0.6895046 $var.distribution [1] 0.6895046 $var.dispersion [1] 0
— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjslefche%2FpiecewiseSEM%2Fissues%2F276%23issuecomment-1482357313&data=05%7C01%7Clefcheckj%40si.edu%7C0ff407b5e9014318f60608db2c375b41%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638152388523866576%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HVml%2BYyDEaqT5kpSNiKop3eUzQXpymIdumEHkX%2BUcos%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAR4AV3BMLV6RXKJ4H5JR6LW5VCT5ANCNFSM6AAAAAAWFHKTUQ&data=05%7C01%7Clefcheckj%40si.edu%7C0ff407b5e9014318f60608db2c375b41%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638152388523866576%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1jDAp2RFiRTlCF9wIYNls5YlpOa%2BbHmQ7fkHS1FTHYc%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>
Try using glmmTMB
…it has different optimizers, and has solved the issue in the past
Jonathan S. Lefcheck, Ph.D. Tennenbaum Coordinating Scientist MarineGEO: https://marinegeo.si.edu/ Smithsonian Institution Phone: +1 (443) 482-2443 www.jonlefcheck.nethttp://www.jonlefcheck.net
From: @.> Sent: Thursday, March 30, 2023 4:53 AM To: @.> Cc: Lefcheck, @.>; @.> Subject: Re: [jslefche/piecewiseSEM] Warning: log-likelihood estimates lead to negative Chi-squared (Issue #276)
External Email - Exercise Caution
Thanks for your help. Both values are close to zero using VarCorr (location: 0.39, Residual: 0.83). Can you give me some advice on how to deal with this? Is lmer() possibly not the right choice for my data? (I do not get the warning message "Check model convergence: log-likelihood estimates lead to negative Chi-squared!" if I dont scale my data using scale.)
— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjslefche%2FpiecewiseSEM%2Fissues%2F276%23issuecomment-1489937534&data=05%7C01%7Clefcheckj%40si.edu%7Cd6aa176568b64ab5c52208db30fc4ac9%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638157632390527971%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bL288vHyGcAntdKmvBhqBUUHTv%2FSODwgG%2F7ZF8tqJD4%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAR4AV75DS74AEV5IKX552TW6VC2FANCNFSM6AAAAAAWFHKTUQ&data=05%7C01%7Clefcheckj%40si.edu%7Cd6aa176568b64ab5c52208db30fc4ac9%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638157632390527971%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fTkHGhV57ezbAa5vs5dJuPKrkZ4vO2VZxUXKPnEezA4%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>
I will try to solve the problem with different optimizers. Thank you for your help!
Hello teacher, I recently came across the same issue.
Could you tell me how it was handled? My Fisher's C = 14.305 with P-value = 0.282, that is okay, but Warning message: Check model convergence: log-likelihood estimates lead to negative Chi-squared.
And I try to solve the problem with different optimizers, but Error in fitTMB(TMBStruc) : negative log-likelihood is NaN at starting parameter values.
Hello, the calculations for Fisher's C are valid and you can infer that your model adequately reproduces your data (i.e., there are no missing relationships as suggested by the tests of directed separation). However, the log-likelihoods arising from these models complicate the calculation of the Chi-squared statistic, generating the warning. In this case, it is advisable to report Fisher's C only. HTH, Jon
Jonathan Lefcheck, Ph.D.
Research Scientist
Integration and Application Network
University of Maryland Center for Environmental Science
www.jonlefcheck.nethttp://www.jonlefcheck.net
From: EDAIL @.> Sent: Sunday, January 28, 2024 9:47 AM To: jslefche/piecewiseSEM @.> Cc: Jon Lefcheck @.>; Comment @.> Subject: Re: [jslefche/piecewiseSEM] Warning: log-likelihood estimates lead to negative Chi-squared (Issue #276)
Hello teacher, I recently came across the same issue.
Could you tell me how it was handled? My Fisher's C = 14.305 with P-value = 0.282, that is okay, but Warning message: Check model convergence: log-likelihood estimates lead to negative Chi-squared.
And I try to solve the problem with different optimizers, but Error in fitTMB(TMBStruc) : negative log-likelihood is NaN at starting parameter values.
— Reply to this email directly, view it on GitHubhttps://www.google.com/url?q=https://github.com/jslefche/piecewiseSEM/issues/276%23issuecomment-1913621446&source=gmail-imap&ust=1707058028000000&usg=AOvVaw2cAC5CXsJdBcUcHGZwZpOZ, or unsubscribehttps://www.google.com/url?q=https://github.com/notifications/unsubscribe-auth/AAR4AV6AWHJQM4XSJEHENOLYQZQGXAVCNFSM6AAAAAAWFHKTUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGYZDCNBUGY&source=gmail-imap&ust=1707058028000000&usg=AOvVaw0dlutrhzpaEEYF0IdC78qU. You are receiving this because you commented.Message ID: @.***>
Very thanks you very much for your detailed explanation teacher!
Hi, I run a piecewise SEM with the package piecewiseSEM.
lmer(variable1 ~ variable2 + (1 | location), data) lm(variable2~ variable3, data) Because I had 18 different locations with 2 or 4 samples each, I specified location as random effect. In total I have 52 samples.
In this model the warning message "Check model convergence: log-likelihood estimates lead to negative Chi-squared!" appeared. And I get "Chi-Squared = NA with P-value = NA and on 1 degrees of freedom". How can I handle this?
Thanks!