Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98ac603

Browse files
authored
Merge 0.1.8 pull request#38 from CenterForStatistics-UGent/devel
Release 0.1.8 pull
2 parentse7e4fbb +6df0a43 commit98ac603

38 files changed

+1937
-112
lines changed

‎DESCRIPTION‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Package: xnet
22
Type: Package
3-
Title:twostep kernel ridge regression fornetwork predictions
4-
Version: 0.1.7
3+
Title:Two-Step Kernel Ridge Regression forNetwork Predictions
4+
Version: 0.1.8
55
Authors@R: c(person("Joris","Meys", email = "Joris.Meys@UGent.be", role
66
= c("cre","aut")), person("Michiel", "Stock", email =
77
"Michiel.Stock@UGent.be", role = "aut"))
8-
Description:This package implementstwo-step kernel ridge regression
9-
for predictingedges in networks,together with many
10-
cross-validationshortcuts for swift and accurate performance
11-
assessment<doi:10.1093/bib/bby095>.
12-
Date: 2019-03-28
8+
Description:Fit atwo-step kernel ridge regression for predicting
9+
edges in networks,and carry out cross-validation using
10+
shortcuts for swift and accurate performance assessment
11+
<doi:10.1093/bib/bby095>.
12+
Date: 2019-04-04
1313
BugReports: https://github.com/CenterForStatistics-UGent/xnet/issues
1414
URL: https://github.com/CenterForStatistics-UGent/xnet
1515
Depends: R(>= 3.4.0)
16-
Imports: methods, utils
16+
Imports: methods, utils, graphics, stats, grDevices
1717
License: GPL-3
1818
Encoding: UTF-8
1919
LazyData: true
2020
RoxygenNote: 6.1.1
21-
Suggests: testthat, knitr, rmarkdown, ChemmineR, covr
21+
Suggests: testthat, knitr, rmarkdown, ChemmineR, covr, fmcsR
2222
VignetteBuilder: knitr
2323
Collate: 'Class_linearFilter.R' 'Class_tskrr.R'
2424
'Class_tskrrHeterogenous.R' 'Class_tskrrImpute.R'
@@ -32,7 +32,8 @@ Collate: 'Class_linearFilter.R' 'Class_tskrr.R'
3232
'getters_tskrrImpute.R' 'getters_tskrrTune.R' 'hat.R'
3333
'impute_tskrr.R' 'impute_tskrr.fit.R' 'is_symmetric.R'
3434
'labels.R' 'linear_filter.R' 'loo.R' 'looInternal.R' 'loss.R'
35-
'loss_functions.R' 'match_labels.R' 'predict.R'
36-
'prepare_lambdas.R' 'test_input.R' 'test_symmetry.R' 'tskrr.R'
37-
'tskrr.fit.R' 'tune.R' 'update.R' 'valid_dimensions.R'
38-
'valid_labels.R' 'weights.R' 'xnet-package.R'
35+
'loss_functions.R' 'match_labels.R' 'plot.tskrr.R'
36+
'plot_grid.R' 'predict.R' 'prepare_lambdas.R' 'residuals.R'
37+
'test_input.R' 'test_symmetry.R' 'tskrr.R' 'tskrr.fit.R'
38+
'tune.R' 'update.R' 'valid_dimensions.R' 'valid_labels.R'
39+
'weights.R' 'xnet-package.R'

‎NAMESPACE‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ S3method(fitted,linearFilter)
44
S3method(fitted,tskrr)
55
S3method(labels,tskrr)
66
S3method(mean,linearFilter)
7+
S3method(plot,tskrr)
78
S3method(predict,tskrr)
9+
S3method(residuals,tskrr)
810
export(alpha)
911
export(create_grid)
1012
export(eigen2hat)
@@ -29,6 +31,8 @@ export(loss_auc)
2931
export(loss_mse)
3032
export(match_labels)
3133
export(na_removed)
34+
export(plot_grid)
35+
export(residuals)
3236
export(symmetry)
3337
export(test_symmetry)
3438
export(tskrr)
@@ -60,11 +64,34 @@ exportMethods(loss)
6064
exportMethods(mean)
6165
exportMethods(na_removed)
6266
exportMethods(predict)
67+
exportMethods(residuals)
6368
exportMethods(response)
6469
exportMethods(rowMeans)
6570
exportMethods(rownames)
6671
exportMethods(tune)
6772
exportMethods(update)
6873
exportMethods(weights)
6974
import(methods)
75+
importFrom(grDevices,dev.flush)
76+
importFrom(grDevices,dev.hold)
77+
importFrom(grDevices,heat.colors)
78+
importFrom(graphics,abline)
79+
importFrom(graphics,axis)
80+
importFrom(graphics,box)
81+
importFrom(graphics,contour)
82+
importFrom(graphics,frame)
83+
importFrom(graphics,image)
84+
importFrom(graphics,layout)
85+
importFrom(graphics,mtext)
86+
importFrom(graphics,par)
87+
importFrom(graphics,plot)
88+
importFrom(graphics,plot.new)
89+
importFrom(graphics,plot.window)
90+
importFrom(graphics,points)
91+
importFrom(graphics,rect)
92+
importFrom(graphics,title)
93+
importFrom(stats,as.dendrogram)
94+
importFrom(stats,as.dist)
95+
importFrom(stats,hclust)
96+
importFrom(stats,order.dendrogram)
7097
importFrom(utils,str)

