Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhongc committed Nov 24, 2021
1 parent 8a7c0b3 commit 0c50701
Show file tree
Hide file tree
Showing 78 changed files with 2,039 additions and 485 deletions.
914 changes: 504 additions & 410 deletions .Rhistory

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .Rproj.user/3992D3D4/pcs/debug-breakpoints.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"debugBreakpointsState": {
"breakpoints": []
}
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/pcs/files-pane.pper
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ascending": true
}
],
"path": "H:/UbuntuRv2/IBGS/IBGS/R"
"path": "H:/UbuntuRv2/IBGS/IBGS"
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab": 1
"activeTab": 3
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TabSet1": 0,
"TabSet2": 0,
"TabSet2": 2,
"TabZoom": {}
}
5 changes: 5 additions & 0 deletions .Rproj.user/3992D3D4/rmd-outputs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
H:/UbuntuRv2/TCGS/IBGS.pdf
H:/UbuntuRv2/TCGS/IBGS.pdf
H:/UbuntuRv2/TCGS/IBGS.pdf
H:/UbuntuRv2/TCGS/IBGS.pdf
H:/UbuntuRv2/TCGS/IBGS.pdf



Expand Down
1 change: 1 addition & 0 deletions .Rproj.user/3992D3D4/sources/prop/354CB43F
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/5380A78C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled2",
"cursorPosition": "0,3",
"cursorPosition": "23,37",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/63A0B237
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled2",
"cursorPosition": "5,0",
"cursorPosition": "38,31",
"scrollLine": "0"
}
1 change: 1 addition & 0 deletions .Rproj.user/3992D3D4/sources/prop/6B6242EF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions .Rproj.user/3992D3D4/sources/prop/7C8C31A9
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tempName": "Untitled3",
"cursorPosition": "20,0",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/7EC5EA7B
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "17,0",
"cursorPosition": "7,70",
"scrollLine": "0"
}
4 changes: 4 additions & 0 deletions .Rproj.user/3992D3D4/sources/prop/86C3D5DC
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cursorPosition": "141,38",
"scrollLine": "0"
}
5 changes: 5 additions & 0 deletions .Rproj.user/3992D3D4/sources/prop/8F7C148B
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "14,0",
"scrollLine": "0"
}
5 changes: 5 additions & 0 deletions .Rproj.user/3992D3D4/sources/prop/97399623
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "17,17",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/AA8888B6
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "3,7",
"cursorPosition": "7,0",
"scrollLine": "0"
}
4 changes: 2 additions & 2 deletions .Rproj.user/3992D3D4/sources/prop/ADDA4E66
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled2",
"cursorPosition": "46,27",
"scrollLine": "26"
"cursorPosition": "43,31",
"scrollLine": "0"
}
4 changes: 2 additions & 2 deletions .Rproj.user/3992D3D4/sources/prop/C361053E
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled2",
"cursorPosition": "41,53",
"scrollLine": "17"
"cursorPosition": "39,65",
"scrollLine": "29"
}
4 changes: 2 additions & 2 deletions .Rproj.user/3992D3D4/sources/prop/C7D401C2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled2",
"cursorPosition": "46,37",
"scrollLine": "25"
"cursorPosition": "7,70",
"scrollLine": "0"
}
1 change: 1 addition & 0 deletions .Rproj.user/3992D3D4/sources/prop/CEE0A27E
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 3 additions & 3 deletions .Rproj.user/3992D3D4/sources/prop/D1765424
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tempName": "Untitled1",
"cursorPosition": "75,17",
"scrollLine": "48",
"last_setup_crc32": "9F8C73CAbb338d19"
"cursorPosition": "68,17",
"scrollLine": "0",
"last_setup_crc32": ""
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/ECE0FFE8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cursorPosition": "7,19",
"cursorPosition": "3,14",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/3992D3D4/sources/prop/FCD88EE5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "23,8",
"cursorPosition": "22,17",
"scrollLine": "0"
}
7 changes: 7 additions & 0 deletions .Rproj.user/3992D3D4/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
H%3A%2FUbuntuRv2%2FGibbs-sampler-algorithm%2FMA-Tingjin5%2Fsimu_case1_EBMA8_log_0.R="CEE0A27E"
H%3A%2FUbuntuRv2%2FGibbs-sampler-algorithm%2FMA-Tingjin5%2Fsimu_case2_log_AoS.R="86C3D5DC"
H%3A%2FUbuntuRv2%2FGibbs-sampler-algorithm%2FMA-Tingjin5%2Fsimu_case2_log_AoS.Rout="6B6242EF"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2F.Rbuildignore="80CD3E7A"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FDESCRIPTION="ECE0FFE8"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FLICENSE="F2054525"
Expand All @@ -12,7 +15,9 @@ H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fblockgibbs3.R="C361053E"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fburnseq.R="3AA9A4FC"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2FexBIC.R="25B3AAD6"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fgibbs.R="7EC5EA7B"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fgibbs1.R="8F7C148B"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fhello.R="EE17ED8B"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fichart.R="7C8C31A9"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fplotgibbs.R="F41F9CA2"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Fpredgibbs.R="6ADD8893"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2FR%2Freorder.R="B6F436B8"
Expand All @@ -25,6 +30,8 @@ H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2Fman%2Fac.ratio.Rd="EF1AA608"
H%3A%2FUbuntuRv2%2FIBGS%2FIBGS%2Fman%2FexBIC.Rd="BAAC6886"
H%3A%2FUbuntuRv2%2FIBGS%2Ftest.R="FCD88EE5"
H%3A%2FUbuntuRv2%2FIBGS%2Ftest.Rout="43B20C7B"
H%3A%2FUbuntuRv2%2FIBGS%2Ftest1.R="97399623"
H%3A%2FUbuntuRv2%2FIBGS%2Ftest1.Rout="354CB43F"
H%3A%2FUbuntuRv2%2FTCGS%2FIBGS.Rmd="D1765424"
H%3A%2FUbuntuRv2%2FTCGS%2FIBGS.tex="4F1C9B07"
H%3A%2FUbuntuRv2%2FTCGS%2Ftcg_ar.R="AA8888B6"
25 changes: 25 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/088D3205
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "088D3205",
"path": "H:/UbuntuRv2/IBGS/IBGS/R/plotgibbs.R",
"project_path": "R/plotgibbs.R",
"type": "r_source",
"hash": "0",
"contents": "",
"dirty": false,
"created": 1637718683116.0,
"source_on_save": false,
"relative_order": 8,
"properties": {
"tempName": "Untitled1",
"cursorPosition": "7,5",
"scrollLine": "0"
},
"folds": "",
"lastKnownWriteTime": 1637242326,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1637242326,
"read_only": false,
"read_only_alternatives": []
}
19 changes: 19 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/088D3205-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' plot the marginal probability for top predictors
#'
#' @param result the result from IBGS
#' @param n.vars the number of top predictors

