rauschenberger / starnet

@@ -83,11 +83,19 @@
Loading
83 83
#' for the base and meta learners, respectively.
84 84
#' 
85 85
#' @examples
86 +
#' \dontshow{
87 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
86 88
#' set.seed(1)
87 89
#' n <- 50; p <- 100
88 90
#' y <- rnorm(n=n)
89 91
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
90 -
#' object <- starnet(y=y,X=X,family="gaussian")
92 +
#' object <- starnet(y=y,X=X,family="gaussian")}}
93 +
#' \donttest{
94 +
#' set.seed(1)
95 +
#' n <- 50; p <- 100
96 +
#' y <- rnorm(n=n)
97 +
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
98 +
#' object <- starnet(y=y,X=X,family="gaussian")}
91 99
#' 
92 100
starnet <- function(y,X,family="gaussian",nalpha=21,alpha=NULL,nfolds=10,foldid=NULL,type.measure="deviance",alpha.meta=1,penalty.factor=NULL,intercept=NULL,upper.limit=NULL,unit.sum=NULL,...){
93 101
  
@@ -316,12 +324,21 @@
Loading
316 324
#' and \code{none} (intercept-only model).
317 325
#' 
318 326
#' @examples
327 +
#' \dontshow{
328 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
329 +
#' set.seed(1)
330 +
#' n <- 50; p <- 100
331 +
#' y <- rnorm(n=n)
332 +
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
333 +
#' object <- starnet(y=y,X=X)
334 +
#' y_hat <- predict(object,newx=X[c(1),,drop=FALSE])}}
335 +
#' \donttest{
319 336
#' set.seed(1)
320 337
#' n <- 50; p <- 100
321 338
#' y <- rnorm(n=n)
322 339
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
323 340
#' object <- starnet(y=y,X=X)
324 -
#' y_hat <- predict(object,newx=X[c(1),,drop=FALSE])
341 +
#' y_hat <- predict(object,newx=X[c(1),,drop=FALSE])}
325 342
#' 
326 343
predict.starnet <- function(object,newx,type="response",nzero=NULL,...){
327 344
  if(length(list(...))!=0){warning("Ignoring argument.",call.=FALSE)}
@@ -384,12 +401,21 @@
Loading
384 401
#' respectively.
385 402
#' 
386 403
#' @examples
404 +
#' \dontshow{
405 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
406 +
#' set.seed(1)
407 +
#' n <- 50; p <- 100
408 +
#' y <- rnorm(n=n)
409 +
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
410 +
#' object <- starnet(y=y,X=X)
411 +
#' coef <- coef(object)}}
412 +
#' \donttest{
387 413
#' set.seed(1)
388 414
#' n <- 50; p <- 100
389 415
#' y <- rnorm(n=n)
390 416
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
391 417
#' object <- starnet(y=y,X=X)
392 -
#' coef <- coef(object)
418 +
#' coef <- coef(object)}
393 419
#' 
394 420
coef.starnet <- function(object,nzero=NULL,...){
395 421
  if(length(list(...))!=0){warning("Ignoring argument.",call.=FALSE)}
@@ -446,12 +472,21 @@
Loading
446 472
#' Vector containing intercept and slopes from the meta learner.
447 473
#' 
448 474
#' @examples
475 +
#' \dontshow{
476 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
477 +
#' set.seed(1)
478 +
#' n <- 50; p <- 100
479 +
#' y <- rnorm(n=n)
480 +
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
481 +
#' object <- starnet(y=y,X=X)
482 +
#' weights(object)}}
483 +
#' \donttest{
449 484
#' set.seed(1)
450 485
#' n <- 50; p <- 100
451 486
#' y <- rnorm(n=n)
452 487
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
453 488
#' object <- starnet(y=y,X=X)
454 -
#' weights(object)
489 +
#' weights(object)}
455 490
#' 
456 491
weights.starnet <- function(object,...){
457 492
  if(length(list(...))!=0){warning("Ignoring argument.",call.=FALSE)}
@@ -480,12 +515,21 @@
Loading
480 515
#' Prints "stacked gaussian/binomial/poisson elastic net".
481 516
#' 
482 517
#' @examples
518 +
#' \dontshow{
519 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
483 520
#' set.seed(1)
484 521
#' n <- 50; p <- 100
485 522
#' y <- rnorm(n=n)
486 523
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
487 524
#' object <- starnet(y=y,X=X)
488 -
#' print(object)
525 +
#' print(object)}}
526 +
#' \donttest{
527 +
#' set.seed(1)
528 +
#' n <- 50; p <- 100
529 +
#' y <- rnorm(n=n)
530 +
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
531 +
#' object <- starnet(y=y,X=X)
532 +
#' print(object)}
489 533
#' 
490 534
print.starnet <- function(x,...){
491 535
  cat(paste0("stacked \"",x$info$family,"\" elastic net"),"\n")
@@ -533,12 +577,13 @@
Loading
533 577
#' with the maximum number of non-zero coefficients shown in the column name.
534 578
#' 
535 579
#' @examples
580 +
#' \dontshow{
581 +
#' if(!grepl('SunOS',Sys.info()['sysname'])){
536 582
#' set.seed(1)
537 583
#' n <- 50; p <- 20
538 584
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
539 585
#' y <- rnorm(n=n,mean=rowSums(X[,1:20]))
540 -
#' \dontshow{
541 -
#' loss <- cv.starnet(y=y,X=X,nfolds.ext=2,nfolds.int=3)}
586 +
#' loss <- cv.starnet(y=y,X=X,nfolds.ext=2,nfolds.int=3)}}
542 587
#' \donttest{
543 588
#' loss <- cv.starnet(y=y,X=X)}
544 589
#' 
Files Coverage
R/functions.R 50.27%
Project Totals (1 files) 50.27%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading