[R] Interactions in regression

Jacek Kownacki @@m@ungx1298 @end|ng |rom gm@||@com
Sat Feb 24 13:39:46 CET 2024


Hi All,
I stumbled upon some topics regarding interactions in anova and regression
and packages for tabulating and visualizations the results of them.
Here we are:
https://stackoverflow.com/questions/77933272/how-to-add-a-reference-level-for-interaction-in-gtsummary-and-sjplot/77935742#77935742
,
https://stackoverflow.com/questions/78016795/how-to-add-reference-levels-for-interaction-in-r?noredirect=1&lq=1
.
I was wondering because I usually use GUI software and these questions did
not get answers, if from a technical point of view
how to do it, using these (sjPlot, gtsummary) or other ways to make such
tables, inserting the reference levels of these mentioned interactions.
This is not likely to be used in publications (including three base
levels), but from the point of view of solving the topics this questions
have interested me.
I tried myself to make it happen, but so far without success.
I recall this reprex based on SO:

set.seed(1000)
my_data <- rbind(
  data.frame(time = "Pre", treatment = "Control", response =
rnorm(100, mean=1)),
  data.frame(time = "Pre", treatment = "Treatment", response =
rnorm(100, mean=2)),
  data.frame(time = "Post", treatment = "Control", response =
rnorm(100, mean=1)),
  data.frame(time = "Post", treatment = "Treatment", response =
rnorm(100, mean=2))
) %>% mutate(time = factor(time, levels = c("Pre", "Post")))
%>%mutate(treatment = factor(treatment, levels = c("Control",
"Treatment")))
model3 <- lm(response ~ time * treatment, data = my_data)

Thanks,
Jacek

	[[alternative HTML version deleted]]



More information about the R-help mailing list