-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
408 lines (408 loc) · 21.4 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#' create a list of all the packages needed to run this R File.
all_packages_needed <- c("reshape", "dplyr","proxy", "matrixStats","R.methodsS3", "zoo","gtools", "Hmisc","knitr","plyr")
#'
#'if an R package that is needed to run this code is not installed, install it.
packages_to_install <- all_packages_needed[!(all_packages_needed %in% installed.packages()[,"Package"])]
if(length(packages_to_install)) try(install.packages(packages_to_install),silent=TRUE)
#'
#'load all the packages needed. A FALSE value returned indicates the package failed to load.
Load_Package_Silently <- function(Package_Name){suppressMessages(require(Package_Name,character.only = TRUE))}
sapply(all_packages_needed,Load_Package_Silently)#load all packages needed and don't print messages
#'
#'
#'Set variables needed to run this code
#Set the percent variance explained cutoff for TSQI, KmQI and KnQI. Value between 0 and 1.
# PCA_PercentVarExplainedCutoff <- .92
NormalSampleSize <- 32
Initial_Vector_Length <- 3500
NormalVectorFileDirectory <- read.csv('Source_File_Directory.csv', header=T, sep=',')
NormalVectorMatrix <- matrix(NA, nrow = Initial_Vector_Length, NormalSampleSize)
# ##Interlab File Directory
# InterlabDataFiles <- read.csv('Main_Source_Files/Interlab_FileDirectory_Final_Methodology.csv', header=T, sep=',')
# #load temporal spatial data
# refpop = as.data.frame(read.table('Main_Source_Files/TS_Normal_Variable_Matrix.csv', header=T, sep=','))
# refpopheights = as.data.frame(read.table('Main_Source_Files/TS_Normal_Height_Matrix_NoCadence_20141125.csv', header=T, sep=','))
#
###############################################################################################################
#'Assemble all the normal vectors in a 3500 x NormalSampleSize matrix
for(n in 1:NormalSampleSize){
CurrentNormVectorFilename <- NormalVectorFileDirectory$NormalVectorFileNames[n]
CurrentNormData <- read.csv(paste('Normal_Files/', CurrentNormVectorFilename,sep=''), header=T, sep=',')
CurrentNormMean_AllVars <- subset(CurrentNormData, select=c(4))
NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_AllVars)
}
#' #'**Begin the kinematic and kinetic calculations on the normal data**
#' ###############################################################################################################
#' #Calculate normal mean and std dev for all 3500 rows.
#' NormalMean <- as.matrix(rowMeans(NormalVectorMatrix))
#' NormalStdDev <- as.matrix(rowSds(NormalVectorMatrix))
#'
#'
#' ##Calculate z-scores on entire matrix
#' Z_Normal_AllVars <- apply(NormalVectorMatrix,2, function(x) (x-NormalMean)/NormalStdDev)
###############################################################################################################
#'###GDI Prep Calculations
##We need to calculate the previous methodololgies, the GDI and GPS to compare to the GQI
##This GDI section was created by Norman Dotson##
#######Setting Typically Developing Control Group Data###########
##################################
#Create list of measurements to be used
MeasurementList = c("L_Pelvis_Rotation"
,"R_Pelvis_Fwd_Tilt"
,"R_Pelvis_Lat_Tilt"
,"L_HIP_Abd_ANG"
,"L_HIP_Flex_ANG"
,"L_HIP_Rot_ANG"
,"L_KNEE_Flex_ANG"
,"L_ANK_Flex_ANG"
,"L_Foot_Orientation"
,"R_HIP_Abd_ANG"
,"R_HIP_Flex_ANG"
,"R_HIP_Rot_ANG"
,"R_KNEE_Flex_ANG"
,"R_ANK_Flex_ANG"
,"R_Foot_Orientation"
)
###########################
#######Variables###########
###########################
Vector_nrow = length(MeasurementList) * 100
#create an empty matrix with 100 * length(MeasurementAngleList)
#This will change according to vector variables selected
#Multiple Sample Size by 2 to account for left and right sides
GDI_GPS_NormalVectorMatrix <- matrix(NA, nrow = Vector_nrow, ncol=NormalSampleSize)
#Assemble all the normal vectors in a 3500 x NormalSampleSize matrix and assembler the GDI and GPS based on measurement list
for(n in 1:NormalSampleSize){
CurrentNormVectorFilename <- NormalVectorFileDirectory$NormalVectorFileNames[n]
CurrentNormData <- read.csv(paste('Normal_Files/', CurrentNormVectorFilename,sep=''), header=T, sep=',')
CurrentNormMean_AllVars <- subset(CurrentNormData, select=c(4))
NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_AllVars)
###GDI and GPS Matrix##
CurrentNormMean_ReqVars <- CurrentNormData[ which(CurrentNormData[,2] %in% MeasurementList),]
##Must include column 1 and 2 in 'order' to preserve a correct structure order
#CurrentNormMean_ReqVars[,2] = as.character(CurrentNormMean_ReqVars[,2])
CurrentNormMean_ReqVars <- CurrentNormMean_ReqVars[order(CurrentNormMean_ReqVars[,2],CurrentNormMean_ReqVars[,1]),]
##Pull the Mean values for each patient and append to NormalVectorMatrix
GDI_GPS_NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_ReqVars[,4])
}
GDI_GPS_Var_Details <- CurrentNormMean_ReqVars[,1:3]
#' ##GDI Calculations for Normals###
#' NormMeans_ForGDIandGPS <- as.matrix(rowMeans(GDI_GPS_NormalVectorMatrix))
#'
#'
#' #'Able-Bodied Temporal Spatial Quality Index prep calculations
#' ###############################################################################################################
#' #Limit Temporal Spatial data based on number of normals in sample.
#' refpop <- refpop[which(refpop$NormID <= NormalSampleSize),]
#' refpopheights <- refpopheights[which(refpopheights$NormID <= NormalSampleSize),]
#'
#' refpopheights <- subset(refpopheights, select=c(3,4,5,8,10,13,14))
#'
#' refpop <- subset(refpop, select=c(3,4,5,8,10,13,14))
#'
#' ##convert to a matrix
#' m_refpopheights <- data.matrix(refpopheights)
#' m_refpop <- data.matrix(refpop)
#' ##Normalize to height
#' refpopHeightNormalized <- m_refpopheights * m_refpop
#'
#'
#'
#'
#'
#'
#'
#' ###### Assemble Patient Data. ######
#' PatientVectorMatrix <- matrix(NA, nrow = Vector_nrow, ncol = length(InterlabDataFiles$VectorFileName))
#' PatientTemporalSpatialData <- matrix(NA, ncol= 7, nrow = length(InterlabDataFiles$VectorFileName))
#'
#' #assemble interlab data into a single dataframe
#' #' ###Loop through all of the interlab data and calculate the GQI, GDI and GPS for each study.
#' #'These 10 subjects have been studied at 3 different time points over two days
#' #'This data is used to calculate the minimum detectable change (MDC) for the different methodologies
#' ###############################################################################################################
#' for(i in 1:length(InterlabDataFiles$VectorFileName)){
#'
#' #Read in interlab data
#' CurrentVectorFilename <- InterlabDataFiles$VectorFileName[i]
#' PatientData <- read.csv(paste('Interlab_Files/',CurrentVectorFilename,sep=''), header=T, sep=',')
#'
#' #Subset the data we need
#' PatientMean_AllVars <- subset(PatientData, select=c(4))
#'
#' ###GDI and GPS Matrix##
#' CurrentPatientMean_ReqVars <- PatientData[ which(PatientData[,2] %in% MeasurementList),]
#' ##Must include column 1 and 2 in 'order' to preserve a correct structure order
#' #CurrentNormMean_ReqVars[,2] = as.character(CurrentNormMean_ReqVars[,2])
#' CurrentPatientMean_ReqVars <- CurrentPatientMean_ReqVars[order(CurrentPatientMean_ReqVars[,2],CurrentPatientMean_ReqVars[,1]),]
#' PatientVectorMatrix[,i] <- CurrentPatientMean_ReqVars$Mean
#'
#' #Read in the patient's temporal Spatial data
#' CurrentTemporalSpatialFilename <- InterlabDataFiles$TempSpatialFileName[i]
#' CurrentTemporalSpatialData <- read.csv(paste('Interlab_Files/',CurrentTemporalSpatialFilename,sep=''), header=T, sep=',')
#'
#' #Read in the current height multiplier
#' CurrentHeightMultiplier <- InterlabDataFiles$HeightMultiplier[i]
#'
#' CurrentHeightMultiplier <- as.numeric(as.character(CurrentHeightMultiplier))
#'
#' #Subset the data we need.
#' CurrentTemporalSpatialData <- subset(CurrentTemporalSpatialData, select=c(1,2,3,6,8,11,12))
#'
#' ##Normalize to height
#' CurrentTemporalSpatialData$L_Step_Length <- CurrentTemporalSpatialData$L_Step_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Step_Length <- CurrentTemporalSpatialData$R_Step_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$L_Stride_Length <- CurrentTemporalSpatialData$L_Stride_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Stride_Length <- CurrentTemporalSpatialData$R_Stride_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$L_Velocity <- CurrentTemporalSpatialData$L_Velocity * CurrentHeightMultiplier
#'
#' ##Per KK Edits, DO NOT NORMALIZE CADENCE TO HEIGHT.
#' #CurrentTemporalSpatialData$L_Cadence <- CurrentTemporalSpatialData$L_Cadence * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Step_Width <- CurrentTemporalSpatialData$R_Step_Width * CurrentHeightMultiplier
#'
#' PatientTemporalSpatialData[i,] <- as.matrix(CurrentTemporalSpatialData)
#'
#' }
#' create a list of all the packages needed to run this R File.
all_packages_needed <- c("reshape", "dplyr","proxy", "matrixStats","R.methodsS3", "zoo","gtools", "Hmisc","knitr","plyr")
#'
#'if an R package that is needed to run this code is not installed, install it.
packages_to_install <- all_packages_needed[!(all_packages_needed %in% installed.packages()[,"Package"])]
if(length(packages_to_install)) try(install.packages(packages_to_install),silent=TRUE)
#'
#'load all the packages needed. A FALSE value returned indicates the package failed to load.
Load_Package_Silently <- function(Package_Name){suppressMessages(require(Package_Name,character.only = TRUE))}
sapply(all_packages_needed,Load_Package_Silently)#load all packages needed and don't print messages
#'
#'
#'Set variables needed to run this code
#Set the percent variance explained cutoff for TSQI, KmQI and KnQI. Value between 0 and 1.
# PCA_PercentVarExplainedCutoff <- .92
NormalSampleSize <- 32
Initial_Vector_Length <- 3500
NormalVectorFileDirectory <- read.csv('Source_File_Directory.csv', header=T, sep=',')
NormalVectorMatrix <- matrix(NA, nrow = Initial_Vector_Length, NormalSampleSize)
# ##Interlab File Directory
# InterlabDataFiles <- read.csv('Main_Source_Files/Interlab_FileDirectory_Final_Methodology.csv', header=T, sep=',')
# #load temporal spatial data
# refpop = as.data.frame(read.table('Main_Source_Files/TS_Normal_Variable_Matrix.csv', header=T, sep=','))
# refpopheights = as.data.frame(read.table('Main_Source_Files/TS_Normal_Height_Matrix_NoCadence_20141125.csv', header=T, sep=','))
#
###############################################################################################################
#'Assemble all the normal vectors in a 3500 x NormalSampleSize matrix
for(n in 1:NormalSampleSize){
CurrentNormVectorFilename <- NormalVectorFileDirectory$NormalVectorFileNames[n]
CurrentNormData <- read.csv(paste('Normal_Files/', CurrentNormVectorFilename,sep=''), header=T, sep=',')
CurrentNormMean_AllVars <- subset(CurrentNormData, select=c(4))
NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_AllVars)
}
#' #'**Begin the kinematic and kinetic calculations on the normal data**
#' ###############################################################################################################
#' #Calculate normal mean and std dev for all 3500 rows.
#' NormalMean <- as.matrix(rowMeans(NormalVectorMatrix))
#' NormalStdDev <- as.matrix(rowSds(NormalVectorMatrix))
#'
#'
#' ##Calculate z-scores on entire matrix
#' Z_Normal_AllVars <- apply(NormalVectorMatrix,2, function(x) (x-NormalMean)/NormalStdDev)
###############################################################################################################
#'###GDI Prep Calculations
##We need to calculate the previous methodololgies, the GDI and GPS to compare to the GQI
##This GDI section was created by Norman Dotson##
#######Setting Typically Developing Control Group Data###########
##################################
#Create list of measurements to be used
MeasurementList = c("L_Pelvis_Rotation"
,"R_Pelvis_Fwd_Tilt"
,"R_Pelvis_Lat_Tilt"
,"L_HIP_Abd_ANG"
,"L_HIP_Flex_ANG"
,"L_HIP_Rot_ANG"
,"L_KNEE_Flex_ANG"
,"L_ANK_Flex_ANG"
,"L_Foot_Orientation"
,"R_HIP_Abd_ANG"
,"R_HIP_Flex_ANG"
,"R_HIP_Rot_ANG"
,"R_KNEE_Flex_ANG"
,"R_ANK_Flex_ANG"
,"R_Foot_Orientation"
)
###########################
#######Variables###########
###########################
Vector_nrow = length(MeasurementList) * 100
#create an empty matrix with 100 * length(MeasurementAngleList)
#This will change according to vector variables selected
#Multiple Sample Size by 2 to account for left and right sides
GDI_GPS_NormalVectorMatrix <- matrix(NA, nrow = Vector_nrow, ncol=NormalSampleSize)
#Assemble all the normal vectors in a 3500 x NormalSampleSize matrix and assembler the GDI and GPS based on measurement list
for(n in 1:NormalSampleSize){
CurrentNormVectorFilename <- NormalVectorFileDirectory$NormalVectorFileNames[n]
CurrentNormData <- read.csv(paste('Source_Data/', CurrentNormVectorFilename,sep=''), header=T, sep=',')
CurrentNormMean_AllVars <- subset(CurrentNormData, select=c(4))
NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_AllVars)
###GDI and GPS Matrix##
CurrentNormMean_ReqVars <- CurrentNormData[ which(CurrentNormData[,2] %in% MeasurementList),]
##Must include column 1 and 2 in 'order' to preserve a correct structure order
#CurrentNormMean_ReqVars[,2] = as.character(CurrentNormMean_ReqVars[,2])
CurrentNormMean_ReqVars <- CurrentNormMean_ReqVars[order(CurrentNormMean_ReqVars[,2],CurrentNormMean_ReqVars[,1]),]
##Pull the Mean values for each patient and append to NormalVectorMatrix
GDI_GPS_NormalVectorMatrix[,n] <- as.matrix(CurrentNormMean_ReqVars[,4])
}
GDI_GPS_Var_Details <- CurrentNormMean_ReqVars[,1:3]
#' ##GDI Calculations for Normals###
#' NormMeans_ForGDIandGPS <- as.matrix(rowMeans(GDI_GPS_NormalVectorMatrix))
#'
#'
#' #'Able-Bodied Temporal Spatial Quality Index prep calculations
#' ###############################################################################################################
#' #Limit Temporal Spatial data based on number of normals in sample.
#' refpop <- refpop[which(refpop$NormID <= NormalSampleSize),]
#' refpopheights <- refpopheights[which(refpopheights$NormID <= NormalSampleSize),]
#'
#' refpopheights <- subset(refpopheights, select=c(3,4,5,8,10,13,14))
#'
#' refpop <- subset(refpop, select=c(3,4,5,8,10,13,14))
#'
#' ##convert to a matrix
#' m_refpopheights <- data.matrix(refpopheights)
#' m_refpop <- data.matrix(refpop)
#' ##Normalize to height
#' refpopHeightNormalized <- m_refpopheights * m_refpop
#'
#'
#'
#'
#'
#'
#'
#' ###### Assemble Patient Data. ######
#' PatientVectorMatrix <- matrix(NA, nrow = Vector_nrow, ncol = length(InterlabDataFiles$VectorFileName))
#' PatientTemporalSpatialData <- matrix(NA, ncol= 7, nrow = length(InterlabDataFiles$VectorFileName))
#'
#' #assemble interlab data into a single dataframe
#' #' ###Loop through all of the interlab data and calculate the GQI, GDI and GPS for each study.
#' #'These 10 subjects have been studied at 3 different time points over two days
#' #'This data is used to calculate the minimum detectable change (MDC) for the different methodologies
#' ###############################################################################################################
#' for(i in 1:length(InterlabDataFiles$VectorFileName)){
#'
#' #Read in interlab data
#' CurrentVectorFilename <- InterlabDataFiles$VectorFileName[i]
#' PatientData <- read.csv(paste('Interlab_Files/',CurrentVectorFilename,sep=''), header=T, sep=',')
#'
#' #Subset the data we need
#' PatientMean_AllVars <- subset(PatientData, select=c(4))
#'
#' ###GDI and GPS Matrix##
#' CurrentPatientMean_ReqVars <- PatientData[ which(PatientData[,2] %in% MeasurementList),]
#' ##Must include column 1 and 2 in 'order' to preserve a correct structure order
#' #CurrentNormMean_ReqVars[,2] = as.character(CurrentNormMean_ReqVars[,2])
#' CurrentPatientMean_ReqVars <- CurrentPatientMean_ReqVars[order(CurrentPatientMean_ReqVars[,2],CurrentPatientMean_ReqVars[,1]),]
#' PatientVectorMatrix[,i] <- CurrentPatientMean_ReqVars$Mean
#'
#' #Read in the patient's temporal Spatial data
#' CurrentTemporalSpatialFilename <- InterlabDataFiles$TempSpatialFileName[i]
#' CurrentTemporalSpatialData <- read.csv(paste('Interlab_Files/',CurrentTemporalSpatialFilename,sep=''), header=T, sep=',')
#'
#' #Read in the current height multiplier
#' CurrentHeightMultiplier <- InterlabDataFiles$HeightMultiplier[i]
#'
#' CurrentHeightMultiplier <- as.numeric(as.character(CurrentHeightMultiplier))
#'
#' #Subset the data we need.
#' CurrentTemporalSpatialData <- subset(CurrentTemporalSpatialData, select=c(1,2,3,6,8,11,12))
#'
#' ##Normalize to height
#' CurrentTemporalSpatialData$L_Step_Length <- CurrentTemporalSpatialData$L_Step_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Step_Length <- CurrentTemporalSpatialData$R_Step_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$L_Stride_Length <- CurrentTemporalSpatialData$L_Stride_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Stride_Length <- CurrentTemporalSpatialData$R_Stride_Length * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$L_Velocity <- CurrentTemporalSpatialData$L_Velocity * CurrentHeightMultiplier
#'
#' ##Per KK Edits, DO NOT NORMALIZE CADENCE TO HEIGHT.
#' #CurrentTemporalSpatialData$L_Cadence <- CurrentTemporalSpatialData$L_Cadence * CurrentHeightMultiplier
#' CurrentTemporalSpatialData$R_Step_Width <- CurrentTemporalSpatialData$R_Step_Width * CurrentHeightMultiplier
#'
#' PatientTemporalSpatialData[i,] <- as.matrix(CurrentTemporalSpatialData)
#'
#' }
library(MASS)
library(dplyr)
library(ggplot2)
library(ggthemes)
library(ipsR)
library(stringr)
?gather
?separate
?rvnorm
?rnorm
p <- 45
sample(c(rep(1,ceiling(p/2))),c(rep(-1,ceiling(p/2))),p,replace = F)
c(rep(1,ceiling(p/2))),c(rep(-1,ceiling(p/2)))
sample(c(rep(1,ceiling(p/2))),c(rep(-1,ceiling(p/2)))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
mean(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2))))
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sum(sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F))
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)
sample(c(rep(1,ceiling(p/2)),c(rep(-1,ceiling(p/2)))),p,replace = F)