+hr_1st
+temp_1st
+spo2_1st
+sodium_first
+bun_first
+po2_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=8;
## logistic regression
## Full Model
# glm1=glm(aline_flg~age+gender_num+weight_first+sofa_first+service_num
#          +day_icu_intime_num+hour_icu_intime+chf_flg+afib_flg
#          +renal_flg+liver_flg+copd_flg+cad_flg+stroke_flg+mal_flg+resp_flg+map_1st
#           +hr_1st+temp_1st+spo2_1st+wbc_first+hgb_first+platelet_first+sodium_first+potassium_first
#           +tco2_first+chloride_first+bun_first+creatinine_first
#           +po2_first+pco2_first,family=binomial, data=data);
## random Model
glm1=glm(aline_flg~age
+gender_num
+weight_first
+sofa_first
+service_num
+hour_icu_intime
+afib_flg
+liver_flg
+copd_flg
+cad_flg
+mal_flg
+map_1st
+hr_1st
+spo2_1st
+hgb_first
+platelet_first
+tco2_first
+chloride_first
+creatinine_first
+po2_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=7;
## random Model
glm1=glm(aline_flg~weight_first
+sofa_first
+service_num
+day_icu_intime_num
+chf_flg
+stroke_flg
+mal_flg
+map_1st
+hr_1st
+spo2_1st
+platelet_first
+bun_first
+creatinine_first
+po2_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=6;
## random Model
glm1=glm(aline_flg~gender_num
+sofa_first
+service_num
+day_icu_intime_num
+chf_flg
+copd_flg
+cad_flg
+resp_flg
+spo2_1st
+wbc_first
+hgb_first
+platelet_first
+tco2_first
+chloride_first
+bun_first
+creatinine_first
+po2_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=5;
## random Model
glm1=glm(aline_flg~weight_first
+sofa_first
+service_num
+day_icu_intime_num
+hour_icu_intime
+liver_flg
+copd_flg
+resp_flg
+temp_1st
+spo2_1st
+wbc_first
+hgb_first
+sodium_first
+tco2_first
+creatinine_first
+po2_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=4;
## random Model
glm1=glm(aline_flg~age
+sofa_first
+service_num
+day_icu_intime_num
+hour_icu_intime
+afib_flg
+cad_flg
+stroke_flg
+resp_flg
+map_1st
+spo2_1st
+tco2_first
+creatinine_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=3;
## random Model
glm1=glm(aline_flg~age
+gender_num
+sofa_first
+service_num
+chf_flg
+renal_flg
+liver_flg
+stroke_flg
+mal_flg
+temp_1st
+spo2_1st
+hgb_first
+platelet_first
+sodium_first
+tco2_first
+chloride_first
+bun_first
+creatinine_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
pos=2;
## random Model
glm1=glm(aline_flg~sofa_first
+service_num
+day_icu_intime_num
+hour_icu_intime
+liver_flg
+copd_flg
+map_1st
+hr_1st
+temp_1st
+spo2_1st
+wbc_first
+platelet_first
+sodium_first
+potassium_first
+chloride_first
+bun_first
,family=binomial, data=data);
#save data objects
#
X <- glm1$fitted
Y <- data$day_28_flg
Tr <- data$aline_flg
s = seq(0.01,0.1, by=0.01);
s1=seq(1,10, by=1);
for (i in s1)
{
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
ps <- Match(Y=NULL, Tr=Tr, X=X, M=1, estimand='ATC', caliper=s[i], replace=FALSE);
#summary(ps);
index=c(ps$index.treated,ps$index.control);
data2 <- data[index,2:3];
##logit regression to measure primary outcome effect size
glm2 <- glm(day_28_flg~aline_flg, family=binomial, data=data2);
p[i,pos]<-coef(summary(glm2))[2,4];
r=exp(cbind(OR = coef(glm2), confint(glm2)));
or[i,pos]<-r[2,1];
};
View(or)
View(or)
View(p)
write.csv(or,"or.csv")
write.csv(p,"pvalue.csv")
plot(or)
plot(s,or)
plot(s[1],or[1,])
or[1,]
plot(or[1,])
help(dotplot)
dotplot(or)
library(graphics)
dotplot(or)
dotchart(or)
help(dotchart)
dotchart(or[1,])
dotchart(or[2,])
dotchart(or)
dotchart(p)
dotplot(s,or)
dotchart(s,or)
help(dotchart)
or_t=t(or)
dotchart(or_T)
dotchart(or_t)
dotchart(or_t,groups=s)
dotchart(or_t)
dotchart(p, groups=row)
plot(or[1,],0.01)
plot(or[1,],y=0.01)
help(vector)
temp=vector(0.01,length=20)
temp=vector(length=20)
temp=0.01
temp=vector(length=20)
temp[]=0.01
plot(or[1,],temp)
for(i in s1)
{
y_data[i*10-10+1:i*10]=s[i]
}
y_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
y_data[i*10-10+1:i*10]=s[i]
}
y_data
s[1]
source('~/Dropbox (Personal)/aLin/github/Aline/Data_Analysis/R/ps_match.R')
y_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
y_data[i*10-10+1:i*10]=s[i];
}
y[1:20]=0.01
y_data[1:20]=0.01
y_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
}
y_data
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=or[i,];
p_x_data[start:end]=p[i,];
}
or[1,]
View(or)
View(or)
View(or)
or=read.csv("or.csv")
p=read.csv("pvalue.csv")
View(or)
View(or)
View(p)
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=or[i,];
p_x_data[start:end]=p[i,];
}
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=or[i,];
p_x_data[start:end]=p[i,];
}
or_x_data
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=vector(or[i,]);
p_x_data[start:end]=p[i,];
}
or_x_data=vector(length=nrow(or)*ncol(or));
dim(or)
View(or)
or$X<-NULL
p$X<-NILL
p$X<-NULL
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=vector(or[i,]);
p_x_data[start:end]=p[i,];
}
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=or[i,];
p_x_data[start:end]=p[i,];
}
or_x_data=vector(length=nrow(or)*ncol(or));
or_x_data[1:20]=or[1,]
or[1,]
or_t=t(or)
or_x_data[1:20]=or_t[,t]
or_x_data[1:20]=or_t[,1]
or_x_data=vector(length=nrow(or)*ncol(or));
or_x_data[1:20]=or_t[,1]
y_data=vector(length=nrow(or)*ncol(or));
or_x_data=vector(length=nrow(or)*ncol(or));
p_x_data=vector(length=nrow(or)*ncol(or));
for(i in s1)
{
start=(i-1)*ncol(or)+1;
end=start+ncol(or)-1;
y_data[start:end]=s[i];
or_x_data[start:end]=t(or)[,i];
p_x_data[start:end]=t(p)[,i];
}
plot(or_x_data,y_data)
help(plot)
plot_data=matrix(3*length(y_data));
plot_data[1,]=y_data;
plot_data=matrix(3*length(y_data));
length(y_data)
plot_data=matrix(nrow=3,ncol=length(y_data));
plot_data[1,]=y_data;
View(plot_data)
plot_data=matrix(nrow=3,ncol=length(y_data));
plot_data[1,]=y_data;
plot_data[2,]=or_x_data;
plot_data[3,]=p_x_data;
View(plot_data)
write.csv(plot_data, "plotdata.csv");
plot(or_x_data,y_data)
plot(p_x_data,y_data)
hist(or_x_data)
hist(or_x_data, 100)
hist(or_x_data, 30)
hist(or_x_data, 20)