‎NEWS.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
##xnet 0.1.8
2+
3+
###Breaking changes
4+
5+
* For consistency, the arguments`K` and`G` for the function`predict()`
6+
have been renamed`k` and`g` (lower case).
7+
*`loo` now adds the labels to the output (except for linear filters)
8+
9+
###New features
10+
11+
*`tune` now allows for a one-dimensional grid search for heterogenous
12+
networks. Set`onedim = TRUE` to avoid a full grid search.
13+
*`has_onedim` tells whether the grid search was one dimensional or not.
14+
This is a getter for the appropriate slote in the tskrrTune class.
15+
*`plot_grid` allows you to plot the loss in function of the
16+
searched grid after tuning a model. It deals with both 1D and
17+
2D grids and can be used for quick evaluation of the optimal
18+
lambda values.
19+
*`residuals` allows you to calculate the residuals based on
20+
the predictions or on the loo values of choice.
21+
* There's a`plot` method available now for`tskrr` objects. It
22+
allows to plot fitted values, residuals, original response and
23+
the results of different loo settings, together with dendrograms
24+
based on the kernel matrices.
25+
26+
###Bug fixes and minor improvements
27+
28+
*`predict` didn't give correct output when only`g` was passed.
29+
fixed.
30+
*`colnames` didn't get the correct labels for homogenous networks
31+
32+
133
##xnet 0.1.7
234

335
###Breaking changes

‎R/Class_tskrrHomogenous.R‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ validTskrrHomogenous <- function(object){
4848
)
4949
return("The element k should either be NA or a character vector with the same number of values as there are rows in the Y matrix.")
5050

51-
5251
else
5352
return(TRUE)
5453
}

‎R/Class_tskrrTune.R‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#' @slot exclusion a character value describing the exclusion used
1919
#' @slot replaceby0 a logical value indicating whether or not the cross
2020
#' validation replaced the excluded values by zero
21+
#' @slot onedim a logical value indicating whether the grid search
22+
#' was done in one dimension. For homogenous networks, this is
23+
#' true by default.
2124
#'
2225
#' @seealso
2326
#' * the function \code{tune} for the tuning itself
@@ -35,7 +38,8 @@ setClass("tskrrTune",
3538
loss_values="matrix",
3639
loss_function="function",
3740
exclusion="character",
38-
replaceby0="logical"))
41+
replaceby0="logical",
42+
onedim="logical"))
3943

4044
validTskrrTune<-function(object){
4145

@@ -55,6 +59,9 @@ validTskrrTune <- function(object){
5559

5660
if(object@replaceby0&&excl!="interaction")
5761
return("replaceby0 can only be used with interaction exclusion")
62+
63+
if(length(object@onedim)!=1)
64+
return("onedim should be a single logical value.")
5865
else
5966
return(TRUE)
6067
}
@@ -91,6 +98,8 @@ setMethod("show",
9198
cat("exclusion setting:",object@exclusion,"\n")
9299
cat("loss value:",object@best_loss,"\n")
93100
cat("loss function:",loss_name,"\n")
101+
if(object@onedim&& is_heterogenous(object))
102+
cat("Grid search done in one dimension.\n")
94103

95104
})
96105

