1 ### Regression matrices
4 valMax = max(abs(model$phi))
10 } else op = par(mfrow = c(2, (K+1)/2))
15 image.plot(t(abs(model$phi[,,r])),
16 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
18 par(mfrow = c(1,K),oma = c(0,0,3,0))
19 mtext("Regression matrices in each cluster", side=3, line=4, font=2, cex=2, col='red')
21 par(mfrow = c(1,2), oma=c(0,0,3,0))
23 plot(runif(20), runif(20),
24 main=paste("random plot (",i,")",sep=''))
27 side=3, line=4, font=2, cex=2, col='red')
29 ### Zoom onto two classes we want to compare
34 image.plot(t(abs(model$phi[,,r])),xaxt="n",yaxt="n",
35 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
37 image.plot(t(abs(model$phi[,,kSel[1]]-model$phi[,,kSel[2]])),
38 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
40 ### Covariance matrices
43 image.plot(matrix(diag(model$rho[,,r]), ncol= 1),
44 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
48 Gam = matrix(0, ncol = K, nrow = n)
52 sqNorm2 = sum( (Y[i,]%*%model$rho[,,r]-X[i,]%*%model$phi[,,r])^2 )
53 Gam[i,r] = model$pi[r] * exp(-0.5*sqNorm2)* det(model$rho[,,r])
55 gam[i,] = Gam[i,] / sum(Gam[i,])
57 affec = apply(gam, 1,which.max)
58 gam2 = matrix(NA, ncol = K, nrow = n)
60 gam2[i, affec[i]] = gam[i, affec[i]]
64 ### Mean in each cluster
67 meanPerClass= matrix(0, ncol = K, nrow = dim(XY)[2])
69 XY_class[[r]] = XY[affec == r, ]
70 meanPerClass[,r] = apply(XY_class[[r]], 2, mean)
73 matplot(meanPerClass, type='l')