1 a = sum(beta*c(1,gammai[i,]))
2 return(exp(a)/(1+exp(a)))
4 U = runif(length(pydata))
5 ydata = as.numeric(U<pydata)
6 plot(sort(pydata),col=ydata[order(pydata)]+2)
10 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
13 Xdata = t(sapply(1:N,FUN = function(i){
14 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
17 beta = c(1,-3.5,4.5,-2.5)
18 pydata = sapply(1:N,FUN=function(i){
19 a = sum(beta*c(1,gammai[i,]))
20 return(exp(a)/(1+exp(a)))
22 U = runif(length(pydata))
23 ydata = as.numeric(U<pydata)
24 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
26 lines(1:15, rep(0,15), col='red')
28 Gamma = matrix(c(5,-0.02,0.01,-0.02,5,0.1,0.01,0.1,5),3,3)
30 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
31 gammai = t(sapply(1:N,FUN = function(i){
32 rmvnorm(1,mugamma,Gamma)
34 Xdata = t(sapply(1:N,FUN = function(i){
35 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
37 matplot(t(Xdata),type="l")
39 plot(sort(sapply(1:N,FUN=function(i) 1/(1+exp((-1)*(resEM$betah[1,ITfinal]+sum(resEM$betah[-1,ITfinal]*resEM$gammahat[i,]))))) ))
44 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
47 Xdata = t(sapply(1:N,FUN = function(i){
48 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
51 beta = c(1,-3.5,4.5,-2.5)
52 pydata = sapply(1:N,FUN=function(i){
53 a = sum(beta*c(1,gammai[i,]))
54 return(exp(a)/(1+exp(a)))
56 U = runif(length(pydata))
57 ydata = as.numeric(U<pydata)
58 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
60 lines(1:15, rep(0,15), col='red')
63 mugamma = c(1,2,3,2,4,6)
64 LGamma = matrix(0,nrow=6,ncol=6)
65 LGamma[lower.tri(LGamma,diag=FALSE)] = rnorm(6*5/2,0,0.05)
66 LGamma = LGamma + diag(runif(6,0.2,1))
67 Gamma = LGamma%*%t(LGamma)
69 freq = seq(0,1,length=M)
70 intervals = list(12:25,67:89)
71 Si = as.matrix(bdiag(getbasismatrix(freq[12:25],create.fourier.basis(nbasis = 3)), getbasismatrix(freq[67:89],create.fourier.basis(nbasis = 3))))
72 gammai = t(sapply(1:N,FUN = function(i){
73 rmvnorm(1,mugamma,Gamma)
75 Xdata = t(sapply(1:N,FUN = function(i){
76 as.vector(Si%*%gammai[i,])+rnorm(nrow(Si),0,s2)
78 xdata = matrix(0,nrow=N,ncol=M)
79 xdata[,intervals[[1]] ] = Xdata[,1:14]
80 xdata[,intervals[[2]] ] = Xdata[,15:37]
81 beta = c(2,0.5,-2,1,0.2,1,-1)
82 pydata = sapply(1:N,FUN=function(i){
83 a = sum(beta*c(1,gammai[i,]))
84 return(exp(a)/(1+exp(a)))
86 U = runif(length(pydata))
87 ydata = as.numeric(U<pydata)
88 plot(sort(pydata),col=ydata[order(pydata)]+1)
93 kapp = sample(1:200,0.8*200,replace=FALSE)
94 xdata.app = xdata[kapp,]
95 ydata.app = ydata[kapp]
96 ktest = setdiff(1:200,kapp)
97 xdata.test = xdata[ktest,]
98 ydata.test = ydata[ktest]
99 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=TRUE)
100 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
101 eer[ell] = mean(Yres$Ypred==ydata.test)
102 cat("\n", "ell =", ell)
104 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
106 kapp = sample(1:200,0.8*200,replace=FALSE)
107 xdata.app = xdata[kapp,]
108 ydata.app = ydata[kapp]
109 ktest = setdiff(1:200,kapp)
110 xdata.test = xdata[ktest,]
111 ydata.test = ydata[ktest]
112 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=TRUE)
113 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
114 eer[ell] = mean(Yres$Ypred==ydata.test)
115 cat("\n", "ell =", ell)
119 Gamma = matrix(c(5,-0.02,0.01,-0.02,5,0.1,0.01,0.1,5),3,3)
121 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
122 gammai = t(sapply(1:N,FUN = function(i){
123 rmvnorm(1,mugamma,Gamma)
125 Xdata = t(sapply(1:N,FUN = function(i){
126 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
128 matplot(t(Xdata),type="l")
130 beta = c(1,-3.5,4.5,-2.5)
131 pydata = sapply(1:N,FUN=function(i){
132 a = sum(beta*c(1,gammai[i,]))
133 return(exp(a)/(1+exp(a)))
135 U = runif(length(pydata))
136 ydata = as.numeric(U<pydata)
137 plot(sort(pydata),col=ydata[order(pydata)]+2)
140 lines(1:15,rep(0,15))
141 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
144 Xdata = t(sapply(1:N,FUN = function(i){
145 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
148 beta = c(1,-3.5,4.5,-2.5)
149 pydata = sapply(1:N,FUN=function(i){
150 a = sum(beta*c(1,gammai[i,]))
151 return(exp(a)/(1+exp(a)))
153 U = runif(length(pydata))
154 ydata = as.numeric(U<pydata)
155 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
157 lines(1:15, rep(0,15), col='red')
160 Gamma = matrix(c(5,-0.02,0.01,-0.02,1,0.1,0.01,0.1,5),3,3)
162 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
163 gammai = t(sapply(1:N,FUN = function(i){
164 rmvnorm(1,mugamma,Gamma)
166 Xdata = t(sapply(1:N,FUN = function(i){
167 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
169 matplot(t(Xdata),type="l")
171 beta = c(1,-3.5,4.5,-2.5)
172 pydata = sapply(1:N,FUN=function(i){
173 a = sum(beta*c(1,gammai[i,]))
174 return(exp(a)/(1+exp(a)))
176 U = runif(length(pydata))
177 ydata = as.numeric(U<pydata)
178 plot(sort(pydata),col=ydata[order(pydata)]+2)
179 # ydata = ydata.noise
182 lines(1:15,rep(0,15))
183 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
186 Xdata = t(sapply(1:N,FUN = function(i){
187 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
190 beta = c(1,-3.5,4.5,-2.5)
191 pydata = sapply(1:N,FUN=function(i){
192 a = sum(beta*c(1,gammai[i,]))
193 return(exp(a)/(1+exp(a)))
195 U = runif(length(pydata))
196 ydata = as.numeric(U<pydata)
197 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
199 lines(1:15, rep(0,15), col='red')
200 matplot(t(Xdata[ydata==1,]),typ="l",lty=1,col="red")
201 matplot(t(Xdata[ydata==0,]),typ="l",lty=1,col="black",add=TRUE)
204 mugamma = c(1,2,3,2,4,6)
205 LGamma = matrix(0,nrow=6,ncol=6)
206 LGamma[lower.tri(LGamma,diag=FALSE)] = rnorm(6*5/2,0,0.05)
207 LGamma = LGamma + diag(runif(6,0.2,1))
208 Gamma = LGamma%*%t(LGamma)
210 freq = seq(0,1,length=M)
211 intervals = list(12:25,67:89)
212 Si = as.matrix(bdiag(getbasismatrix(freq[12:25],create.fourier.basis(nbasis = 3)), getbasismatrix(freq[67:89],create.fourier.basis(nbasis = 3))))
213 gammai = t(sapply(1:N,FUN = function(i){
214 rmvnorm(1,mugamma,Gamma)
216 Xdata = t(sapply(1:N,FUN = function(i){
217 as.vector(Si%*%gammai[i,])+rnorm(nrow(Si),0,s2)
219 xdata = matrix(0,nrow=N,ncol=M)
220 xdata[,intervals[[1]] ] = Xdata[,1:14]
221 xdata[,intervals[[2]] ] = Xdata[,15:37]
222 beta = c(2,0.5,-2,1,0.2,1,-1)
223 pydata = sapply(1:N,FUN=function(i){
224 a = sum(beta*c(1,gammai[i,]))
225 return(exp(a)/(1+exp(a)))
227 U = runif(length(pydata))
228 ydata = as.numeric(U<pydata)
229 plot(sort(pydata),col=ydata[order(pydata)]+1)
231 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=500,100,eps=10^-8,keep=TRUE)
232 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
233 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=500,100,eps=10^-8,keep=TRUE)
237 kapp = sample(1:200,0.8*200,replace=FALSE)
238 xdata.app = xdata[kapp,]
239 ydata.app = ydata[kapp]
240 ktest = setdiff(1:200,kapp)
241 xdata.test = xdata[ktest,]
242 ydata.test = ydata[ktest]
243 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=FALSE)
244 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
245 eer[ell] = mean(Yres$Ypred==ydata.test)
246 cat("\n", "ell =", ell)
248 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
250 kapp = sample(1:200,0.8*200,replace=FALSE)
251 xdata.app = xdata[kapp,]
252 ydata.app = ydata[kapp]
253 ktest = setdiff(1:200,kapp)
254 xdata.test = xdata[ktest,]
255 ydata.test = ydata[ktest]
256 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=FALSE)
257 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
258 eer[ell] = mean(Yres$Ypred==ydata.test)
259 cat("\n", "ell =", ell)
263 source('~/Dropbox/projet spectres/cluster/EMLiqArtBandeHugues.R')
267 source('EMalgorithm.R')
268 source('EMLiqArtBandeHugues.R')
270 EMLiqArtBandeHugues(nVC)
272 setwd("~/Dropbox/projet spectres/cluster")
276 source('EMalgorithm.R')
277 source('EMLiqArtBandeHugues.R')
279 EMLiqArtBandeHugues(nVC)
281 sims= c(63:67,69,71:74,76:85,88:90,93:100)
282 #simulation_settings=expand.grid(c(1,2,3,4,5),c(1,2),c(600),c(300))
283 #for (i in 1:nrow(simulation_settings)){
284 aa=cbind(sims,rep(9, each =length(sims)))
285 colnames(aa)=c("isim","model")
286 write.table(aa,file=paste("SimulationSettings9.txt",sep=""),row.names=FALSE,sep=",")
287 setwd("~/Dropbox/WarpMixedModel/warpingMixedModel/SuperComputer")
288 write.table(aa,file=paste("SimulationSettings9.txt",sep=""),row.names=FALSE,sep=",")
290 colnames(sims) = "isim"
292 #simulation_settings=expand.grid(c(1,2,3,4,5),c(1,2),c(600),c(300))
293 #for (i in 1:nrow(simulation_settings)){
294 aa=cbind(sims,rep(10, each =length(sims)))
295 colnames(aa)=c("isim","model")
296 write.table(aa,file=paste("SimulationSettings10.txt",sep=""),row.names=FALSE,sep=",")
297 load("~/valse/data/data.RData")
298 load("~/valse/data/data.RData")
301 library("devtools", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
389 hist(notes, nclass = 20)
390 notesBis = c(7.375,19.375,10.125,9,6,12.25,11,18.75,10.5,11.5,15.5,13,2.375,12.75,17.75,15.375,8.125,16,8.5,14.5,11.625,11.25,9.625,14,
391 6.5,11.375,11.875,16.25,10.125,12,6.25,9.75,8.75,3.5,0,0,0,5.75,2,3.75,6.625,5.25)
433 shiny::runApp('Dropbox/cranview-master')
435 min_date = Sys.Date() - 1
436 for (pkg in packages)
438 # api data for package. we want the initial release - the first element of the "timeline"
439 pkg_data = httr::GET(paste0("http://crandb.r-pkg.org/", pkg, "/all"))
440 pkg_data = httr::content(pkg_data)
441 initial_release = pkg_data$timeline[[1]]
442 min_date = min(min_date, as.Date(initial_release))
445 library("capushe", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
446 A = matrix(rnorm(25), ncol = 5)
447 A = rbind(A, matrix(0, ncol = 5, nrow = 2))
449 A[rowSums(A)==0,]=c()
451 A = A[rowSums(A)!=0,]
453 source('~/valse/pkg/R/valse.R')
454 setwd("~/valse/reports")
463 covY = array(dim = c(q,q,k))
464 covY[,,1] = 0.1*diag(q)
465 covY[,,2] = 0.2*diag(q)
466 beta = array(dim = c(p,q,2))
467 beta[,,2] = matrix(c(rep(2,(D)),rep(0, p*q-D)))
468 beta[,,1] = matrix(c(rep(1,D),rep(0, p*q-D)))
471 data = generateXY(meanX,covX,covY, pi, beta, n)
472 source('~/valse/pkg/R/generateSampleInputs.R')
473 data = generateXY(meanX,covX,covY, pi, beta, n)
482 XY_class[[r]] = XY[affec == r, ]
486 XY_class[[r]] = XY[affec == r, ]
490 XY_class[[r]] = XY[affec == r, ]
493 XY_class[[r]] = XY[affec == r, ]
494 meanPerClass[,r] = apply(XY_class[[r]], 2, mean)
496 meanPerClass= matrix()
498 XY_class[[r]] = XY[affec == r, ]
499 meanPerClass[,r] = apply(XY_class[[r]], 2, mean)
501 apply(XY_class[[r]], 2, mean)
504 meanPerClass[r,] = apply(XY_class[[r]], 2, mean)
506 meanPerClass= matrix(0, ncol = K, nrow = dim(XY)[2])
508 XY_class[[r]] = XY[affec == r, ]
509 meanPerClass[,r] = apply(XY_class[[r]], 2, mean)
511 matplot(meanPerClass)
512 matplot(meanPerClass, type='l')