Skip to content

Commit 29fc447

Browse files
committed
fixing IPA
1 parent 6ecf5ca commit 29fc447

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

slowtests/test-GLMnet.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
### test-GLMnet.R ---
2+
#----------------------------------------------------------------------
3+
## Author: Thomas Alexander Gerds
4+
## Created: okt 17 2025 (08:17)
5+
## Version:
6+
## Last-Updated: okt 17 2025 (11:33)
7+
## By: Thomas Alexander Gerds
8+
## Update #: 2
9+
#----------------------------------------------------------------------
10+
##
11+
### Commentary:
12+
##
13+
### Change Log:
14+
#----------------------------------------------------------------------
15+
##
16+
### Code:
17+
library(testthat)
18+
library(lava)
19+
library(data.table)
20+
test_that("penalized logistic regression", {
21+
m = lvm(X2~X1+X8)
22+
distribution(m,~X2) = binomial.lvm()
23+
regression(m,X2~X1+X8) = c(-.05,.07)
24+
set.seed(9)
25+
d = setDT(sim(m,1100))
26+
d[,table(X2)]
27+
fit = glm(X2~X1+X8,data = d,family = "binomial")
28+
lasso = GLMnet(X2~X1+X8,data = d,family = "binomial",alpha = 1)
29+
ridge = GLMnet(X2~X1+X8,data = d,family = "binomial",alpha = 0)
30+
31+
32+
})
33+
34+
35+
######################################################################
36+
### test-GLMnet.R ends here

slowtests/test-ipa.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
library(riskRegression)
2+
library(survival)
3+
library(data.table)
4+
library(testthat)
5+
library(randomForestSRC)
6+
test_that("ipa cv5 survival",{
7+
set.seed(8)
8+
learndat=sampleData(200,outcome="survival")
9+
testdat=sampleData(123,outcome="survival")
10+
cox1a = coxph(Surv(time,event)~X6,data=learndat,x=TRUE,y=TRUE)
11+
cox2a = coxph(Surv(time,event)~X7+X8+X9,data=learndat,x=TRUE,y=TRUE)
12+
set.seed(5)
13+
five <- Score(list("COX1"=cox1a,"COX2"=cox2a),formula=Surv(time,event)~1,data=learndat,times=5,B = 1,split.method="cv5",summary = "ipa",se.fit=TRUE,progress.bar=NULL)
14+
set.seed(5)
15+
loob <- Score(list("COX1"=cox1a,"COX2"=cox2a),formula=Surv(time,event)~1,data=learndat,times=5,summary = "ipa",split.method="loob",B=100,se.fit=TRUE,progress.bar=NULL,verbose = 0L)
16+
set.seed(5)
17+
loob_sans <- Score(list("COX1"=cox1a,"COX2"=cox2a),formula=Surv(time,event)~1,data=learndat,times=5,summary = "ipa",split.method="loob",B=100,se.fit=FALSE,progress.bar=NULL,verbose = 0L)
18+
set.seed(5)
19+
test <- Score(list("COX1"=cox1a,"COX2"=cox2a),formula=Surv(time,event)~1,data=testdat,times=5,summary = "ipa",se.fit=FALSE,progress.bar=NULL,verbose = 0L)
20+
set.seed(5)
21+
bootcv <- Score(list("COX1"=cox1a,"COX2"=cox2a),formula=Surv(time,event)~1,data=testdat,times=5,summary = "ipa",split.method = "bootcv",B = 5,se.fit=TRUE,progress.bar=NULL,verbose = 0L)
22+
})
23+

0 commit comments

Comments
 (0)