data=read.csv('F:/SRC/GPSM.csv',stringsAsFactors = F)
data=data[,-1]
data$treat=as.factor(data$group)
mnps.AOD <- mnps(treat ~ Gender + Age + Location + stage + size+Pre_chemo+resection,
data = data,
estimand = "ATE",
verbose = FALSE,
stop.method = c("es.mean", "ks.mean"),
n.trees = 3000)
library(survey)
data$w <- get.weights(mnps.AOD, stop.method = "es.mean")
design.mnps <- svydesign(ids=~1, weights=~w, data=data)
st=strata(data, stratanames=c('treat'), size=c(300,300,300), method=c("srswor","srswr","poisson",
"systematic")[4], pik=1/data$w,description=T)
sda=data[st$ID_unit,]
write.csv(sda,'f:/SRC/SDA.CSV')
网友评论