User Tools

Site Tools


interaction_effects_in_regression_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
interaction_effects_in_regression_analysis [2025/06/16 07:27] – [Two category variables] hkimscilinteraction_effects_in_regression_analysis [2025/06/16 13:00] (current) – [E.g.2] hkimscil
Line 96: Line 96:
  
 ====== Two category variables ====== ====== Two category variables ======
-<code>> set.seed(12)+<code> 
 +> set.seed(12)
 > f1<-gl(n=2,k=30,labels=c("Low","High")) > f1<-gl(n=2,k=30,labels=c("Low","High"))
 > f2<-as.factor(rep(c("A","B","C"),times=20)) > f2<-as.factor(rep(c("A","B","C"),times=20))
Line 273: Line 274:
  
 <code> <code>
-# install.packages("jtools"+interact_plot(mod2, pred = "f1", modx = "f2")
-# install.packages("interactions"+
-library(jtools) +
-library(interactions) +
-interact_plot(mod2, pred = "f1", modx = "f2")+
 </code> </code>
-{{:pasted:20250616-072703.png}}+{{:pasted:20250616-072703.png?400}} 
 +<code> 
 +> interact_plot(mod2, pred = "f2", modx = "f1"
 +</code> 
 +{{:pasted:20250616-072946.png?400}}
 :r:interaction.effects.2.jpeg :r:interaction.effects.2.jpeg
 ====== Two continuous variables ====== ====== Two continuous variables ======
Line 419: Line 420:
 ====== E.g.2  ====== ====== E.g.2  ======
 {{:r:states.rds}} {{:r:states.rds}}
-Download the data file to c:/Rstatistics firstThen +<code> 
-do  +# states.data <- readRDS("c:/Rstatistics/dataSets/states.rds" 
-<code>states.data <- readRDS("c:/Rstatistics/dataSets/states.rds") </code> +states.data <- readRDS(url("http://commres.net/wiki/_media/r/states.rds")
 +</code> 
  
 Or, read the above data file directly Or, read the above data file directly
Line 469: Line 471:
 </code> </code>
 <code> <code>
-> data.info <- data.frame(attributes(data)[c("names", "var.labels")])+> data.info <- data.frame(attributes(states.data)[c("names", "var.labels")])
 > # attributes(data) reveals various attributes of the data file,  > # attributes(data) reveals various attributes of the data file, 
 > # which contains variable names and labels. > # which contains variable names and labels.
interaction_effects_in_regression_analysis.1750026433.txt.gz · Last modified: 2025/06/16 07:27 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki