jslefche / piecewiseSEM

Piecewise Structural Equation Modeling in R
152 stars 48 forks source link

standardized coefficients not returned when using glmmTMB model #281

Open eimichae85 opened 1 year ago

eimichae85 commented 1 year ago

Hello, I would like to include a beta-regression model (using glmmTMB) via the piecewiseSEM package. The model looks like this:

mod_sel_herbtot<-modCOMBO<-glmmTMB(branch_av_Herbtot~ N_pc+Year+Stratum+(1|Tree.ID),
                                      data=data, family=beta_family(link = "logit"),na.action=na.fail)

I want to conduct a SEM using my beta regression model above and several regular "lmer" models (i.e. mod1x, mod2x etc.)

newlist = list(
  mod_sel_herbtot,mod1x, mod2x, mod3x,mod4ax,mod4bx,mod5ax,mod5bx)
modTot<-as.psem(newlist)
SEM_beta_Herbtot<-summary(modTot, .progressBar = F)

However, when running the as.psem I get the following warning:

Warning messages: 1: In GetSDy(i, newdata, standardize, standardize.type) : Family or link function not supported: standardized coefficients not returned

As a consequence I do not get any standardized coefficients for my beta regression model. Is there a work-around solution to fix the problem with the "link function"?

thanks a lot!

jslefche commented 1 year ago

Hi, gamma distributions are not yet supported. You may investigate whether any distribution specific variance exists & incorporate that into the calculations of SD for the response, following Grace et al 2018. HTH, Jon


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 31, 2023 4:00 AM To: @.> Cc: @.***> Subject: [jslefche/piecewiseSEM] standardized coefficients not returned when using glmmTMB model (Issue #281)

External Email - Exercise Caution

Hello, I would like to include a beta-regression model (using glmmTMB) via the piecewiseSEM package. The model looks like this:

mod_sel_herbtot<-modCOMBO<-glmmTMB(branch_av_Herbtot~ N_pc+Year+Stratum+(1|Tree.ID),

                                  data=data, family=beta_family(link = "logit"),na.action=na.fail)

I want to conduct a SEM using my beta regression model above and several regular "lmer" models (i.e. mod1x, mod2x etc.)

newlist = list(

mod_sel_herbtot,mod1x, mod2x, mod3x,mod4ax,mod4bx,mod5ax,mod5bx)

modTot<-as.psem(newlist)

SEM_beta_Herbtot<-summary(modTot, .progressBar = F)

However, when running the as.psem I get the following warning:

Warning messages: 1: In GetSDy(i, newdata, standardize, standardize.type) : Family or link function not supported: standardized coefficients not returned

As a consequence I do not get any standardized coefficients for my beta regression model. Is there a work-around solution to fix the problem with the "link function"?

thanks a lot!

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjslefche%2FpiecewiseSEM%2Fissues%2F281&data=05%7C01%7Clefcheckj%40si.edu%7Cb8d76dd45a5a47c161e108db31be047d%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638158464444578795%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=90mRH%2BFoLaRc1ilYG4F0X0OZQ1cqNrFVVCyiFF1LX%2BM%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAR4AV73PNQX2PNZJDIOOZDW62FKNANCNFSM6AAAAAAWOJXFWU&data=05%7C01%7Clefcheckj%40si.edu%7Cb8d76dd45a5a47c161e108db31be047d%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638158464444578795%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=M%2BKIWDWzDCA22pJV98W46fBufTRSG7HvodkjnuDD%2FKU%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>

eimichae85 commented 1 year ago

Hi, Thanks for your swift reply. Just to make sure I am understanding you correctly and we are on the same page (I am not a statistician)

My response variable contains values between 0 and 1 (proportions of leaf damage). Hence I used a beta-regression model. In the "piecewise" package description it says "glmmTMB" models are supported. But it does not work in my case since I use a beta-regression model (gamma distribution)? Right?

My goal is to end up with standardized estimates for all my model paths (including also variables from a beta-regression model). While I get standadize estimate values for model paths of LMM models I do not get any standardized estimates for model paths that include variables from my beta-regression models (see picture below, the first 3 lines are model paths that include beta-regression model variables)

Capture

If I understood you correctly I have to find a way to compare the unstandardized estimates (i.e. standardize them manually). You suggested to have a look at the paper by Grace et al 2018 (Ecosphere): https://doi.org/10.1002/ecs2.2283 Unfortunately, it seems that the paper is not adressing beta-regression models and I struggle quite a bit when it comes to applying the Grace et al approach to my models. From my understaning I have to take the SD of the link-transformed response and incoroporate the distribution specific variance but I am not exactly sure how to do that. Is there an alternative way? Did other people deal with this issue by just using a LMM ( less-optimal model ) as it is supported by piecewiseSEM?

Thanks a lot for your help Michael

jslefche commented 1 year ago

glmmTMB is the model fitting function, but can accommodate a range of distributions, some of which are supported (poisson, binomial, etc.) and some of which are not yet (gamma). Apologies for this

Here is the paper: https://esajournals.onlinelibrary.wiley.com/doi/full/10.1002/ecs2.2283


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 31, 2023 1:12 PM To: @.> Cc: Lefcheck, @.>; @.> Subject: Re: [jslefche/piecewiseSEM] standardized coefficients not returned when using glmmTMB model (Issue #281)

External Email - Exercise Caution

Hi, Thanks for your swift reply.

Just to make sure I am understanding you correctly ( I am new to beta-regression models and piecewiseSEM so please exucse this question): Is is just beta-regressions (gamma distriution models) that are not supported in the piecewise package? I am a bit confused since the PDF that describes the piecewise package says " glmmTMB" models are supported (I am using glmmTMB for my beta regression). I am not a statistician so I was hoping that there might be "easy" work-around solution for the "logit-link " problem. I can't be the first one that is using piecewiseSEM for beta-regression models (or am I?)

Also what paper Grace et al. 2018 paper are your referring to. A google scholar search did not result in any meaningful results

Thanks a lot for your help

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjslefche%2FpiecewiseSEM%2Fissues%2F281%23issuecomment-1492289662&data=05%7C01%7Clefcheckj%40si.edu%7C1082311a01474513c97408db320b13ba%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638158795379230279%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4ZO5bCoIRw42UWkwvSOVkS58OFOteYYceClzfkcyGCc%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAR4AV6BMYE6I7ZS735RUNTW64F67ANCNFSM6AAAAAAWOJXFWU&data=05%7C01%7Clefcheckj%40si.edu%7C1082311a01474513c97408db320b13ba%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C638158795379230279%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=J5thGWAVB2atjXp2GwqdKE18WXXsfXHfEodmlPHkY0Q%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

eimichae85 commented 1 year ago

Ok that is good to know. Too bad GAMs are so tricky. Thank you very much for replying so swiftly!

graco-roza commented 1 year ago

Hi, I came across this post and noticed that you mentioned the lack of support for gamma distributions. However, the original question was about using a beta distribution, and I couldn't find a clear connection between the two.

Could you please clarify the rationale or context behind mentioning the gamma distribution in relation to the acceptance or non-acceptance of the beta distribution? I would greatly appreciate any insights you can provide to help me better understand this topic.

Thank you for your assistance!

luroy commented 2 months ago

Hello @eimichae85 By any chance, have you found a solution for obtaining standardized coefficients from a beta regression? Kind regards, Léa