‎R/Class_tskrrTuneHeterogenous.R‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,27 @@ validTskrrTuneHeterogenous <- function(object){
1717
lossval<-object@loss_values
1818
lgrid<-object@lambda_grid
1919
excl<-object@exclusion
20+
onedim<-object@onedim
2021

21-
if(any(names(lgrid)!= c("k","g")))
22+
if(!onedim&&any(names(lgrid)!= c("k","g")))
2223
return("lambda grid should be a list with two elements named k and g (in that order) for heterogenous networks")
24+
elseif(onedim&& any(names(lgrid)!="k")&& length(lgrid)>1)
25+
return("in a one-dimensional search there should only be a single element named k in the lambda grid.")
2326

24-
if(nrow(lossval)!= length(lgrid$k)||
25-
ncol(lossval)!= length(lgrid$g))
26-
return(paste("Loss values should have",length(lgrid$k),"rows and",length(lgrid$g),"columns to match the lambda grid."))
27+
if(nrow(lossval)!= length(lgrid$k))
28+
return(paste("Loss values should have",length(lgrid$k),"rows to match the lambda grid."))
29+
30+
if(!onedim&& ncol(lossval)!= length(lgrid$g))
31+
return(paste("Loss values should have",length(lgrid$g),"columns to match the lambda grid."))
32+
elseif(onedim&& ncol(lossval)!=1)
33+
return(paste("Loss values should have one column in case of one-dimensional search."))
2734

2835
exclmatch<- match(excl, c("interaction","row","column","both"),
2936
nomatch=0L)
3037
if(exclmatch==0)
3138
return("exclusion should be one of 'interaction', 'row', 'column' or 'both'")
39+
else
40+
return(TRUE)
3241

3342
}
3443

‎R/Class_tskrrTuneHomogenous.R‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ validTskrrTuneHomogenous <- function(object){
3030
if(exclmatch==0)
3131
return("exclusion should be either 'interaction' or 'both' for homogenous networks.")
3232

33+
elseif(!object@onedim)
34+
return("grid search can only be done in one dimension for a homogenous network.")
35+
else
36+
return(TRUE)
37+
3338
}
3439

3540
setValidity("tskrrTuneHomogenous",validTskrrTuneHomogenous)

‎R/all_generics.R‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ setGeneric("as_tskrr", function(x, ...) standardGeneric("as_tskrr"))
6262

6363
#' @rdname loss
6464
#' @export
65-
setGeneric("loss", function(x, ...) standardGeneric("loss"))
65+
setGeneric("loss", function(x, ...) standardGeneric("loss"))
66+
67+
#' @rdname residuals.tskrr
68+
#' @export
69+
setGeneric("residuals")

‎R/getters_tskrrTune.R‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,12 @@ get_loss_values <- function(x){
6464
if(!inherits(x,"tskrrTune")) stop("x should be a tuned model.")
6565
x@loss_values
6666
}
67+
68+
#' @return for \code{is_onedim} a single logical value telling whether the
69+
#' grid search in the object was onedimensional.
70+
#' @rdname getters-tskrrTune
71+
#' @aliases has_onedim
72+
has_onedim<-function(x){
73+
if(!inherits(x,"tskrrTune")) stop("x should be a tuned model.")
74+
x@onedim
75+
}

‎R/labels.R‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
#' These functions allow you to extract the labels from a
44
#' \code{\link{tskrr}} object. The function \code{labels} and the
55
#' function \code{dimnames} are aliases and do the exact same
6-
#' thing.
6+
#' thing. The functions \code{rownames} and \code{colnames} work like
7+
#' you would expect. Note that contrary to the latter two, \code{labels}
8+
#' will never return \code{NULL}. If no labels are found, it will construct
9+
#' labels using the prefixes defined in the argument \code{prefix}.
710
#'
8-
#' The functions \code{colnames} and \code{rownames} work like you would
9-
#' expect, with one difference: the rownames or colnames for a \code{tskrr}
10-
#' object can never be \code{NULL}.
11+
#' @section Warning:
12+
#' If the original data didn't contain row- or column names for the
13+
#' adjacency matrix, \code{rownames} and \code{colnames} will return
14+
#' \code{NULL}. Other functions will extract the automatically generated
15+
#' labels, so don't count on \code{rownames} and \code{colnames} if you
16+
#' want to predict output from other functions!
1117
#'
1218
#' @param x a \code{\link{tskrr}} object
1319
#' @param object a \code{\link{tskrr}} object
@@ -101,7 +107,7 @@ setMethod("rownames",
101107
setMethod("colnames",
102108
"tskrr",
103109
function(x,do.NULL=TRUE,prefix="col"){
104-
rn<-x@labels$g
110+
rn<-if(is_homogenous(x))x@labels$kelsex@labels$g
105111

106112
nolabels<- length(rn)==1&& is.na(rn)
107113

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp