1 lines(1:15, rep(0,15), col='red')
4 Gamma = matrix(c(5,-0.02,0.01,-0.02,1,0.1,0.01,0.1,1),3,3)
6 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
7 gammai = t(sapply(1:N,FUN = function(i){
8 rmvnorm(1,mugamma,Gamma)
10 Xdata = t(sapply(1:N,FUN = function(i){
11 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
13 matplot(t(Xdata),type="l")
15 beta = c(1,-3.5,4.5,-2.5)
16 pydata = sapply(1:N,FUN=function(i){
17 a = sum(beta*c(1,gammai[i,]))
18 return(exp(a)/(1+exp(a)))
20 U = runif(length(pydata))
21 ydata = as.numeric(U<pydata)
22 plot(sort(pydata),col=ydata[order(pydata)]+2)
26 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
29 Xdata = t(sapply(1:N,FUN = function(i){
30 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
33 beta = c(1,-3.5,4.5,-2.5)
34 pydata = sapply(1:N,FUN=function(i){
35 a = sum(beta*c(1,gammai[i,]))
36 return(exp(a)/(1+exp(a)))
38 U = runif(length(pydata))
39 ydata = as.numeric(U<pydata)
40 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
42 lines(1:15, rep(0,15), col='red')
44 matplot(Xdata,type='l')
45 matplot(t(Xdata),type='l')
46 matplot(apply(Xdata, 2, mean),type='l')
47 mean(apply(Xdata, 2, mean))
50 Gamma = matrix(c(5,-0.02,0.01,-0.02,1,0.1,0.01,0.1,1),3,3)
52 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
53 gammai = t(sapply(1:N,FUN = function(i){
54 rmvnorm(1,mugamma,Gamma)
56 Xdata = t(sapply(1:N,FUN = function(i){
57 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
59 matplot(t(Xdata),type="l")
61 beta = c(1,-3.5,4.5,-2.5)
62 pydata = sapply(1:N,FUN=function(i){
63 a = sum(beta*c(1,gammai[i,]))
64 return(exp(a)/(1+exp(a)))
66 U = runif(length(pydata))
67 ydata = as.numeric(U<pydata)
68 plot(sort(pydata),col=ydata[order(pydata)]+2)
72 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
75 Xdata = t(sapply(1:N,FUN = function(i){
76 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
79 beta = c(1,-3.5,4.5,-2.5)
80 pydata = sapply(1:N,FUN=function(i){
81 a = sum(beta*c(1,gammai[i,]))
82 return(exp(a)/(1+exp(a)))
84 U = runif(length(pydata))
85 ydata = as.numeric(U<pydata)
86 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
88 lines(1:15, rep(0,15), col='red')
90 Gamma = matrix(c(5,-0.02,0.01,-0.02,5,0.1,0.01,0.1,5),3,3)
92 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
93 gammai = t(sapply(1:N,FUN = function(i){
94 rmvnorm(1,mugamma,Gamma)
96 Xdata = t(sapply(1:N,FUN = function(i){
97 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
99 matplot(t(Xdata),type="l")
101 plot(sort(sapply(1:N,FUN=function(i) 1/(1+exp((-1)*(resEM$betah[1,ITfinal]+sum(resEM$betah[-1,ITfinal]*resEM$gammahat[i,]))))) ))
105 lines(1:15,rep(0,15))
106 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
109 Xdata = t(sapply(1:N,FUN = function(i){
110 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
113 beta = c(1,-3.5,4.5,-2.5)
114 pydata = sapply(1:N,FUN=function(i){
115 a = sum(beta*c(1,gammai[i,]))
116 return(exp(a)/(1+exp(a)))
118 U = runif(length(pydata))
119 ydata = as.numeric(U<pydata)
120 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
122 lines(1:15, rep(0,15), col='red')
125 mugamma = c(1,2,3,2,4,6)
126 LGamma = matrix(0,nrow=6,ncol=6)
127 LGamma[lower.tri(LGamma,diag=FALSE)] = rnorm(6*5/2,0,0.05)
128 LGamma = LGamma + diag(runif(6,0.2,1))
129 Gamma = LGamma%*%t(LGamma)
131 freq = seq(0,1,length=M)
132 intervals = list(12:25,67:89)
133 Si = as.matrix(bdiag(getbasismatrix(freq[12:25],create.fourier.basis(nbasis = 3)), getbasismatrix(freq[67:89],create.fourier.basis(nbasis = 3))))
134 gammai = t(sapply(1:N,FUN = function(i){
135 rmvnorm(1,mugamma,Gamma)
137 Xdata = t(sapply(1:N,FUN = function(i){
138 as.vector(Si%*%gammai[i,])+rnorm(nrow(Si),0,s2)
140 xdata = matrix(0,nrow=N,ncol=M)
141 xdata[,intervals[[1]] ] = Xdata[,1:14]
142 xdata[,intervals[[2]] ] = Xdata[,15:37]
143 beta = c(2,0.5,-2,1,0.2,1,-1)
144 pydata = sapply(1:N,FUN=function(i){
145 a = sum(beta*c(1,gammai[i,]))
146 return(exp(a)/(1+exp(a)))
148 U = runif(length(pydata))
149 ydata = as.numeric(U<pydata)
150 plot(sort(pydata),col=ydata[order(pydata)]+1)
155 kapp = sample(1:200,0.8*200,replace=FALSE)
156 xdata.app = xdata[kapp,]
157 ydata.app = ydata[kapp]
158 ktest = setdiff(1:200,kapp)
159 xdata.test = xdata[ktest,]
160 ydata.test = ydata[ktest]
161 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=TRUE)
162 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
163 eer[ell] = mean(Yres$Ypred==ydata.test)
164 cat("\n", "ell =", ell)
166 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
168 kapp = sample(1:200,0.8*200,replace=FALSE)
169 xdata.app = xdata[kapp,]
170 ydata.app = ydata[kapp]
171 ktest = setdiff(1:200,kapp)
172 xdata.test = xdata[ktest,]
173 ydata.test = ydata[ktest]
174 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=TRUE)
175 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
176 eer[ell] = mean(Yres$Ypred==ydata.test)
177 cat("\n", "ell =", ell)
181 Gamma = matrix(c(5,-0.02,0.01,-0.02,5,0.1,0.01,0.1,5),3,3)
183 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
184 gammai = t(sapply(1:N,FUN = function(i){
185 rmvnorm(1,mugamma,Gamma)
187 Xdata = t(sapply(1:N,FUN = function(i){
188 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
190 matplot(t(Xdata),type="l")
192 beta = c(1,-3.5,4.5,-2.5)
193 pydata = sapply(1:N,FUN=function(i){
194 a = sum(beta*c(1,gammai[i,]))
195 return(exp(a)/(1+exp(a)))
197 U = runif(length(pydata))
198 ydata = as.numeric(U<pydata)
199 plot(sort(pydata),col=ydata[order(pydata)]+2)
202 lines(1:15,rep(0,15))
203 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
206 Xdata = t(sapply(1:N,FUN = function(i){
207 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
210 beta = c(1,-3.5,4.5,-2.5)
211 pydata = sapply(1:N,FUN=function(i){
212 a = sum(beta*c(1,gammai[i,]))
213 return(exp(a)/(1+exp(a)))
215 U = runif(length(pydata))
216 ydata = as.numeric(U<pydata)
217 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
219 lines(1:15, rep(0,15), col='red')
222 Gamma = matrix(c(5,-0.02,0.01,-0.02,1,0.1,0.01,0.1,5),3,3)
224 Si = getbasismatrix(seq(0,1,length=15),create.fourier.basis(nbasis = 3))
225 gammai = t(sapply(1:N,FUN = function(i){
226 rmvnorm(1,mugamma,Gamma)
228 Xdata = t(sapply(1:N,FUN = function(i){
229 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
231 matplot(t(Xdata),type="l")
233 beta = c(1,-3.5,4.5,-2.5)
234 pydata = sapply(1:N,FUN=function(i){
235 a = sum(beta*c(1,gammai[i,]))
236 return(exp(a)/(1+exp(a)))
238 U = runif(length(pydata))
239 ydata = as.numeric(U<pydata)
240 plot(sort(pydata),col=ydata[order(pydata)]+2)
241 # ydata = ydata.noise
244 lines(1:15,rep(0,15))
245 plot( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),typ="l",lty=1,col="green")
248 Xdata = t(sapply(1:N,FUN = function(i){
249 as.vector(Si%*%gammai[i,])+rnorm(15,0,s2)
252 beta = c(1,-3.5,4.5,-2.5)
253 pydata = sapply(1:N,FUN=function(i){
254 a = sum(beta*c(1,gammai[i,]))
255 return(exp(a)/(1+exp(a)))
257 U = runif(length(pydata))
258 ydata = as.numeric(U<pydata)
259 lines( apply(t(Xdata[ydata==1,]),1,mean)-apply(t(Xdata[ydata==0,]),1,mean),col="green")
261 lines(1:15, rep(0,15), col='red')
262 matplot(t(Xdata[ydata==1,]),typ="l",lty=1,col="red")
263 matplot(t(Xdata[ydata==0,]),typ="l",lty=1,col="black",add=TRUE)
266 mugamma = c(1,2,3,2,4,6)
267 LGamma = matrix(0,nrow=6,ncol=6)
268 LGamma[lower.tri(LGamma,diag=FALSE)] = rnorm(6*5/2,0,0.05)
269 LGamma = LGamma + diag(runif(6,0.2,1))
270 Gamma = LGamma%*%t(LGamma)
272 freq = seq(0,1,length=M)
273 intervals = list(12:25,67:89)
274 Si = as.matrix(bdiag(getbasismatrix(freq[12:25],create.fourier.basis(nbasis = 3)), getbasismatrix(freq[67:89],create.fourier.basis(nbasis = 3))))
275 gammai = t(sapply(1:N,FUN = function(i){
276 rmvnorm(1,mugamma,Gamma)
278 Xdata = t(sapply(1:N,FUN = function(i){
279 as.vector(Si%*%gammai[i,])+rnorm(nrow(Si),0,s2)
281 xdata = matrix(0,nrow=N,ncol=M)
282 xdata[,intervals[[1]] ] = Xdata[,1:14]
283 xdata[,intervals[[2]] ] = Xdata[,15:37]
284 beta = c(2,0.5,-2,1,0.2,1,-1)
285 pydata = sapply(1:N,FUN=function(i){
286 a = sum(beta*c(1,gammai[i,]))
287 return(exp(a)/(1+exp(a)))
289 U = runif(length(pydata))
290 ydata = as.numeric(U<pydata)
291 plot(sort(pydata),col=ydata[order(pydata)]+1)
293 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=500,100,eps=10^-8,keep=TRUE)
294 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
295 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=500,100,eps=10^-8,keep=TRUE)
299 kapp = sample(1:200,0.8*200,replace=FALSE)
300 xdata.app = xdata[kapp,]
301 ydata.app = ydata[kapp]
302 ktest = setdiff(1:200,kapp)
303 xdata.test = xdata[ktest,]
304 ydata.test = ydata[ktest]
305 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=FALSE)
306 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
307 eer[ell] = mean(Yres$Ypred==ydata.test)
308 cat("\n", "ell =", ell)
310 source('~/Dropbox/projet spectres/algoEM/EMalgorithmBandes.R')
312 kapp = sample(1:200,0.8*200,replace=FALSE)
313 xdata.app = xdata[kapp,]
314 ydata.app = ydata[kapp]
315 ktest = setdiff(1:200,kapp)
316 xdata.test = xdata[ktest,]
317 ydata.test = ydata[ktest]
318 resEM = EM.Bands.function(ydata,xdata,freq,intervals,nBasis,MCit=1000,25,eps=10^-8,keep=FALSE)
319 Yres = Y.predB(xdata.test,freq,intervals,resEM$muh,resEM$Gammah,resEM$s2h,resEM$betah,nBasis=c(3,3))
320 eer[ell] = mean(Yres$Ypred==ydata.test)
321 cat("\n", "ell =", ell)
325 source('~/Dropbox/projet spectres/cluster/EMLiqArtBandeHugues.R')
329 source('EMalgorithm.R')
330 source('EMLiqArtBandeHugues.R')
332 EMLiqArtBandeHugues(nVC)
334 setwd("~/Dropbox/projet spectres/cluster")
338 source('EMalgorithm.R')
339 source('EMLiqArtBandeHugues.R')
341 EMLiqArtBandeHugues(nVC)
343 sims= c(63:67,69,71:74,76:85,88:90,93:100)
344 #simulation_settings=expand.grid(c(1,2,3,4,5),c(1,2),c(600),c(300))
345 #for (i in 1:nrow(simulation_settings)){
346 aa=cbind(sims,rep(9, each =length(sims)))
347 colnames(aa)=c("isim","model")
348 write.table(aa,file=paste("SimulationSettings9.txt",sep=""),row.names=FALSE,sep=",")
349 setwd("~/Dropbox/WarpMixedModel/warpingMixedModel/SuperComputer")
350 write.table(aa,file=paste("SimulationSettings9.txt",sep=""),row.names=FALSE,sep=",")
352 colnames(sims) = "isim"
354 #simulation_settings=expand.grid(c(1,2,3,4,5),c(1,2),c(600),c(300))
355 #for (i in 1:nrow(simulation_settings)){
356 aa=cbind(sims,rep(10, each =length(sims)))
357 colnames(aa)=c("isim","model")
358 write.table(aa,file=paste("SimulationSettings10.txt",sep=""),row.names=FALSE,sep=",")
359 load("~/valse/data/data.RData")
360 load("~/valse/data/data.RData")
363 library("devtools", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
451 hist(notes, nclass = 20)
452 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,
453 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)
495 shiny::runApp('Dropbox/cranview-master')
497 min_date = Sys.Date() - 1
498 for (pkg in packages)
500 # api data for package. we want the initial release - the first element of the "timeline"
501 pkg_data = httr::GET(paste0("http://crandb.r-pkg.org/", pkg, "/all"))
502 pkg_data = httr::content(pkg_data)
503 initial_release = pkg_data$timeline[[1]]
504 min_date = min(min_date, as.Date(initial_release))
507 load("~/valse/data/data.RData")
509 init = initSmallEM(k, X, Y)
511 library("devtools", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
512 library("roxygen2", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")