-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
283 lines (283 loc) · 9.85 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
penalized_regression
file_path<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/data_for_r.csv"#
output_stats<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_stats.csv"#
#
# Import packages#
library(logistf)#
#
# Load csv file#
dr<-read.csv(file_path,header=TRUE,sep=",")
fit1<-logistf(data=dr,drug_resistant~pst+duration_minutes,firth=FALSE,pl=FALSE)#
summary(fit1)
fit2<-logistf(data=dr,drug_resistant~pst+duration_minutes,firth=TRUE,pl=TRUE)#
summary(fit2)
file_path<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_table.csv"#
output_stats<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_stats.csv"#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
# Survdiff#
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
plot(Surv)
Surv
eeg.surv<-survfit(Surv(survtime, observed)~resistant,data=data)
plot(eeg.surv)
plot(survfit(Surv(survtime,observed))~resistant,data=data)
# Parameters#
file_path<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_table.csv"#
output_stats<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_stats.csv"#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
# Survdiff#
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
# Plot#
plot(survfit(Surv(survtime,observed))~resistant,data=data)
plot(survfit(Surv(survtime,observed)~resistant),data=data)
plot(survfit(Surv(survtime,observed)~resistant,data=data))
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
file_path<-"/Users/erinconrad/Desktop/residency stuff/R25/ige project/data/r_table_pst.csv"#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
# Survdiff#
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
# Plot#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
file_path<-"../data/r_table_kw.csv"
data<-read.csv(file_path,header=TRUE,sep=",")
data
file_path<-"../data/r_table_kw.csv"
data<-read.csv(file_path,header=TRUE,sep=",")
data
data<-read.csv(file_path,header=FALSE,sep=",")
data
kruskal.test(V1 ~ V2,data = data)
survival
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
file_path<-"../data/r_table_pst.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")
data
file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")
data
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")
data
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data,subset = 1:204),mark.time =TRUE)
survdiff(Surv(survtime,observed)~resistant,data=data,subset = 1:204,rho=0)
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
ile_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
library(samplesizeCMH)#
#
odds.ratio(marginal_table)
install.packages("samplesizeCMH")
library(samplesizeCMH)
library(stats)
odds.ratio(marginal_table)
library(datasets)
data(Titanic, package = "datasets")
Titanic
marginal_table <- margin.table(Titanic, c(2,4))
marginal_table
partial_tables <- margin.table(Titanic, c(2,4,1))#
partial_tables
Titanic
mantelhaen.test(partial_tables)
partial_tables
my.array<-array(0,dim=c(5,6,8))
my.array
help("Titanic", "datasets")
file_path<-"../data/cmh_table.csv"
data<-read.csv(file_path,header=TRUE,sep=",")
data
data<-read.csv(file_path,header=FALSE,sep=",")
data
data(1,1)
data[1,1]
table3d[1,1,1] <- data[1,1]
table3d <- data#
dim(table3d) = c(2,2,2)
table3d
v = sample(1:5,24,replace = TRUE)
v
dim(table3d) = c(1,8)
dim(table3d) = c(8)
table3d <- array(data,dim=c(2,2,2))
table3d
data
table3d <- array(data,dim=c(2,2,2),dimnames=NULL)
table3d
m <- matrix(data)
m
data
m <- matrix(data,2,4)
m
data
class(data)
m <- data.matrix(data,nrow=2,ncol=4)
m <- data.matrix(data)
m
class(m)
table3d <- array(m,dim=c(2,2,2),dimnames=NULL)
table3d
mantelhaen.test(table3d)
mantelhaen.test(table3d,correct=FALSE)
survival
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
# Parameters#
file_path<-"../data/cmh_table.csv" # the file path for the table of time to first PST#
#file_path<-"../data/cmh_table.csv" # file path for time to first occurrence of various features#
#
library(samplesizeCMH)#
# Load csv file#
data<-read.csv(file_path,header=FALSE,sep=",")#
#
# Make 3 dimensional table#
m <- data.matrix(data)#
table3d <- array(m,dim=c(2,2,2),dimnames=NULL)#
#
mantelhaen.test(table3d,correct=FALSE)
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)
file_path<-"../data/cmh_table.csv" # the file path for the table of time to first PST#
#file_path<-"../data/cmh_table.csv" # file path for time to first occurrence of various features#
#
library(samplesizeCMH)#
# Load csv file#
data<-read.csv(file_path,header=FALSE,sep=",")#
#
# Make 3 dimensional table#
m <- data.matrix(data)#
table3d <- array(m,dim=c(2,2,2),dimnames=NULL)#
#
mantelhaen.test(table3d,correct=FALSE)
# Parameters#
file_path<-"../data/r_table_pst.csv" # the file path for the table of time to first PST#
#file_path<-"../data/r_all_features.csv" # file path for time to first occurrence of various features#
#
# Import packages#
library(survival)#
#
# Load csv file#
data<-read.csv(file_path,header=TRUE,sep=",")#
#
# perform the log-rank test to test for a difference in "survival time" (time to first PST) between drug resistant and responsive patients #
survdiff(Surv(survtime,observed)~resistant,data=data,rho=0)#
#
# Kaplan-Meier plot (should give the same plot as in Matlab)#
plot(survfit(Surv(survtime,observed)~resistant,data=data),mark.time =TRUE)