Subgroup analysis in ISIS-2

 Sys.setlocale("LC_CTYPE", "C.UTF-8")

library(dplyr)

# https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(15)61505-7/fulltext

# Set parameters

n <- 17187  # total number of patients as per the ISIS-2 trial

age_mean <- 60

age_sd <- 10

gender_distribution <- c(0.6, 0.4)  # Assuming 60% male, 40% female

treatment_types <- c('Streptokinase', 'Aspirin', 'Both', 'Neither')  # Four treatment groups

zodiac_signs <- c('Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Capricorn', 'Libra', 

                  'Scorpio', 'Sagittarius', 'Pisces', 'Aquarius', 'Virgo')

# Simulate data

set.seed(1)  # for reproducibility

data <- tibble(

  patient_id = 1:n,

  age = round(rnorm(n, age_mean, age_sd)),

  gender = sample(c('Male', 'Female'), n, replace = TRUE, prob = gender_distribution),

  treatment = sample(treatment_types, n, replace = TRUE, prob = rep(1/4, 4)),

  zodiac_sign = sample(zodiac_signs, n, replace = TRUE)

)

data$treatment <- factor(data$treatment)

data$treatment <- relevel(data$treatment, ref = 'Neither')

# Function to assign death probability based on treatment

assign_death_probability <- function(treatment) {

  if (treatment == 'Streptokinase') {

    return(rbinom(1, 1, 0.097))

  } else if (treatment == 'Aspirin') {

    return(rbinom(1, 1, 0.097))

  } else if (treatment == 'Both') {

    return(rbinom(1, 1, 0.087))

  } else {

    return(rbinom(1, 1, 0.120))

  }

}

# Apply the function to each row

data <- data %>%

  rowwise() %>%

  mutate(vascular_death = assign_death_probability(treatment))

# Mapping of zodiac signs to Traditional Chinese

zodiac_chinese <- c('Aries' = '白羊座', 'Taurus' = '金牛座', 'Gemini' = '雙子座', 

                    'Cancer' = '巨蟹座', 'Leo' = '獅子座', 'Virgo' = '處女座', 

                    'Libra' = '天秤座', 'Scorpio' = '天蠍座', 'Sagittarius' = '射手座', 

                    'Pisces' = '雙魚座', 'Aquarius' = '水瓶座', 'Capricorn' = '摩羯座')

# Convert zodiac signs to Traditional Chinese

data <- data %>%

  mutate(zodiac_sign = zodiac_chinese[zodiac_sign])

head(data)

library(rms)

lrm(vascular_death ~ treatment+ zodiac_sign, data=data)

if(FALSE){

"死亡              係數    標準誤   Wald Z    P

截距          -2.0565 0.0994 -20.70 <0.0001 

Aspirin      -0.2653 0.0694  -3.82 0.0001  

Both          -0.6230 0.0766  -8.13 <0.0001 

Streptokinase -0.298 0.07 -4.26 <0.0001 

天蠍座      -0.0117 0.1302  -0.09 0.9285  

射手座      -0.0261 0.1314  -0.20 0.8428  

巨蟹座      -0.0350 0.1325  -0.26 0.7918  

摩羯座       0.2499 0.1256   1.99 0.0466  

水瓶座       0.1392 0.1285   1.08 0.2787  

獅子座       0.1904 0.1263   1.51 0.1317  

白羊座       0.1529 0.1283   1.19 0.2333  

處女座       0.1063 0.1277   0.83 0.4054  

金牛座       0.0292 0.1291   0.23 0.8212  

雙子座       0.1332 0.1267   1.05 0.2932  

雙魚座       0.0294 0.1313   0.22 0.8231 "

}

留言

這個網誌中的熱門文章

Bayesian reanalysis of ORBITA

Bayesian reanalysis with pymc3

Bayesian reanalysis of Apolipoprotein A1 Infusions