Skip to content

Commit f5122a1

Browse files
committed
update to match CRAN requirements
1 parent 2771e57 commit f5122a1

10 files changed

Lines changed: 33 additions & 21 deletions

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ importFrom(stats,na.omit)
119119
importFrom(stats,predict)
120120
importFrom(stats,quantile)
121121
importFrom(stats,sd)
122+
importFrom(stats,setNames)
122123
importFrom(stats,terms.formula)
123124
importFrom(stats,variable.names)
124125
importFrom(utils,getS3method)
125126
importFrom(utils,packageDescription)
127+
importFrom(utils,relist)
126128
importFrom(zoo,na.locf)

R/FDboost-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' Details on the functional regression models that can be fitted with \pkg{FDboost}
1515
#' can be found in Brockhaus et al. (2015, 2017, 2018) and Ruegamer et al. (2018).
1616
#' A hands-on tutorial for the package can be found
17-
#' in Brockhaus, Ruegamer and Greven (2020), see \url{https://doi.org/10.18637/jss.v094.i10}.
17+
#' in Brockhaus, Ruegamer and Greven (2020), see <doi:10.18637/jss.v094.i10>.
1818
#' For density-on-scalar regression models see Maier et al. (2021).
1919
#'
2020
#' Using component-wise gradient boosting as fitting procedure, \pkg{FDboost} relies on

R/FDboost.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@
431431
#' @import methods Matrix mboost
432432
#' @importFrom grDevices heat.colors rgb
433433
#' @importFrom graphics abline barplot contour legend lines matplot par persp plot points
434-
#' @importFrom utils getS3method packageDescription
435-
#' @importFrom stats approx as.formula coef complete.cases fitted formula lm median model.matrix model.weights na.omit predict quantile sd terms.formula variable.names
434+
#' @importFrom utils relist getS3method packageDescription
435+
#' @importFrom stats setNames approx as.formula coef complete.cases fitted formula lm median model.matrix model.weights na.omit predict quantile sd terms.formula variable.names
436436
#' @importFrom gamboostLSS GaussianLSS GaussianMu GaussianSigma make.grid cvrisk.mboostLSS mboostLSS_fit
437437
#' @importFrom stabs stabsel stabsel_parameters
438438
#' @importFrom splines bs splineDesign
@@ -471,8 +471,8 @@ FDboost <- function(formula, ### response ~ xvars
471471
}
472472

