-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
2,039 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"debugBreakpointsState": { | ||
"breakpoints": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"ascending": true | ||
} | ||
], | ||
"path": "H:/UbuntuRv2/IBGS/IBGS/R" | ||
"path": "H:/UbuntuRv2/IBGS/IBGS" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"activeTab": 1 | ||
"activeTab": 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"TabSet1": 0, | ||
"TabSet2": 0, | ||
"TabSet2": 2, | ||
"TabZoom": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled2", | ||
"cursorPosition": "0,3", | ||
"cursorPosition": "23,37", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled2", | ||
"cursorPosition": "5,0", | ||
"cursorPosition": "38,31", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tempName": "Untitled3", | ||
"cursorPosition": "20,0", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "17,0", | ||
"cursorPosition": "7,70", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"cursorPosition": "141,38", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "14,0", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "17,17", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "3,7", | ||
"cursorPosition": "7,0", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"cursorPosition": "7,19", | ||
"cursorPosition": "3,14", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "23,8", | ||
"cursorPosition": "22,17", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} |
Oops, something went wrong.