Commit 8f1c6201bb5cf6f1c0432bb580ee6422e468030c
1 parent
4d40f27465
Exists in
master
Updated Version
Showing
1 changed file
with
21 additions
and
9 deletions
Show diff stats
RMarkovBlanket.r
1 | 1 | #Efrain Gonzalez |
2 | -#7/25/2017 | |
2 | +#8/25/2017 | |
3 | 3 | #Code for Markov Blanket |
4 | 4 | |
5 | 5 | |
... | ... | @@ -91,7 +91,7 @@ for(j in 1:sizeDotP1){ |
91 | 91 | } |
92 | 92 | |
93 | 93 | lrgMarkov <- dim(NewDotP2_2)[1] |
94 | -MBlanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", VariableEndName = "Age"){ | |
94 | +Blanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", VariableEndName = "Age"){ | |
95 | 95 | #Finding the Parents and Children |
96 | 96 | d <- 1 |
97 | 97 | AllNamList1 <- vector("list",length = 3) |
... | ... | @@ -124,9 +124,12 @@ MBlanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", V |
124 | 124 | nc <- 1 |
125 | 125 | for(nc in 1:NumofChild){ |
126 | 126 | LocCOPofVar <- grep(CofVar[nc],NewDotP2_2[,2]) |
127 | - COPofVar <- NewDotP2_2[LocCOPofVar,1] | |
128 | - if(grepl(COPofVar,VariableStartName)){ | |
129 | - next | |
127 | + COPofVar <- NewDotP2_2[LocCOPofVar,1] | |
128 | + if(sum(grepl(VariableStartName,COPofVar)) >= 1){ | |
129 | + #positions of variable start name within the vector of co parents | |
130 | + posoforig <- grep(VariableStartName,COPofVar) | |
131 | + COPofVar <- COPofVar[-posoforig] | |
132 | + COPlist <- append(COPlist,COPofVar) | |
130 | 133 | } else{ |
131 | 134 | #COPlist[[nc]] <- COPofVar[COPofVar!=VariableStartName] |
132 | 135 | COPlist <- append(COPlist,COPofVar) |
... | ... | @@ -180,8 +183,11 @@ MBlanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", V |
180 | 183 | for(np in 1:NumofVars){ |
181 | 184 | LocCofVar <- grep(AllVarList[[d-1]][[ef]][np],NewDotP2_2[,1]) |
182 | 185 | CofVar <- NewDotP2_2[LocCofVar,2] |
183 | - #if(grepl(VariableStartName,CofVar)){ | |
184 | - # next | |
186 | + #if(sum(grepl(VariableStartName,CofVar)) >= 1){ | |
187 | + # #positions of variable start name within the vector of co parents | |
188 | + # posoforig <- grep(VariableStartName,COPofVar) | |
189 | + # COPofVar <- COPofVar[-posoforig] | |
190 | + # COPlist <- append(COPlist,COPofVar) | |
185 | 191 | #} else{ |
186 | 192 | CofVlist <- append(CofVlist,CofVar) |
187 | 193 | #} |
... | ... | @@ -202,7 +208,14 @@ MBlanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", V |
202 | 208 | for(ncp in 1:NumofCVars){ |
203 | 209 | LocCPofCVar <- grep(CofVlist[ncp],NewDotP2_2[,2]) |
204 | 210 | CPofCVar <- NewDotP2_2[LocCPofCVar,1] |
205 | - CPofClist <- append(CPofClist,CPofCVar) | |
211 | + #if(sum(grepl(,CPofCVar)) >= 1){ | |
212 | + # #positions of variable start name within the vector of co parents | |
213 | + # posoforig <- grep(VariableStartName,COPofVar) | |
214 | + # COPofVar <- COPofVar[-posoforig] | |
215 | + # COPlist <- append(COPlist,COPofVar) | |
216 | + #} else{ | |
217 | + CPofClist <- append(CPofClist,CPofCVar) | |
218 | + #} | |
206 | 219 | ncp <- ncp + 1 |
207 | 220 | } |
208 | 221 | |
... | ... | @@ -224,4 +237,3 @@ MBlanky <- function(MarkovDegree = lrgMarkov, VariableStartName = "Alzheimer", V |
224 | 237 | ##The Markov Degree is that found below |
225 | 238 | d |
226 | 239 | } |
227 | -#Now use the command MBlanky() with the appropriate settings | |
228 | 240 | \ No newline at end of file |