1 ### Regression matrices
4 valMax = max(abs(model$phi))
9 } else par(mfrow = c(2, (K+1)/2))
12 image.plot(t(abs(model$phi[,,r])),
13 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
16 ### Zoom onto two classes we want to compare
21 image.plot(t(abs(model$phi[,,r])),xaxt="n",yaxt="n",
22 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
24 image.plot(t(abs(model$phi[,,kSel[1]]-model$phi[,,kSel[2]])),
25 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
27 ### Covariance matrices
30 image.plot(matrix(diag(model$rho[,,r]), ncol= 1),
31 col=gray(rev(seq(0,64,length.out=65))/65),breaks=seq(0,valMax,length.out=66))
35 Gam = matrix(0, ncol = K, nrow = n)
39 sqNorm2 = sum( (Y[i,]%*%model$rho[,,r]-X[i,]%*%model$phi[,,r])^2 )
40 Gam[i,r] = model$pi[r] * exp(-0.5*sqNorm2)* det(model$rho[,,r])
42 gam[i,] = Gam[i,] / sum(Gam[i,])
44 affec = apply(gam, 1,which.max)
45 gam2 = matrix(NA, ncol = K, nrow = n)
47 gam2[i, affec[i]] = gam[i, affec[i]]
51 ### Mean in each cluster
54 meanPerClass= matrix(0, ncol = K, nrow = dim(XY)[2])
56 XY_class[[r]] = XY[affec == r, ]
57 meanPerClass[,r] = apply(XY_class[[r]], 2, mean)
60 matplot(meanPerClass, type='l')