Skip to content

Commit 427e89c

Browse files
committed
Fixed a small bug in the coef functions for fs and lar: use of dec instead of decreasing in the call to coef.interpolate.
1 parent 4dac202 commit 427e89c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

selectiveInference/R/funs.common.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ standardize <- function(x, y, intercept, normalize) {
5656

5757
# Interpolation function to get coefficients
5858

59-
coef.interpolate <- function(betas, s, knots, dec=TRUE) {
59+
coef.interpolate <- function(beta, s, knots, decreasing=TRUE) {
6060
# Sort the s values
61-
o = order(s,dec=dec)
61+
o = order(s,decreasing=decreasing)
6262
s = s[o]
6363

6464
k = length(s)
6565
mat = matrix(rep(knots,each=k),nrow=k)
66-
if (dec) b = s >= mat
66+
if (decreasing) b = s >= mat
6767
else b = s <= mat
6868
blo = max.col(b,ties.method="first")
6969
bhi = pmax(blo-1,1)
@@ -73,7 +73,7 @@ coef.interpolate <- function(betas, s, knots, dec=TRUE) {
7373
p[i] = 0
7474
p[!i] = ((s-knots[blo])/(knots[bhi]-knots[blo]))[!i]
7575

76-
beta = t((1-p)*t(betas[,blo,drop=FALSE]) + p*t(betas[,bhi,drop=FALSE]))
76+
beta = t((1-p)*t(beta[,blo,drop=FALSE]) + p*t(beta[,bhi,drop=FALSE]))
7777
colnames(beta) = as.character(round(s,3))
7878
rownames(beta) = NULL
7979

selectiveInference/R/funs.fs.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ coef.fs <- function(object, s, ...) {
225225

226226
if (min(s)<0 || max(s)>k) stop(sprintf("s must be between 0 and %i",k))
227227
knots = 1:k
228-
dec = FALSE
229-
return(coef.interpolate(beta,s,knots,dec))
228+
decreasing = FALSE
229+
return(coef.interpolate(beta,s,knots,decreasing))
230230
}
231231

232232
# Prediction function for fs

selectiveInference/R/funs.lar.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ coef.lar <- function(object, s, mode=c("step","lambda"), ...) {
295295
if (mode=="step") {
296296
if (min(s)<0 || max(s)>k) stop(sprintf("s must be between 0 and %i",k))
297297
knots = 1:k
298-
dec = FALSE
298+
decreasing = FALSE
299299
} else {
300300
if (min(s)<min(lambda)) stop(sprintf("s must be >= %0.3f",min(lambda)))
301301
knots = lambda
302-
dec = TRUE
302+
decreasing = TRUE
303303
}
304304

305-
return(coef.interpolate(beta,s,knots,dec))
305+
return(coef.interpolate(beta,s,knots,decreasing))
306306
}
307307

308308
# Prediction function for lar

0 commit comments

Comments
 (0)