# Slope in three way interaction

Hi,

I have a three way interaction in my brms fit model. I tried hypothesis function to calculate the slopes of biomass vs evenness in a given density and year. with fitted function I generated negative slopes of biomass and evenness, however, hypothesis function shows me positive slopes.

Could you tell me how can I get conditional slopes for three way interactions? two categorical and one continuous variables are present in my dataset.

``````biomass~Density+evenness+year,family=Gamma(link = "log")

hyp.biomass.2011.L<-hypothesis(bm.fit2, "0+DensityLow+evenness+DensityLow:evenness=0", re_formula=NA)

hyp.biomass.2014.L<-hypothesis(bm.fit2, "year2014+DensityLow+evenness:year2014+DensityLow:evenness:year2014=0", re_formula=NA)

hyp.biomass.2019.L<-hypothesis(bm.fit2, "year2019+DensityLow+evenness:year2019+DensityLow:evenness:year2019=0")
``````

I may be misunderstanding the code you have written, but if:

``````biomass~Density+evenness+year
``````

is your regression equation, I don’t think you have coded in the interaction. I think you would first want to look at the basic output if you do something like:

``````biomass ~ Density:evenness:year
``````

Hi,

Sorry for the misunderstanding. It should be

``````biomass~Density*evenness*year,family=Gamma(link = "log")

Shovon
``````

Ah, okay! If you are able to show the regression output that could also be helpful. Given that the link is log, is it possible that you are looking at the output and it has a negative coefficient, but that you need to transform it (exponentiate, as it is on the log scale), which would make it positive?

Note also that I think the hypothesis function in brms will give output that ranges from 0 to some positive number, because it is an evidence ratio for the hypothesis you give it and not a description of a slope https://www.rdocumentation.org/packages/brms/versions/2.13.5/topics/hypothesis.brmsfit

Again, apologies if it is something else you are doing/trying to do and I am misunderstanding!