[R] Interactions in regression

Jacek Kownacki
2024-02-25T16:39:32Z

Hi,
I do not want to make a plot, I try to make an output table in R, (in GUI
like Stata this is trivially easy task)
with regard to SO OP question. As I mentioned, in paper I would not do
this, but out of curiosity I use R this time trying to create it.
If in R this is trivial task as well, could you please show how to do it ?
After googling a lot I did not find solution.
regards,
Jacek

niedz., 25 lut 2024 o 17:00 Bert Gunter <bgunter.4567 at gmail.com>
napisa?(a):

> It is trivial in R to add whatever decorations to a plot that you would
> like, but that requires that you go beyond point and click production of
> graphics and write actual code. If you are unwilling or unable to do this,
> you are stuck with whatever various packaged graphics functionality
> provides.So you might want to search on "interaction plots for linear
> models in R" or similar at rseek.org or in your favorite web search
> engine if you haven't already done so. My minimal efforts brought up
lots
> of hits, though none may be useful for your concerns, especially, as has
> already been pointed out, as your query doesn't seem to make much sense
> statistically.
>
> Cheers,
> Bert
>
>
> On Sun, Feb 25, 2024 at 7:46?AM Jacek Kownacki <samsungx1298 at
gmail.com>
> wrote:
>
>> 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]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

	[[alternative HTML version deleted]]