473473
## check formulas
474-
if(class(try(id)) == "try-error") stop("id must either be NULL or a formula object.")
475-
if(missing(timeformula) || class(try(timeformula)) == "try-error")
474+
if(inherits(try(id), "try-error")) stop("id must either be NULL or a formula object.")
475+
if(missing(timeformula) || inherits(try(timeformula), "try-error"))
476476
stop("timeformula must either be NULL or a formula object.")
477477
stopifnot(class(formula) == "formula")
478478
if(!is.null(timeformula)) stopifnot(class(timeformula) == "formula")
@@ -817,7 +817,7 @@ FDboost <- function(formula, ### response ~ xvars
817817
}else{
818818
bl_df <- vector("list", length(tmp))
819819
bl_df[equalBrackets] <- lapply(tmp[equalBrackets], function(x) try(get_df(x)))
820-
bl_df <- unlist(bl_df[equalBrackets & (!sapply(bl_df, class) %in% "try-error")])
820+
bl_df <- unlist(bl_df[equalBrackets & (!sapply(bl_df, function(x) inherits(x, "try-error")))])
821821
#print(bl_df)
822822

823823
if( !is.null(bl_df) && any(abs(bl_df - bl_df[1]) > .Machine$double.eps * 10^10) ){
@@ -1066,7 +1066,7 @@ FDboost <- function(formula, ### response ~ xvars
10661066
silent = offset_control$silent )
10671067
}
10681068

1069-
if(any(class(modOffset) == "try-error")){
1069+
if(inherits(modOffset, "try-error")){
10701070
warning(paste("Could not fit the smooth offset by adaptive splines (default), use a simple spline expansion with 5 df instead.",
10711071
if(offset_control$cyclic) "This offset is not cyclic!"))
10721072
if(round(length(time)/2) < 8) warning("Most likely because of too few time-points.")
@@ -1121,7 +1121,7 @@ FDboost <- function(formula, ### response ~ xvars
11211121
silent = offset_control$silent )
11221122
}
11231123

1124-
if(any(class(modOffset) == "try-error")){
1124+
if(inherits(modOffset, "try-error")){
11251125
warning(paste("Could not fit the smooth offset by adaptive splines (default), use a simple spline expansion with 5 df instead.",
11261126
if(offset_control$cyclic) "This offset is not cyclic!"))
11271127
if(round(length(time)/2) < 8) warning("Most likely because of too few time-points.")

R/methods.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ coef.FDboost <- function(object, raw = FALSE, which = NULL,
12841284

12851285
## short names for the terms, if shortnames() does not work, use the original names
12861286
shrtlbls <- try(unlist(lapply(names(object$baselearner), shortnames)))
1287-
if(class(shrtlbls)=="try-error") shrtlbls <- names(object$baselearner)
1287+
if(inherits(shrtlbls, "try-error")) shrtlbls <- names(object$baselearner)
12881288

12891289
###### just return the data that is used for the prediction
12901290
if(returnData){
@@ -1697,14 +1697,14 @@ plot.FDboost <- function(x, raw = FALSE, rug = TRUE, which = NULL,
16971697
rm(temp)
16981698
}
16991699

1700-
if(class(terms)!="list") terms <- list(terms)
1700+
if(!inherits(terms,"list")) terms <- list(terms)
17011701
if(mstop(x) > 0 && length(which) == 1 && which == 0) terms[[1]] <- offset
17021702
if(length(which) == 1 && length(terms[[1]]) == 1 && terms[[1]] == 0){ terms[[1]] <- rep(0, l=length(x$yind)) }
17031703

17041704
#if(length(which)==1 && !any(class(x)=="FDboostLong")) terms <- list(terms)
17051705

17061706
shrtlbls <- try(coef(x, which=which, computeCoef=FALSE))# get short names
1707-
if(class(shrtlbls) == "try-error"){
1707+
if(inherits(shrtlbls, "try-error")){
17081708
shrtlbls <- names(x$baselearner)[which[which!=0]]
17091709
if(0 %in% which) shrtlbls <- c("offset", which)
17101710
}

man/FDboost-package.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/factorize.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/factorize_test_irregular.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ par(opar)
8282
fac <- factorize(m)
8383

8484
vi <- as.data.frame(varimp(fac$cov))
85-
lattice::barchart(variable ~ reduction, group = blearner, vi, stack = TRUE)
85+
# if(require(lattice))
86+
# barchart(variable ~ reduction, group = blearner, vi, stack = TRUE)
8687

8788
cbind(d^2, sort(vi$reduction, decreasing = TRUE)[1:3])
8889

@@ -162,11 +163,13 @@ for(w in 1:length(wch)) {
162163
main = names(fac$resp$baselearner[wch[w]]))
163164

164165
lines(sort(griddata$t),
165-
ratio*predict(fac2$resp, which = wch[w])[order(griddata$t)], col = cols[w], lty = 2)
166+
ratio*predict(fac2$resp, which = wch[w])[order(griddata$t)],
167+
col = cols[w], lty = 2)
166168
plot(fac$cov, which = wch[w],
167169
main = names(fac$cov$baselearner[wch[w]]))
168170
this_x <- fac2$cov$model.frame(which = wch[w])[[1]][[1]]
169-
lines(sort(this_x), 1/ratio*predict(fac2$cov, which = wch[w])[order(this_x)], col = cols[w], lty = 1)
171+
lines(sort(this_x), 1/ratio*predict(fac2$cov, which = wch[w])[order(this_x)],
172+
col = cols[w], lty = 1)
170173
}
171174
par(opar)
172175

tests/factorize_test_regular.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ par(opar)
6565
fac <- factorize(m)
6666

6767
vi <- as.data.frame(varimp(fac$cov))
68-
lattice::barchart(variable ~ reduction, group = blearner, vi, stack = TRUE)
68+
# if(require(lattice))
69+
# barchart(variable ~ reduction, group = blearner, vi, stack = TRUE)
6970

7071
cbind(d^2, vi$reduction[c(1:2, 10)])
7172

vignettes/density-on-scalar_birth.Rnw

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
\usepackage{authblk}
1111
\usepackage[left=25mm, right=25mm, top=20mm, bottom=20mm]{geometry}
1212
%\usepackage[nolists]{endfloat}
13+
%\usepackage{mathspec}
14+
\usepackage{dsfont}
1315
\usepackage{bbm}
1416

1517
%\VignetteEngine{knitr::knitr}
@@ -211,7 +213,7 @@ In the continuous case, the sum is proportional to the integral numerically, if
211213
Thus, using \texttt{bbsc} is suitable in this case, as well.
212214
Second, we must specify the B-spline basis in \texttt{bbsc} appropriately.
213215
The continuous case is straightforward, e.g., by using cubic B-splines.
214-
In our discrete case, a suitable (unconstrained) basis is $(\mathbbm{1}_{\{1\}}, \ldots, \mathbbm{1}_{\{12\}}) \in L^2 ( \delta)^{12}$, where $\mathbbm{1}_{A}$ denotes the indicator function of $A \in \mathcal{A}$.
216+
In our discrete case, a suitable (unconstrained) basis is $(\mathds{1}_{\{1\}}, \ldots, \mathds{1}_{\{12\}}) \in L^2 ( \delta)^{12}$, where $\mathds{1}_{A}$ denotes the indicator function of $A \in \mathcal{A}$.
215217
This results in the identity matrix as design matrix.
216218
In \texttt{bbs()} (or \texttt{bbsc()}, which yields the corresponding constrained basis), this can be achieved using \texttt{degree = 1} with knots equal to $\mathcal{T}$.
217219

-165 KB
Binary file not shown.

0 commit comments

Comments
 (0)