0

I'm using the function from from my analysis. My ctree contain all binary/categorical variables. When I change the value labels of the binary categorical variables, I end up getting a different ctree diagram.

Initial Labels

Racialized: 0 = "non-rac" ; 1 = "rac"

Immigrant: 0 = "non-imm"; 1 = "imm"

New Labels

Racialized: 0 = "no" ; 1 = "yes"

Immigrant: 0 = "no"; 1 = "yes"

I'm finding that this is only an issue when I change the labels to "yes/no". I've looked through my code and nothing else has changed. I don't understand why this is happening.

I'll appreciate any help/ideas.

Update Here's a glimpse of the code I initially used for "labelling" my variables, which pretty much changed by numeric variables to character:

data$racialized[data$PP_racialized==0]<- "non-rac"
data$racialized[data$PP_racialized==1]<- "rac" 

data$racialized[data$PP_racialized==0]<- "no"
data$racialized[data$PP_racialized==1]<- "yes" 
#before Ctree analysis 
data <- data %>% dplyr::mutate_if(is.character, factor)

I find that when I use the apply_labels function instead my results stay consistent and I no longer get a discrepancy when I rename my variables

data=apply_labels(racialized=c("rac"=1, "non-rac"= 0))

data=apply_labels(racialized=c("yes"=1, "no"= 0))
#before ctree analysis
data <- data %>% dplyr::mutate_if(is.numeric, factor)
Bisola
  • 21
  • 3
  • Include the code you used to make this happen and the before and after images. – sconfluentus Feb 24 '23 at 23:40
  • Just updated my initial post with more information. Unfortunately I'm unable to upload the ctree b/c of data agreement reasons. – Bisola Feb 25 '23 at 00:36
  • Without a reproducible example it is hard to say what is going on. Can you please try to replicate the problem with an easily available dataset (e.g., from an R package or simulated)? And then please provide a minimal, self-contained and reproducible example. – Achim Zeileis Feb 25 '23 at 15:31

0 Answers0