Skip to content

Commit 2cca8a7

Browse files
added print method, getting warning about doc
1 parent 94a6556 commit 2cca8a7

File tree

5 files changed

+78
-23
lines changed

5 files changed

+78
-23
lines changed

selectiveInference/NAMESPACE

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
export(lar,fs,
2-
larInf,fsInf,
3-
coef.lar,coef.fs,
4-
predict.lar,predict.fs,
5-
print.lar,print.fs,
6-
print.larInf,print.fsInf,
7-
plot.lar,plot.fs,
8-
fixedLassoInf,print.fixedLassoInf,
1+
export(lar,
2+
fs,
3+
larInf,
4+
fsInf,
5+
coef.lar,
6+
coef.fs,
7+
predict.lar,
8+
predict.fs,
9+
print.lar,
10+
print.fs,
11+
print.larInf,
12+
print.fsInf,
13+
plot.lar,
14+
plot.fs,
15+
fixedLassoInf,
16+
print.fixedLassoInf,
917
forwardStop,
1018
estimateSigma,
11-
manyMeans,print.manyMeans,
12-
groupfs,groupfsInf,
13-
scaleGroups,factorDesign,
19+
manyMeans,
20+
print.manyMeans,
21+
groupfs,
22+
groupfsInf,
23+
scaleGroups,
24+
factorDesign,
1425
TG.pvalue,
1526
TG.limits,
1627
TG.interval,
1728
debiasingMatrix,
1829
randomizedLasso,
1930
randomizedLassoInf,
20-
ROSI
31+
ROSI,
32+
print.ROSI
2133
)
2234

2335
S3method("coef", "lar")
@@ -31,6 +43,7 @@ S3method("print", "fs")
3143
S3method("plot", "fs")
3244
S3method("print", "fsInf")
3345
S3method("print", "fixedLassoInf")
46+
S3method("print", "ROSI")
3447
S3method("print", "fixedLogitLassoInf")
3548
S3method("print", "fixedCoxLassoInf")
3649
S3method("print", "manyMeans")

selectiveInference/R/funs.full.main.R renamed to selectiveInference/R/funs.ROSI.R

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,11 @@ ROSI = function(X,
399399
construct_ci=TRUE,
400400
debiasing_method=c("JM", "BN"),
401401
verbose=FALSE,
402+
level=0.9,
402403
use_debiased=TRUE) {
403404

405+
this.call = match.call()
406+
404407
family = match.arg(family)
405408
solver = match.arg(solver)
406409
debiasing_method = match.arg(debiasing_method)
@@ -502,29 +505,59 @@ ROSI = function(X,
502505
if (construct_ci) {
503506
sel_int = create_tnorm_interval(z=target_stat,
504507
sd=sqrt(target_cov) * sigma_est,
505-
alpha=0.1,
508+
alpha=1-level,
506509
intervals=intervals)
507510
if (verbose==TRUE){
508511
cat("sel interval", sel_int, "\n")
509512
}
510-
sel_intervals = cbind(sel_intervals, sel_int)
513+
sel_intervals = rbind(sel_intervals, sel_int)
511514
}
512515
} else {
513516
pvalues = c(pvalues, NA)
514-
sel_intervals = cbind(sel_intervals, c(NA, NA))
517+
sel_intervals = rbind(sel_intervals, c(NA, NA))
515518
warning("observation not within the truncation limits!")
516519
}
517520
}
518521

519-
return(list(pvalues=pvalues,
520-
active_set=active_set,
521-
intervals=sel_intervals,
522-
estimate=beta_barE,
523-
std_err=sqrt(diag(QiE) * dispersion),
524-
lower_trunc=lower_trunc,
525-
upper_trunc=upper_trunc))
522+
out = list(pvalues=pvalues,
523+
active_set=active_set,
524+
intervals=sel_intervals,
525+
estimate=as.numeric(beta_barE),
526+
std_err=sqrt(diag(QiE) * dispersion),
527+
dispersion=dispersion,
528+
lower_trunc=as.numeric(lower_trunc),
529+
upper_trunc=as.numeric(upper_trunc),
530+
lambda=lambda,
531+
penalty_factor=penalty_factor,
532+
level=level,
533+
call=this.call)
534+
class(out) = "ROSI"
535+
return(out)
536+
}
537+
538+
print.ROSI <- function(x, ...) {
539+
cat("\nCall:\n")
540+
dput(x$call)
541+
542+
cat(sprintf("\nDispersion taken to be dispersion = %0.3f\n",
543+
x$dispersion))
544+
545+
cat(sprintf("\nTesting results at lambda = %0.3f, with level = %0.2f\n",x$lambda,x$level))
546+
cat("",fill=T)
547+
tab = cbind(signif(x$std_err^2,3),
548+
round(x$estimate,3),
549+
round(x$estimate / x$std_err,3),
550+
round(x$pvalues,3),
551+
round(x$intervals,3))
552+
colnames(tab) = c("Var", "Coef", "Z-score", "P-value", "LowConfPt", "UpConfPt")
553+
rownames(tab) = rep("",nrow(tab))
554+
print(tab)
555+
556+
cat("\nNote: coefficients shown are full regression coefficients.\n")
557+
invisible()
526558
}
527559

560+
528561
# Some little used functions -- not exported
529562

530563

selectiveInference/man/ROSI.Rd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ROSI(X,
2020
construct_ci=TRUE,
2121
debiasing_method=c("JM", "BN"),
2222
verbose=FALSE,
23+
level=0.9,
2324
use_debiased=TRUE)
2425
}
2526
\arguments{
@@ -79,6 +80,9 @@ or "BN" (method described in arxiv.org/1703.03282).
7980
\item{verbose}{
8081
Print out progress along the way? Default is FALSE.
8182
}
83+
\item{level}{
84+
Confidence level for intervals.
85+
}
8286
\item{use_debiased}{
8387
Use the debiased estimate of the parameter or not. When FALSE, this is the
8488
method desribed in arxiv.org/1801.09037. The default TRUE often
@@ -96,8 +100,13 @@ p is comparable to n. Ignored when n<p and set to TRUE.
96100
\item{intervals}{Confidence intervals}
97101
\item{estimate}{Relaxed (i.e. unshrunk) selected estimates.}
98102
\item{std_err}{Standard error of relaxed estimates (pre-selection).}
103+
\item{dispersion}{Dispersion parameter.}
99104
\item{lower_trunc}{Lower truncation point. The estimates should be outside the interval formed by the lower and upper truncation poitns.}
100105
\item{upper_trunc}{Lower truncation point. The estimates should be outside the interval formed by the lower and upper truncation poitns.}
106+
\item{lambda}{Value of tuning parameter lambda used.}
107+
\item{penalty_factor}{Penalty factor used for solving problem.}
108+
\item{level}{Confidence level.}
109+
\item{call}{The call to fixedLassoInf.}
101110
}
102111

103112
\references{

selectiveInference/man/fixedLassoInf.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ for the model fit to the active set from the lasso.
142142
\item{sign}{Signs of active coefficients}
143143
\item{alpha}{Desired coverage (alpha/2 in each tail)}
144144
\item{sigma}{Value of error standard deviation (sigma) used}
145-
\item{call}{The call to lassoInf}
145+
\item{call}{The call to fixedLassoInf}
146146
}
147147
148148
\references{

0 commit comments

Comments
 (0)