0
$\begingroup$

I would like to analyze a dataset that looks like the following:

library(data.table)

dataset <- fread("
x1  x2  y
A   A1  0
A   A2  1
A   A3  1
B   B1  0
B   B2  1
B   B3  0
")

and the properties A1, A2, A3 are only relative to A, as well B1, B2, B3 to B and not have any column x1=A and x2=B1 for example. And I would like if there is a method to deal with this dependency between columns. I think I can't just fit a linear model with those, and I don't know any tests that work in this situation. One path I think that could be possible is create a third column "x1*x2" with x1 and x2 concatenated and the proceed to fit a linear model, or make some common tests.

Thanks in advance!

$\endgroup$
3
  • $\begingroup$ If you can't fit a linear model, then what kind of model do you have in mind? You do seem to be describing the linear model y ~ x2. How does your conception differ from that? $\endgroup$
    – whuber
    Jun 6, 2022 at 14:58
  • $\begingroup$ I can fit a linear model, but a would like to see the impact of x1 $\endgroup$ Jun 6, 2022 at 15:03
  • $\begingroup$ It would help, then, to state that in your question, rather than suggest you are looking for a nonlinear model. By properly coding your variables you can get your regression software to test $x_1$ automatically; otherwise, you can conduct that as a post hoc test. $\endgroup$
    – whuber
    Jun 6, 2022 at 16:08

0

Your Answer

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