#' @export

plots.Gibbs <- function(result, n.vars = 20){
colors <- rep(0,n.vars)
v.order <- order(result$v.prob, decreasing = TRUE)
v.freq <- result$v.prob[v.order[1:n.vars]]

colors[v.freq > result$tau] <- 2
colors[v.freq <= result$tau ] <- 1
plot(1:n.vars, v.freq, xlab = "", ylab = "Marginal Probability",
xaxt = "n", main = "", type = "h", col = colors, ylim = c(0,1))
mtext(result$x.predictors[v.order[1:n.vars]], side = 1, line = 0.25,
at = 1:n.vars, las = 2, cex = 1)
}
52 changes: 52 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/24ECBBFE-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#' a summary of partial results
#'
#' @param m.matrix a matrix of generated samples
#' @param y the response variable
#' @param x the predictors
#' @param n.models the number of top selected models
#' @param info the selected model selection criterion from AIC, AICc, BIC and exBIC
#' @param family the type of model from linear, logistic, poisson
#' @param k the tuning parameter
#' @param gamma the tuning parameter to control the penalty
#' @param p0 the number of total predictors
#'
#' @return a list containing partial results
#' @export

result.GibbsSampler <- function(m.matrix, y, x, k, gamma, p0, n.models, info, family){
z <- as.data.frame(cbind(y,x))
colnames(z)[1] <- "y"

n <- dim(m.matrix)[1]
m.sic <- vector()
for(i in 1:n){
m.sic <- c(m.sic, v.sic(m.matrix[i,], y, x, gamma, p0, info, family))
}

m.sic.df <- as.data.frame(table(m.sic))
m.sics <- as.numeric(levels(m.sic.df[,1]))

if(length(m.sics) < n.models)
n.models <- length(m.sics)

m.order <- order(m.sic, decreasing = FALSE)
m.index <- cumsum(m.sic.df[,2])
m.models <- list()
for (i in 1:n.models) {
model <- glm(y~., z[,m.matrix[m.order[m.index[i]],]==1], family = family)
m.models[[i]] <- model
}
m.sicc <- m.sics[1:n.models]
m.weights <- weight(m.sicc, k)

return(list(n.models = n.models,
m.sics = m.sics,
m.sic = m.sic,
m.seq = m.matrix[,-1],
c.models = list(models = m.models,
weights = m.weights),
k = k,
info = info,
family = family
))
}
50 changes: 50 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/2856D250-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#' The second step in the block Gibbs sampler search algorithm in the iterations
#'
#' @param y the response variable
#' @param x1 the non-important predictors
#' @param x2 the important predictors
#' @param H the number of predictors in small groups
#' @param kapp the number of selected predictors in first step
#' @param tau the threshold to select the important predictors in second step
#' @param len the half number of generated samples
#' @param k the tuning parameter
#' @param gamma the parameter for extended BIC
#' @param p0 the number of all predictors
#' @param info the selected model selection criterion
#' @param family the type of model

