Skip to content

Commit 8ad2f63

Browse files
variable rename
1 parent a6fcd6e commit 8ad2f63

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

selectiveInference/R/funs.fixedCox.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if( sum(status==0)+sum(status==1)!=length(y)) stop("status vector must have valu
2929
vars=which(m)
3030
if(sum(m)>0){
3131
bhat=beta[beta!=0] #penalized coefs just for active variables
32-
s2=sign(bhat)
32+
sign_bhat=sign(bhat)
3333

3434
#check KKT
3535

@@ -40,7 +40,7 @@ if(sum(m)>0){
4040
res=residuals(aaa,type="score")
4141
if(!is.matrix(res)) res=matrix(res,ncol=1)
4242
scor=colSums(res)
43-
g=(scor+lambda*s2)/(2*lambda)
43+
g=(scor+lambda*sign_bhat)/(2*lambda)
4444
# cat(c(g,lambda,tol.kkt),fill=T)
4545
if (any(abs(g) > 1+tol.kkt) )
4646
warning(paste("Solution beta does not satisfy the KKT conditions",
@@ -49,9 +49,9 @@ scor=colSums(res)
4949
# Hessian of partial likelihood at the LASSO solution
5050
MM=vcov(aaa)
5151

52-
bbar=(bhat+lambda*MM%*%s2)
53-
A1=-(mydiag(s2))
54-
b1= -(mydiag(s2)%*%MM)%*%s2*lambda
52+
bbar=(bhat+lambda*MM%*%sign_bhat)
53+
A1=-(mydiag(sign_bhat))
54+
b1= -(mydiag(sign_bhat)%*%MM)%*%sign_bhat*lambda
5555

5656
temp=max(A1%*%bbar-b1)
5757

@@ -63,7 +63,7 @@ b1= -(mydiag(s2)%*%MM)%*%s2*lambda
6363
# the one sided p-values are a bit off
6464

6565
for(jj in 1:length(bbar)){
66-
vj=rep(0,length(bbar));vj[jj]=s2[jj]
66+
vj=rep(0,length(bbar));vj[jj]=sign_bhat[jj]
6767

6868

6969
junk=TG.pvalue(bbar, A1, b1, vj,MM)

selectiveInference/R/funs.fixedLogit.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fixedLogitLassoInf=function(x,y,beta,lambda,alpha=.1, type=c("partial"), tol.bet
3232
m=beta[-1]!=0 #active set
3333

3434
bhat=c(beta[1],beta[-1][beta[-1]!=0]) # intcpt plus active vars
35-
s2=sign(bhat)
35+
sign_bhat=sign(bhat)
3636
lam2m=diag(c(0,rep(lambda,sum(m))))
3737

3838

@@ -66,14 +66,14 @@ fixedLogitLassoInf=function(x,y,beta,lambda,alpha=.1, type=c("partial"), tol.bet
6666
# MM=solve(t(xxm)%*%w%*%xxm)
6767
MM=solve(scale(t(xxm),F,1/ww)%*%xxm)
6868
gm = c(0,-g[vars]*lambda) # gradient at LASSO solution, first entry is 0 because intercept is unpenalized
69-
# at exact LASSO solution it should be s2[-1]
69+
# at exact LASSO solution it should be sign_bhat[-1]
7070
dbeta = MM %*% gm
7171

72-
# bbar=(bhat+lam2m%*%MM%*%s2) # JT: this is wrong, shouldn't use sign of intercept anywhere...
72+
# bbar=(bhat+lam2m%*%MM%*%sign_bhat) # JT: this is wrong, shouldn't use sign of intercept anywhere...
7373
bbar = bhat - dbeta
7474

75-
A1=-(mydiag(s2))[-1,]
76-
b1= (s2 * dbeta)[-1]
75+
A1=-(mydiag(sign_bhat))[-1,]
76+
b1= (sign_bhat * dbeta)[-1]
7777

7878
tol.poly = 0.01
7979
if (max((A1 %*% bbar) - b1) > tol.poly)
@@ -87,7 +87,7 @@ fixedLogitLassoInf=function(x,y,beta,lambda,alpha=.1, type=c("partial"), tol.bet
8787

8888

8989
for(jj in 1:sum(m)){
90-
vj=c(rep(0,sum(m)+1));vj[jj+1]=s2[jj+1]
90+
vj=c(rep(0,sum(m)+1));vj[jj+1]=sign_bhat[jj+1]
9191
# compute p-values
9292
junk=TG.pvalue(bbar, A1, b1, vj, MM)
9393
pv[jj] = junk$pv

0 commit comments

Comments
 (0)