-
Notifications
You must be signed in to change notification settings - Fork 37
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
Interaction term interpretation and prediction #147
Comments
You mean the prediction functions do not work at all with interaction covariates, or you are struggling to make them working in a manner that you want them to? Could you be a bit more specific? |
thanks for your quick answer, what I mean is that I am not sure how to interpret my beta parameter estimates and the beta plot when using an interaction term between 2 covariates. So I thought I will use the prediction function in the same way as in normal regression modelling but I tried to use the "constructGradient" function with the focal variable being the interaction covariate but it doesn't seem to work. I am not sure if the construct gradient is the best way to interpret interaction terms but I am just not sure about what other way will be the best... sorry if it is a very stupid question! thanks For example: set.seed(1)
n = 50
x = rnorm(n)
x2 = rnorm(n)
beta1 = 0
beta2 = 1
L = beta1 + beta2*x
y1 = L + rnorm(n, sd = 1)
Y = as.matrix(y1)
XData = data.frame(x = x, x2=x2)
m = Hmsc(Y = Y, XData = XData, XFormula = ~ x*x2)
nChains = 2
thin = 5
samples = 1000
transient = 500*thin
verbose = 500*thin
m = sampleMcmc(m, thin = thin, samples = samples,
transient = transient, nChains = nChains,
verbose = verbose)
Gradient = constructGradient(m, focalVariable = "x:x2") # where here I want to visualise the prediction of the interaction term. |
There is a clear reason for this. When you set variables to arbitrary values in model frame, the internally calculated variables should reflect these arbitrary values. That is, term You cannot inspect the interaction alone, and therefore your approach was doomed originally (even if some magic would make it work in There is an option of setting Numerical interactions terms can be difficult to interpret, but they may be the best choice in this case. |
OK, thanks for this! yes, I thought construct gradient was not the way to go but thought I will ask in case I missed something. I guess my question will be then how to interpret output from plot beta with my interaction term? I am guessing the plot beta here is irrelevant and the comparison method with a model without interaction term is maybe the way to go (as suggested above)? But then I still have the same issue of interpretation, if the model with interaction is different/"better" than the other model, then what is the explanation of this? For example, if my variables are "Distance to feature" and "Elevation" if my model with an interaction term between the two covariates fits better than the model without an interaction term, then how do I interpret the results of this model: with more distance, higher elevation or lower elevation, we detect fewer/more species? |
Hi,
Negative interaction term Distance:Management would mean that response to Management is more negative for large distance than for small distance. Note that it does not tell directly whether the response to Management is e.g. always positive or always negative, or sometimes positive and sometimes negative. That you would see from the main effects, but those can be interpreted from the beta-plot only if you have scaled the variables to zero mean before the analysis (the default scaling of Hmsc does not help with that). Probably the best way for examining those interactions is through some predictions where you e.g. put management to x-axis and distance to y-axis and plot the predictions as contour lines; or plot predictions over management gradient for small, intermediate and large distance (there is no ready functionality in Hmsc for doing these so would need some scripting by yourself).
Best,
O2
From: solenemarion ***@***.***>
Sent: keskiviikko 26. lokakuuta 2022 12:29
To: hmsc-r/HMSC ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [hmsc-r/HMSC] Interaction term interpretation and prediction (Issue #147)
I think my issue is more about the interpretation of the beta results itself because the interaction makes it hard to interpret. For example, that is one plot I got with interaction terms between multiple covariates. However, I am not sure what is the best interpretation of this result. For example, for the interaction term Distance:Management (mgt), I get a lot of negative responses but I am not sure how to interpret that: is it when both Distance and management increase that you do get not detection of species?
Thanks for the help
Solene
[image]<https://user-images.githubusercontent.com/46536657/197990069-6c805592-faea-4d1d-a6a2-43f849d24dd2.png>
—
Reply to this email directly, view it on GitHub<#147 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEIYMZWCNC5RWDMIR23ACQ3WFD2V3ANCNFSM6AAAAAARNFQCYY>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
|
Great thanks! That helps a lot. |
Hi there,
I am running an HMSC model with an interaction term between multiple covariates and I wonder if there is an easy way to interpret HMSC output for interaction? For example, I was not able to use the prediction functions for my interaction covariates.
Any suggestion?
Thanks
The text was updated successfully, but these errors were encountered: