.Rhistory 17.2 KB
Newer Older
Armin Rauschenberger's avatar
Armin Rauschenberger committed
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
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
n <- 100; p <- 20; q <- 10
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Y <- matrix(rnorm(n*q),nrow=n,ncol=q)
#y <- rbinom(n=n,size=1,prob=0.2)
alpha <- 1
nfolds <- 10
family <- "gaussian"
type.measure <- "deviance"
# properties
n <- nrow(X); p <- ncol(X)
if(length(y)!=n){stop("sample size")}
#foldid <- sample(x=rep(x=seq_len(nfolds),length.out=n))
foldid <- palasso:::.folds(y=y,nfolds=nfolds)
# weights
pi <- seq(from=0,to=1,by=0.2) # adapt this
y <- rnorm(n=n)
# properties
n <- nrow(X); p <- ncol(X)
if(length(y)!=n){stop("sample size")}
#foldid <- sample(x=rep(x=seq_len(nfolds),length.out=n))
foldid <- palasso:::.folds(y=y,nfolds=nfolds)
# weights
pi <- seq(from=0,to=1,by=0.2) # adapt this
# model fitting
fit <- list()
ym <- colasso::colasso_moderate(Y=Y) # trial
for(i in seq_along(pi)){
weights <- rep(c(1-pi[[i]],pi[[i]]),each=n)
fit[[i]] <- glmnet::glmnet(y=c(y,ym),x=rbind(X,X),weights=weights,family=family,alpha=alpha)
}
names(fit) <- paste0("pi",pi)
# inner cross-validation
pred <- lapply(pi,function(x) matrix(data=NA,nrow=length(y),ncol=100))
for(k in sort(unique(foldid))){
y0 <- y[foldid!=k]
y1 <- y[foldid==k]
Y0 <- Y[foldid!=k,,drop=FALSE]
Y1 <- Y[foldid==k,,drop=FALSE]
X0 <- X[foldid!=k,,drop=FALSE]
X1 <- X[foldid==k,,drop=FALSE]
y0m <- colasso_moderate(Y=Y0)
for(i in seq_along(pi)){
weights <- rep(c(1-pi[[i]],pi[[i]]),each=sum(foldid!=k)) # trial
glmnet <- glmnet::glmnet(y=c(y0,y0m),x=rbind(X0,X0),weights=weights,family=family,alpha=alpha)
temp <- stats::predict(object=glmnet,newx=X1,type="response",s=fit[[i]]$lambda)
pred[[i]][foldid==k,seq_len(ncol(temp))] <- temp
}
}
# loss sequence
for(i in seq_along(pi)){
# WATCH OUT: adapt to all loss fuctions
#fit[[i]]$cvm <- apply(X=pred[[i]],MARGIN=2,FUN=function(x) mean((x-y)^2))
fit[[i]]$cvm <- palasso:::.loss(y=y,fit=pred[[i]],family=family,type.measure=type.measure,foldid=foldid)
# WATCH OUT: minimise or maximise
if(type.measure=="AUC"){
fit[[i]]$lambda.min <- fit[[i]]$lambda[which.max(fit[[i]]$cvm)]
} else {
fit[[i]]$lambda.min <- fit[[i]]$lambda[which.min(fit[[i]]$cvm)]
}
}
i
fit[[i]]$cvm
?palasso:::.loss
# loss sequence
cvm <- .loss(y=y,fit=fit,family=args$family,type.measure=args$type.measure,foldid=foldid)
# loss sequence
cvm <- palasso:::.loss(y=y,fit=fit,family=args$family,type.measure=args$type.measure,foldid=foldid)
# loss sequence
cvm <- palasso:::.loss(y=y,fit=fit,family=family,type.measure=type.measure,foldid=foldid)
# loss sequence
cvm <- palasso:::.loss(y=y,fit=pred,family=family,type.measure=type.measure,foldid=foldid)
cvm
cvm
#--- generate toydata ----------------------------------------------------------
Armin Rauschenberger's avatar
Armin Rauschenberger committed
85
86
87
88
89
90
91
92
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
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
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
stop("Family not implemented.")
rm(list=ls())
n <- 100; p <- 20; q <- 10
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Y <- matrix(rnorm(n*q),nrow=n,ncol=q)
#y <- rbinom(n=n,size=1,prob=0.2)
y <- rnorm(n=n)
test <- colasso(y=y,Y=Y,X=X)
test
#--- generate toydata ----------------------------------------------------------
Armin Rauschenberger's avatar
Armin Rauschenberger committed
119
120
121
122
123
124
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
125
#load("D:/colasso/package/toydata.RData")
Armin Rauschenberger's avatar
Armin Rauschenberger committed
126
127
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
colasso_compare <- function(y,Y,X,plot=TRUE,nfolds.int=10,family="gaussian",type.measure="deviance"){
fold <- sample(x=rep(x=seq_len(5),length.out=length(y)))
pred <- matrix(data=NA,nrow=length(y),ncol=8)
select <- list()
for(i in sort(unique(fold))){
cat("i =",i,"\n")
fit <- colasso(y=y[fold!=i],Y=Y[fold!=i,],X=X[fold!=i,],alpha=1,nfolds=nfolds.int,type.measure=type.measure)
for(j in seq_along(fit)){
pred[fold==i,j] <- glmnet::predict.glmnet(object=fit[[j]],
newx=X[fold==i,],
s=fit[[j]]$lambda.min,
type="response")
}
select[[i]] <- lapply(fit,function(x) which(x$beta[,x$lambda==x$lambda.min]!=0))
pred[fold==i,8] <- mean(y[fold!=i]) # intercept-only model
}
colnames(pred) <- c(names(fit),"intercept")
if(family=="gaussian" & type.measure=="deviance" | family=="binomial" & type.measure=="mse"){
loss <- apply(X=pred,MARGIN=2,FUN=function(x) sum((y-x)^2))
} else if(family=="binomial" & type.measure=="class"){
loss <- apply(X=pred,MARGIN=2,FUN=function(x) mean(y!=x))
} else {
warning("Implement other loss functions!")
}
### start temporary ###
#stability <- numeric()
#for(k in seq_along(fit)){
#    matrix <- matrix(data=NA,nrow=5,ncol=5)
#    for(i in seq_len(5)){
#        for(j in seq_len(5)){
#            a <- select[[i]][[k]]
#            b <- select[[j]][[k]]
#            matrix[i,j] <- length(intersect(a,b))/length(union(a,b))
#        }
#    }
#    diag(matrix) <- NA
#    stability[k] <- mean(matrix,na.rm=TRUE)
#}
#cat(stability)
### end temporary ###
if(plot){
graphics::par(mar=c(3,3,1,1))
col <- rep(x=0,times=length(loss)-1)
col[1] <- col[length(col)] <- 1
graphics::plot.new()
graphics::plot.window(xlim=c(1,length(loss)-1),ylim=range(loss))
graphics::axis(side=1,at=seq_len(length(loss)-1),labels=names(loss)[-length(loss)])
graphics::axis(side=2)
graphics::points(y=loss[-length(loss)],
x=seq_len(length(loss)-1),
col=col+1,pch=col)
graphics::abline(v=c(1.5,length(loss)-1.5),lty=2)
graphics::grid()
graphics::abline(h=loss[length(loss)],lty=2,col="red")
}
return(loss)
}
colasso_compare(y=y,Y=Y,X=X)
graphics::box()
#################
### colasso ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
# consider scaling of responses!
colasso:::colasso_compare(y=y,Y=Y,X=X)
#################
### colasso ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
456
457
458
459
460
461
462
#pkg <- "E:/colasso/package/colasso"
setwd(pkg)
system("git remote set-url origin https://rauschenberger:Merkel0517@github.com/rauschenberger/colasso.git")
system("git remote -v")
system("git add --all")
system("git commit -m \"automation\"")
system("git push origin master") # GitHub
Armin Rauschenberger's avatar
Armin Rauschenberger committed
463
464
# Apply to simulated data.
set.seed(1)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
n <- 100
p <- 300
Sigma <- matrix(data=0.05,nrow=p,ncol=p)
X <- MASS::mvrnorm(n=n,mu=rep(0,p),Sigma=Sigma)
# X <- matrix(stats::rnorm(n*p),nrow=n,ncol=p)
beta <- rep(1,times=p)
beta[stats::rbinom(n=p,size=1,prob=0.95)==1] <- 0
mu <- X %*% beta
Y <- replicate(n=10,expr=stats::rnorm(n=n,mean=mu,sd=10))
plot(mu,rowMeans(Y))
cor <- cor(Y)
cor[row(cor)>=col(cor)] <- NA
median(cor,na.rm=TRUE)
y <- scale(Y[,1])
ym <- scale(rowMeans(Y[,-1]))
Y <- scale(Y)
colasso:::colasso_compare(y=y,Y=Y,X=X)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
setwd(pkg)
system("git remote set-url origin https://rauschenberger:Merkel0517@github.com/rauschenberger/colasso.git")
system("git remote -v")
system("git add --all")
system("git commit -m \"automation\"")
system("git push origin master") # GitHub
rm(list=ls())