0
$\begingroup$

I'm fitting a binomial GLM with the following formula:

glm(outcome ~ categorical:continuous:factor)

I would like to see the interaction of categorical and continuous under only the 1st level of 'factor' as well and I have been accomplishing that by subsetting the whole dataset to the 1st level so that 'factor' isn't a variable any more. For clarity the 1st level of factor is the reference level in the above model.

My question is whether I can accomplish the same thing without subsetting i.e. through contrast specification or some other syntax?

My current attempt:

glm(outcome ~ categorical:continuous:(factor == 1stLevel))

But the results don't look like what I'm trying to achieve.

edit I think specifying the formula as follows (in R) works:

glm(outcome ~ categorical:continuous, data = data[data$factor == "1stLevel",])

$\endgroup$
4
  • $\begingroup$ I don't find interaction of categorical and continuous under only the 1st level of 'factor' meaningful. Can you explain what are you aiming at? It it's only a matter of coding this question would be off-topic here. $\endgroup$
    – utobi
    Commented Jan 13, 2023 at 8:04
  • 1
    $\begingroup$ Create an indicator of the first level of the factor and interact that--and only that--with the continuous variable. Subsetting is not the same. $\endgroup$
    – whuber
    Commented Jan 13, 2023 at 11:59
  • $\begingroup$ @utobi thank you for querying. If first level of 'factor' is a control condition for example, doesn't inspecting the interaction between categorical and continuous in the control allow one to see the potential relationship (confounding) present between predictors and outcome prior to intervention i.e. intervention being the successive levels of factor? $\endgroup$ Commented Jan 14, 2023 at 4:00
  • 1
    $\begingroup$ Ok I see. I believe whuber has answered your question then. $\endgroup$
    – utobi
    Commented Jan 14, 2023 at 4:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.