-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForagingStateAnalysis_ModelFitting.Rmd
417 lines (338 loc) · 19.3 KB
/
ForagingStateAnalysis_ModelFitting.Rmd
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
409
410
411
412
413
414
415
416
417
---
title: "Foraging motion analysis - Fitting statistical models"
author: "kostas lagogiannis"
date: "20/11/2020"
output: html_document
---
The data on dispersion, MSD and mean-path lengths suggest differences between groups.
To rigorously compare the different treatments I next fit statistical models to:
- Compare difference in mean speed: mean path-length vs path duration
- MSD vs Time -power-laws - check exponents
- Probability of being in ROI against time
\[
D^G \sim \mathcal{N}(\mu^G,\sigma^G)\\
k_c \sim \mathbb{categorical}(\lambda)\\
d_l \sim \mathcal{N}(\mu_{k[c]},\sigma_{k[c]})
\]
where the $\sum^{K}_{k=1}\lambda_k = 1$.
```{r jagsmodelfitting-code-setup,eval=FALSE, include=FALSE}
## Because the Full Dispersion Record data is too large- I use a sparse subsampled version to cluster the motin
## this works because movement at 0.5 sec intervals should be sufficient to classify the larva's dispersion over the last 5 sec
# nsamp allows a quick random subset to be created for testing purposes .
makeDispersionDataInferenceSet <- function(bQuickTest = FALSE,nsamp=4000)
{
#nsubsample <- 10000
##Subsample The Dispersion Data into 0.5 sec bins - But Add the hunt Event Frames
loadDispersionData()
datSubDispersion <- datDispersion[ !is.na(datDispersion$Dispersion), ]
datSubDispersion <- datSubDispersion[seq(1,NROW(datSubDispersion),by=nsubsampleInterval ),]
# add the exact frames of hunt events so we can cluster them in exploit/Explore easly datHEventDispersion$frameRow
# Frame Records of Huntevents not in SubSampled frames
missinghuntEvents.frameROW <- datHEventDispersion[!(datHEventDispersion$frameRow %in% datSubDispersion$frameRow),"frameRow"]
# Merge missing hunt Frames onto subsampled dispersion data so we can cluster Hunt Events Specifically
datSubDispersion <- rbind(datSubDispersion,datDispersion[datDispersion$frameRow %in% missinghuntEvents.frameROW,])
#Add Hunt Initiation Events
datSubDispersion$HuntMode <- 0
datSubDispersion[datSubDispersion$frameRow %in% datHEventDispersion$frameRow,"HuntMode"] <- 1
## Lastly / Model and Cluster All Data so we can then run a relative comparison between groupscompare
if (bQuickTest)
datSubDispersion <- datSubDispersion[sample(1:NROW(datSubDispersion),nsamp),]
return(datSubDispersion)
}
```
The GM model is implemented in RJags and its code is as as follows:
```{r RJags-model-DEF,eval=FALSE,include=TRUE,ref.label='clustering-code-setup'}
strDispersionClusterModel <- "
var initR[1,Nclust];
model {
# Likelihood:
for( i in 1 : N ) {
y[i] ~ dnorm( muOfClust[ clust[i] ], tauOfClust[ clust[i] ] )
#mu[i] <- ]
clust[i] ~ dcat( pClust[1:Nclust] )
}
# Prior:
for ( clustIdx in 1: Nclust ) {
muOfClust[clustIdx] ~ dnorm( 0 , 1.0E-10 )
tauOfClust[clustIdx] ~ dgamma( 0.01 , 0.01 )
initR[1,clustIdx] <- 1
}
pClust[1:Nclust] ~ ddirch( initR )
}
"
```
```{r RJags-model-RUN, eval=FALSE, include=FALSE,ref.label='clustering-code-setup'}
initfunct <- function(nchains,N)
{
initlist <- replicate(nchains,list(#mID=c(rbinom(N,1,0.5)),
# sigma = matrix(c ( c(runif(1,min=0,max=0.1),runif(1,min=0,max=2)),
#s c(runif(1,min=0,max=0.1),runif(1,min=0,max=15)) ),nrow=2,byrow=T ),
# mu = matrix(c ( c( rnorm(1,mean=1,sd=sqrt(1/10) ), rnorm(1,mean=8,sd=sqrt(1/2) ) ),
# c( rnorm(1,mean=1, sd=sqrt(1/10) ) , rnorm(1,mean=30, sd=sqrt(1/0.1) ) ) )
# ,nrow=2,byrow = T ),
".RNG.name"="base::Super-Duper",
".RNG.seed"=round(runif(1,0,60000)) ),
simplify=FALSE)
return(initlist)
}
datSubDispersion <- makeDispersionDataInferenceSet(FALSE)
vDispersion.NF.E <- datSubDispersion[datSubDispersion$groupID == 'NL',"Dispersion",]
vDispersion.LF.E <- datSubDispersion[datSubDispersion$groupID == 'LL',"Dispersion",]
#vDispersion.NF.E <- sample(datSubDispersion[datSubDispersion$groupID == 'NL',"Dispersion",] ,min(nsubsample,NROW(datSubDispersion[datSubDispersion$groupID == 'NL',]) ) )
vDispersion.DF.E <- datSubDispersion[datSubDispersion$groupID == 'DL',"Dispersion",]
vDispersion.NF.S <- datSubDispersion[datSubDispersion$groupID == 'NE',"Dispersion",]
vDispersion.LF.S <- datSubDispersion[datSubDispersion$groupID == 'LE',"Dispersion",]
vDispersion.DF.S <- datSubDispersion[datSubDispersion$groupID == 'DE',"Dispersion",]
runGaussianMixClusterModel <- function(vDispersion)
{
##Cluster Membership
N = NROW(vDispersion)
Nclust <- 2
clust = rep(NA,N)
clust[which.min(vDispersion)]=1 # smallest value assigned to cluster 1
clust[which.max(vDispersion)]=2 # highest value assigned to cluster 2
dataList = list(
y = vDispersion ,
N = N,
Nclust = 2 ,
clust = clust
#onesRepNclust = rep(1,Nclust)
)
##
##
steps <-500
nchains <- 3
nthin <- 10
#str_vars <- c("mu","rho","sigma","x_rand") #Basic model
str_vars <- c("clust","pClust","muOfClust","tauOfClust") #Mixture Model
# Run the 2 chains in parallel (allowing the run.jags function
# to control the number of parallel chains). We also use a
# mutate function to convert the precision to standard deviation:
results <- run.jags(model=strDispersionClusterModel, n.chains=nchains,
inits=initfunct(nchains,dataList$N),
thin=nthin,
sample=steps,
data= dataList,
monitor=str_vars,
method="parallel", mutate=list("prec2sd", vars="tauOfClust"))
return(results)
}
results.NF.E <- runGaussianMixClusterModel(vDispersion.NF.E)
write.jagsfile(results.NF.E, file=paste0(strDataExportDir,'jagsModel_clustDispersion_NL.txt') )
save(list=c("results.NF.E","vDispersion.NF.E"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_NL.RData') )
results.LF.E <- runGaussianMixClusterModel(vDispersion.LF.E)
write.jagsfile(results.LF.E, file=paste0(strDataExportDir,'jagsModel_clustDispersion_LL.txt') )
save(list=c("results.LF.E","vDispersion.LF.E"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_LL.RData') )
results.DF.E <- runGaussianMixClusterModel(vDispersion.DF.E)
write.jagsfile(results.DF.E, file=paste0(strDataExportDir,'jagsModel_clustDispersion_DL.txt') )
save(list=c("results.DF.E","vDispersion.DF.E"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_DL.RData') )
## Spont
results.NF.S <- runGaussianMixClusterModel(vDispersion.NF.S)
write.jagsfile(results.NF.S, file=paste0(strDataExportDir,'jagsModel_clustDispersion_NE.txt') )
save(list=c("results.NF.S","vDispersion.NF.S"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_NE.RData') )
results.LF.S <- runGaussianMixClusterModel(vDispersion.LF.S)
write.jagsfile(results.LF.S, file=paste0(strDataExportDir,'jagsModel_clustDispersion_LE.txt') )
save(list=c("results.LF.S","vDispersion.LF.S"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_LE.RData') )
results.DF.S <- runGaussianMixClusterModel(vDispersion.DF.S)
write.jagsfile(results.DF.S, file=paste0(strDataExportDir,'jagsModel_clustDispersion_DE.txt') )
save(list=c("results.DF.S","vDispersion.DF.S"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_DE.RData') )
resultsGmix.All <- runGaussianMixClusterModel(datSubDispersion$Dispersion)
write.jagsfile(resultsGmix.All, file=paste0(strDataExportDir,'jagsModel_clustDispersion_ALL.txt') )
save(list=c("resultsGmix.All","datSubDispersion"),file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_All.RData') )
##Convergence Check
muclustNF <- as.mcmc.list(results.NF.S, vars="muOfClust")
plot(muclustNF)
# View the results using the standard print method:
#summary(results.LF.E)
```
and the clustering results of each group/condition are summarized in the following figures:
```{r RJags-model-PLOT, fig.show='hide', out.width="33%", eval=FALSE, include=FALSE, cache=FALSE, dev='png'}
#ref.label='clustering-code-setup'
##
library(rjags)
library(runjags)
library('coda')
loadDispersionData()
## Extracts the monitor values and returns them packaged in a list
getMCMCEstimatedParams <- function(results,groupID,ichain = 2)
{
clustcoeff = as.mcmc.list(results, vars="clust")
tauOfClust = as.mcmc.list(results, vars="tauOfClust")
muOfClust = as.mcmc.list(results, vars="muOfClust")
lret <- list(
chain = ichain,
groupID = groupID,
muOfClustcoeff = muOfClust,
tauOfClustcoeff = tauOfClust,
mean = muOfClust[[ichain]],
sd = cbind(tauOfClust[[ichain]][,3],tauOfClust[[ichain]][,4]), ##Take the precision converted to sd Columns
pClustcoeff = as.mcmc.list(results, vars="pClust"),
clustID = round(colMeans(clustcoeff[[ichain]]) )
)
return (lret)
}
# clusterIDOffset, and groupIDOffset plot Allows function to work when multiple subgroups are modelled
# by extracting from these columns pClust[groupID,Clust] : pClust[1,1] pClust[2,1] ... pClust[5,2] pClust[6,2]
plotClusterProb <- function(lmcmcRes,clustCol,groupIDOffset=1,clustIDOffset=1)
{
##plot prob of occupying each cluster
breaksProb <- seq(0,1.01,by=0.01)
list_histo <- hist(lmcmcRes$pClustcoeff[[lmcmcRes$chain]],breaks=breaksProb,plot=FALSE )
h1<-hist( lmcmcRes$pClustcoeff[[lmcmcRes$chain]][,groupIDOffset], breaks=breaksProb,plot=FALSE) ##Cluster 1 ylim=c(0,max(list_histo$counts))
h2 <- hist( lmcmcRes$pClustcoeff[[lmcmcRes$chain]][,groupIDOffset + clustIDOffset], breaks=breaksProb, plot=FALSE ) ## ##Cluster 1
##Colour Determines which Cluster is fast and slow
barplot(rbind(h1$density,h2$density),beside = FALSE, col = c(clustCol[1],clustCol[2],"white"),
names.arg = (h1$breaks[-length(h1$breaks)]),
main=paste("Clustered Occupancies", lmcmcRes$groupID ),
xlab = "Prob. of cluster membership (pClust)"
)
txtLeg <- c("Exploit","Explore")
## Make Legend order match the colour classes
## being Exploit (Cyan), Explore (Yellow)
muClustAllChain <- as.data.frame(lmcmcRes$mean)#rbind(
if ( mean(unlist(muClustAllChain[1]) ) > mean(unlist( muClustAllChain[2]) ) )
txtLeg<- rev(txtLeg)
##Add legend colouring Clusters correctly
legend("topright",legend=txtLeg, fill=clustCol)
}
# Plot probability densities of initiating hunting within each Dispersal cluster for each group
# clusterIDOffset, and groupIDOffset plot Allows function to work when multiple subgroups are modelled
# by extracting from these columns pClust[groupID,Clust] : pClust[1,1] pClust[2,1] ... pClust[5,2] pClust[6,2]
plotHuntProb <- function(lmcmcRes,clustCol,groupIDOffset=1,clustIDOffset=1)
{
d1 <- density( lmcmcRes$pHunt[[lmcmcRes$chain]][,groupIDOffset] )
d2 <- density(lmcmcRes$pHunt[[lmcmcRes$chain]][,groupIDOffset + clustIDOffset]) ##The Indexes are organized as such
plot(d1, lty=1, lwd=3, col=clustCol[1],
main=paste("Hunt initiation", lmcmcRes$groupID ),
xlab = "Prob. of hunt initiation per cluster (pHunt)",xlim=c(0,1),ylim=c(0,max(max(max(d2$y),max(d1$y)))*1.10 ))
lines(d2,lwd=3,lty=2,col=clustCol[2])
txtLeg <- c("Exploit","Explore")
## Make Legend order match the colour classes
## being Exploit (Cyan), Explore (Yellow)
muClustAllChain <- as.data.frame(lmcmcRes$mean)#rbind(
if ( mean(unlist(muClustAllChain[1]) ) > mean(unlist( muClustAllChain[2]) ) )
txtLeg<- rev(txtLeg)
##Add legend colouring Clusters correctly
legend("topright",legend=txtLeg, fill=clustCol)
}
# Colour Coded Histogram of Dispersion Data Showing plit between Exploit[1] / Explore[2]
histClusteredDispersion <- function(lmcmcRes,vDispersion,clustCol)
{
## Plot Clustered Histogram
breaksSlots <- seq(0,11,by=0.5)
h0 <- hist(vDispersion, breaks=breaksSlots,plot=FALSE) # freq=TRUE,
h1 <- hist(vDispersion[lmcmcRes$clustID == 1], breaks=breaksSlots, plot=FALSE) #xlim=c(0,10),ylim=c(0,max(h0$counts))
h2 <- hist(vDispersion[lmcmcRes$clustID == 2], breaks=breaksSlots, plot=FALSE) #xlim=c(0,10),
barplot(rbind(h1$density,h2$density),beside = FALSE, col = c(clustCol,"white"),names.arg = (h1$breaks[-length(h1$breaks)]),main=paste("Clustered densities", lmcmcRes$groupID ),xlab = "Dispersion (mm)")
}
# Colour Coded Histogram of Dispersion Data Showing plit between Exploit[1] / Explore[2] - Using Data frame as input
histClusteredDispersionFrame <- function(datSubDispersion,dispfield="Dispersion")
{
clustCol <- c(colourClusters[1],colourClusters[2])
##Validate Colouring - Fast Cluster - Yellow / Slow Cluster Blue
muC1 <- mean(datSubDispersion[datSubDispersion$clustID == 1,dispfield],na.rm = TRUE)
muC2 <- mean(datSubDispersion[datSubDispersion$clustID == 2,dispfield],na.rm = TRUE)
if (muC1>muC2)
clustCol <- rev(clustCol)
## Plot Clustered Histogram
upLim <- round(max(datSubDispersion[,dispfield],na.rm = TRUE))
breaksSlots <- seq(0,upLim*1.1,by=upLim/30)
h0 <- hist(datSubDispersion[,dispfield], breaks=breaksSlots,plot=FALSE) # freq=TRUE,
h1 <- hist(datSubDispersion[datSubDispersion$clustID == 1,dispfield], breaks=breaksSlots, plot=FALSE) #xlim=c(0,10),ylim=c(0,max(h0$counts))
h2 <- hist(datSubDispersion[datSubDispersion$clustID == 2,dispfield], breaks=breaksSlots, plot=FALSE) #xlim=c(0,10),
barplot(rbind(h1$density,h2$density),beside = FALSE, col = c(clustCol,"white"),names.arg = (h1$breaks[-length(h1$breaks)]),
main=paste("Clustered dispersion", paste(unique( datSubDispersion$groupID),collapse="," ) ),xlab = paste(dispfield))
}
## Plot Estimated Mean of each Gaussian
plotClusterMeans <- function(lmcmcRes,clustCol)
{
#hist( mucoeff[[3]],xlim=c(0,10), breaks=20,col=colourDataScheme[[groupID]],main=groupID,xlab = "Sample Means (mm)" )
tauClustAllChain <- as.data.frame(lmcmcRes$var)#rbind( as.data.frame(tauOfClustcoeff[[3]]),as.data.frame(tauOfClustcoeff[[2]]),as.data.frame(tauOfClustcoeff[[1]]))
muClustAllChain <- as.data.frame(lmcmcRes$mean)#rbind( as.data.frame(muOfClustcoeff[[3]]),as.data.frame(muOfClustcoeff[[2]]),as.data.frame(muOfClustcoeff[[1]]) )
## Plot Estimated Mean of each Gaussian
plot(density(unlist(muClustAllChain[1]) ) ,xlim=c(0,10),col=clustCol[1],lwd=3,lty=1,main=paste("Cluster means", lmcmcRes$groupID ),xlab = "Estimated means of each cluster (mu)")
lines(density(unlist(muClustAllChain[2]) ) ,xlim=c(0,10),col=clustCol[2],lwd=3,lty=2)
}
## Compare NegBin To Clustered Data distribution using CDF plots
plotNBFitcdf <- function(vDispersion,resParams)
{
XLim <- 100
x <- seq(0,XLim,1)
ntail <- 20
clustCol <-c(colourClusters[1],colourClusters[2])
if ( mean(resParams$mean[,1]) > mean(resParams$mean[,2]) )
clustCol <- rev(clustCol)
cdfD_C1 <- ecdf(vDispersion[resParams$clustID == 1]*10)
cdfD_C2 <- ecdf(vDispersion[resParams$clustID == 2]*10)
plot(cdfD_C1,col="red",pch=5,xlab=NA,ylab=NA,main="",xlim=c(0,XLim),ylim=c(0,1))
lines(cdfD_C2,col="blue",pch=5,xlab=NA,ylab=NA,main="",xlim=c(0,XLim),ylim=c(0,1))
##Construct CDF of Model by Sampling randomly from Model distribution for exp rate parameter
for (c in 1:2) {
for (i in (NROW(resParams$q[,1])-ntail):NROW(resParams$q[,1]) )
{
cdfM <- dnbinom(x,size=resParams$r[i,c],prob= resParams$q[i,c] )##1-exp(-q*x) ##ecdf( dexp( x, q ) )
lines(x,cumsum(cdfM),col=clustCol[c],lty=1) #add=TRUE,
}
}
##Model AND Data Densities
c<-1
plot(((dnbinom(x,size=mean(resParams$r[,c] ), prob= mean(resParams$q[,c])) ) ), col=clustCol[c],lwd=2,main="NB Model and data distributions",xlim=c(0,XLim),ylim=c(0,2*max(cdfM)),type="l",ylab="Density",xlab="Dispersal (mm x 10)")
lines(density(vDispersion[resParams$clustID == c]*10,na.rm=TRUE), col=clustCol[c],lty=2,lwd=3)
#hist( dnbinom( x, size=1/mean(resParams$r[,c] ), prob = mean(resParams$q[,c]) ) ,col=colourClusters[c],freq=FALSE,breaks=20)
#hist(vDispersion[resParams$clustID == c]*10,col=colourClusters[c],freq=FALSE,add=TRUE)
c<-2
lines((dnbinom(x,size=resParams$r[,c],prob= resParams$q[,c] )),col=clustCol[c],lwd=2)
lines(density(vDispersion[resParams$clustID == c]*10,na.rm=TRUE),col=clustCol[c],lty=2,lwd=3)
#hist( dnbinom(x, size=mean(resParams$r[,c] ), prob= mean(resParams$q[,c]) ) ,col=colourClusters[c],freq=FALSE)
#hist(vDispersion[resParams$clustID == c]*10,col=colourClusters[c],freq=FALSE,add=TRUE)
legend("topright",legend=c("NB Model","Data"),lty=c(1,2),lw=c(2,3) )
legend("bottomright",legend=c("Exploit","Explore"),fill=colourClusters)
}
# Plot Clustering Dispersion Results #
# Colour coded Histogram, Prob of cluster membership, mean dispersion per Gaussian cluster
plotClusterModel <- function(results, vDispersion, groupID, lmcmcRes)
{
muClustAllChain <- as.data.frame(lmcmcRes$mean)#rbind(
## Make Colour code match Low/High Dispersal
## being Exploit (Cyan), Explore (Yellow)
clustCol <- c(colourClusters[1],colourClusters[2])
if ( mean(unlist(muClustAllChain[1]) ) > mean(unlist( muClustAllChain[2]) ) )
clustCol <- rev(clustCol) ##Reverse Colour Order so C1 - has explore colour , and C2 has exploit colour
histClusteredDispersion(lmcmcRes,vDispersion,clustCol)
## Plot Estimated Mean of each Gaussian
plotClusterMeans(lmcmcRes,clustCol)
#plot(density(muClustAllChain$`muOfClust[1]`),xlim=c(0,10),col=clustCol[1],lwd=3,lty=1,main=paste("Cluster means", groupID ),xlab = "Estimated means of each cluster (mu)")
#lines(density(muClustAllChain$`muOfClust[2]`),xlim=c(0,10),col=clustCol[2],lwd=3,lty=2)
##plot prob of occupying each cluster
if (groupID != "All")
plotClusterProb(lmcmcRes,clustCol)
#breaksProb <- seq(0,1,by=0.01)
#list_histo <- hist(lmcmcRes$pClustcoeff[[lmcmcRes$chain]],breaks=breaksProb,main=groupID,freq = FALSE)
#hist( lmcmcRes$pClustcoeff[[lmcmcRes$chain]][,1],xlim=c(0,1),ylim=c(0,max(list_histo$counts)), breaks=breaksProb,col=clustCol[1],xlab = "Prob. of cluster membership (pClust)" ,add=TRUE,freq=FALSE)
#hist( lmcmcRes$pClustcoeff[[lmcmcRes$chain]][,2],xlim=c(0,1), breaks=breaksProb,col=clustCol[2],main=groupID,add=TRUE,freq=FALSE )
}
##plot Cluster Dists
## Evoked
#results <- results.NF.E
#vDispersion <- vDispersion.NF.S
#groupID <- "NL"
```
```{r RJags-model-results-LOAD, eval=FALSE, fig.show='hold', out.width="33%",dev='png',warnings=FALSE,cache=FALSE}
#ref.label='plot-functions dispersion-clustering'
## Load Gaussian Mixture Clustering Results
#if (!exists("results.NF.E"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_NL.RData') )
#if (!exists("results.NF.S"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_NE.RData') )
#if (!exists("results.LF.E"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_LL.RData') )
#if (!exists("results.LF.S"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_LE.RData') )
#if (!exists("results.DF.E"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_DL.RData') )
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_DE.RData') )
#if (!exists("resultsGmix.All"))
load(file=paste0(strDataExportDir,'jagsModelResults_clustDispersion_All.RData') )
plotClusterModel(results.NF.E,vDispersion.NF.E, "NL", getMCMCEstimatedParams(results.NF.E,"NL",2))
plotClusterModel(results.NF.S,vDispersion.NF.S, "NE", getMCMCEstimatedParams(results.NF.S,"NE",2))
```