jasp-stats / jasp-issues

This repository is solely meant for reporting of bugs, feature requests and other issues in JASP.
59 stars 29 forks source link

[Feature Request]: Interaction term in frequentist logistic regression model #2519

Closed aboyle57 closed 10 months ago

aboyle57 commented 10 months ago

Description

Functionality to create an interaction term for two variables in logistic regression?

Purpose

No response

Use-case

No response

Is your feature request related to a problem?

No response

Is your feature request related to a JASP module?

Regression

Describe the solution you would like

An option to create an interaction between at least 2 variables, that can then be displayed in the coefficients table as "Variable A * Variable B"

Describe alternatives that you have considered

Jamovi has this option in the binomial logistic regression package

Additional context

No response

Kucharssim commented 10 months ago

Dear @aboyle57,

adding interaction terms is easy: 1) Expand the Model section, 2) select variables in the Components box that you want to put in the interaction, and 3) add them to the Model Terms by clicking on the right arrow between the boxes.

Please feel free to reopen this issue if this doesn't work for you.

aboyle57 commented 10 months ago

Thanks @Kucharssim

Unless I'm mistaken, this doesn't allow you to include the interaction term in a multivariable analysis? It provides an intercept (which I assume is the value of the interaction term), but does so in the absence of other variables that you might want to control for but that are not included in the interaction term.

Kucharssim commented 10 months ago

I am not sure what you are asking for at the moment, sorry. Could you explain in a different way what you want to achieve? A concrete example would be appreciated.

aboyle57 commented 10 months ago

No problem. Here's an example from Jamovi that hopefully explains my point.

Model 1 has the two variables and the interaction term.

Model 2 has two variables, the interaction term, and other co-variates of interest.

I prefer JASP and want to use it, but I can't seem to replicate this analysis in JASP? Example.pdf

Kucharssim commented 10 months ago

Thanks for the example. To check if I understand correctly, let's pretend we have a dependent variable Y, and independent variables X1, X2, and X3. Your example suggest to me that you want to do a comparison of two models akin to this:

M1: Y ~ X1 + X2 + X1*X2 M2: Y ~ X1 + X2 + X1*X2 + X3

In JASP, you can do that as follows:

1) Add Y as dependent variable, X1, X2, and X3 as covariates/factors depending on their type. 2) Open Model section, where the main effects X1, X2, and X3 should be already automatically added to the Model Terms. 3) Select X1 and X2 at the same time and add them to the Model Terms to specify the interaction X1*X2. 4) Toggle Add to null model next to the interaction term that you created. This will include the interaction term into the null model (H0), which by default only includes the intercept. X1 and X2 will be automatically added to the null model too (to respect the principle of marginality).

As long as I understood your example correctly (it is difficult from the jamovi output to judge what terms are included in your Model 1), this will get you what you want.

To point out some limitations: 1) The analysis is limited only to two models. If you have multiple possible models to compare you will have to conduct the analysis multiple times. 2) The analysis does not allow comparing non-nested models.

We have had some internal discussion on whether and how to tackle these limitations (https://github.com/jasp-stats/INTERNAL-jasp/issues/1900, https://github.com/jasp-stats/INTERNAL-jasp/issues/1619), but so far we have not felt the need to put more priority on this, as comparing multiple non-nested models is (arguably) a relatively niche problem.

Hope this helps!

aboyle57 commented 10 months ago

That's brilliant, thanks Simon! I won't confess to how long I've been looking to do this!!!

Out of interest, do you know if there are plans to include cox proprotional hazards modelling in JASP? I'm sure there are with initial survival analysis module recently released.

EJWagenmakers commented 10 months ago

Yes, we'll add more survival models this year! EJ