leifeld / btergm

Temporal Exponential Random Graph Models by Bootstrapped Pseudolikelihood
16 stars 10 forks source link

Interaction Effect within TERGM - Investigating Homophily #32

Closed JohannaHeleneE closed 1 year ago

JohannaHeleneE commented 2 years ago

@leifeld In my bachelor thesis I use TERGM to investigate the influence of homophily on leadership tie formation within shared leadership. In addition, I would also like to investigate whether the effect of homophily on tie formation is also influenced by another variable. Usually when I add an interaction effect to TERGM, I would calculate the interaction of the two variables beforehand and then add them to the model with the following arguments "nodeocov("Interaction") + nodeicov("Interaction")".

Is it possible to calculate an interaction effect between the homophily argument ("nodematch()") speciefied within the TERGM model and a second independent variable? Or to create a variable out of the "nodematch()" argument that can be multiplied with another variable?

I hope my question makes sense, otherwise feel free to request more details. Thanks already for your help!

leifeld commented 2 years ago

Interaction effects for exogenous covariates can be added by multiplying the two constituent terms. For example, if you have something like edgecov(covariate1) and edgecov(covariate2), you can multiply the elements of the two matrices (interaction <- covariate1 * covariate2) and include the result as another covariate together with the two main effects (edgecov(interaction)).

Nodal covariates are slightly trickier because you will first have to create matrices for these covariates for inclusion in an edgecov term. For example, nodeocov would require column-wise duplication of the row-varying covariate, and nodeicov would require row-wise duplication of the column-varying covariate to fill the matrix to be included in the edgecov term in an equivalent way. The result can then be used for multiplication, as above.

nodematch works in a similar way. You have to create the nodematch matrix for inclusion in an edgecov term first and can then multiply it with another matrix in an element-wise way to create an interaction term. So the key is that whatever exogenous covariate you want to include, you convert it into matrix format first.