⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.r

📁 使用R语言的马尔科夫链蒙特卡洛模拟(MCMC)源代码程序。
💻 R
字号:
########## Utility Functions ########### takes a symmetric matrix x and returns lower diagonal# note: does not check for symmetry## ADM 4/18/2003 "vech" <-  function (x) {    x <- as.matrix(x)    if (dim(x)[1] != dim(x)[2]) {      stop("Non-square matrix passed to vech().\n")    }    output <- x[lower.tri(x, diag = TRUE)]    dim(output) <- NULL    return(output)  }# takes vector x and returns an nrow times nrow symmetric matrix# this will recycle the elements of x as needed to fill the matrix## ADM 4/18/2003# ADM 11/13/2003 [bug fix]# ADM 1/25/2006 [patch to automatically compute matrix size]"xpnd" <-  function (x, nrow = NULL) {    dim(x) <- NULL    if(is.null(nrow)) nrow <- (-1 + sqrt(1 + 8 * length(x))) / 2    output <- matrix(0, nrow, nrow)    output[lower.tri(output, diag = TRUE)] <- x    hold <- output    hold[upper.tri(hold, diag=TRUE)] <- 0    output <- output + t(hold)        return(output)  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -