Hello!

I would like to create a loop that allows me to select all the possible combinations of 2 variables from a list of n variables and fit a logistic regression model for each combination.

For example, let's suppose that there are 8 variables x1 - x8.
I want to fit 36 logistic models:

logit y xk xl w z

where y is the dependent variable, w and z are covariates, and xk and xl are 2 independent variables from the group above.

Is it possible to do this with a loop instead of writing 36 lines of code?

Thank you in advance for your help!