#' @return the number of selected columns
#' @export

BlockGibbsSampler.step2 <- function(y, x1, x2, H, kapp, tau, len,
k, gamma, p0, info, family){
x <- cbind(x1,x2)
z <- as.data.frame(cbind(y,x1,x2))
colnames(z)[1] <- "y"

n <- dim(x1)[1]
p1 <- dim(x1)[2]
if(is.null(dim(x2))){
p2 <- 0
}else
p2 <- dim(x2)[2]

h <- ceiling(dim(x1)[2]/(min(H, n-p2)))
v.freq <- BlockGibbsSampler.step1(y, x1, x2, h, len, k, gamma, p0, info, family)

x.s <- cbind(x1[,order(v.freq, decreasing = TRUE)[1:kapp]], x2)
p.s <- dim(x.s)[2]

s.index <- rep(1, p.s)
m.matrix <- GibbsSamplerStep(y, x.s, x2 = vector(), s.index, len,
k, gamma, p0, info, family)
v.freq2 <- colSums(m.matrix)/len

if(sum(v.freq2[-1] > tau) > 1){
v.select <- as.numeric(colnames(x.s)[v.freq2[-1] > tau])
}
else{
v.select <- as.numeric(colnames(x.s))
}
return(sort(v.select))
}
18 changes: 18 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/3A7AE6B8-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by roxygen2: do not edit by hand

export(AICc)
export(BlockGibbsSampler)
export(BlockGibbsSampler.step1)
export(BlockGibbsSampler.step2)
export(BlockGibbsSampler.step3)
export(GibbsSamplerStep)
export(ac.ratio)
export(burn.seq)
export(exBIC)
export(plots.Gibbs)
export(predicts.Gibbs)
export(r.index)
export(result.GibbsSampler)
export(sigmoid)
export(v.sic)
export(weight)
25 changes: 25 additions & 0 deletions .Rproj.user/3992D3D4/sources/s-54CE4874/4CA67785
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "4CA67785",
"path": "H:/UbuntuRv2/IBGS/test1.R",
"project_path": null,
"type": "r_source",
"hash": "2176420345",
"contents": "",
"dirty": false,
"created": 1637716901605.0,
"source_on_save": false,
"relative_order": 12,
"properties": {
"tempName": "Untitled1",
"cursorPosition": "17,17",
"scrollLine": "0"
},
"folds": "",
"lastKnownWriteTime": 1637716979,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1637716979135,
"read_only": false,
"read_only_alternatives": []
}
Loading

0 comments on commit 0c50701

Please sign in to comment.