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
library(dplyr) | |
library(MASS) | |
data("diamonds", package = "ggplot2") | |
diamonds2 <- dplyr::select(diamonds, carat, depth:price,x:z) | |
a01 <- rgb(0,0,0,0.1) | |
png("pairs.png") | |
plot(diamonds2, col=a01) | |
dev.off() |
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
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(patchwork) | |
df1 <- mutate(iris,id=1:n()) %>% | |
pivot_longer(1:4) | |
df2 <-reframe(df1, x=c(as.integer(factor(name))-0.25,as.integer(factor(name))+0.25), |
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
scan1_mtx <- function(con, skip = 0){ | |
base::scan(con, nmax = 1, quiet=TRUE, | |
what = list(i=integer(), j=integer(), v=numeric()), | |
skip = skip) | |
} | |
dataloader_mtx2 <- function(file_path, bag){ | |
con <- file(file_path, open = "r") #Open for reading in text mode | |
#get matrix size |
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
#include "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
using namespace Rcpp; | |
using namespace arma; | |
// [[Rcpp::export]] | |
double sumouterprod(const arma::field<arma::vec> & V){ | |
int K = V.n_rows; | |
arma::vec tout = V(0); | |
for(int j=1; j<K; j++){ |
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
#include "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
using namespace Rcpp; | |
using namespace arma; | |
// [[Rcpp::export]] | |
double sumouterprod(const arma::field<arma::vec> & V){ | |
int K = V.n_rows; | |
arma::vec tout = V(0); | |
for(int j=1; j<K; j++){ |
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
library(tweedie) | |
library(dplyr) | |
library(ggplot2) | |
library(ggh4x) | |
pow <- c(1.01,1.05,1.3,1.9) | |
phi <- c(0.2,0.5,1,3) | |
mu <- c(0.1,0.3,2) | |
dens <- expand.grid(y=y,power=pow,mu=mu,phi=phi) %>% |
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
\documentclass{beamer} | |
\usepackage{tikz} | |
\setbeamertemplate{navigation symbols}{} | |
\usetikzlibrary{positioning} | |
\makeatletter | |
\usefonttheme{serif} | |
\usepackage{xcolor} | |
\def\mathunderline#1#2{\color{#1}\underline{{\color{black}#2}}\color{black}} |
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
library(BiasedUrn) | |
library(exact2x2) | |
library(animation) | |
#MCMCpack::dnoncenhypergeom(x = NA, cs[1],cs[2],rs[1], 1) | |
saveGIF({ | |
for(i in c(0:17,17:0)){ | |
rs <- c(18,17) | |
cs <- c(17,18) | |
X <-matrix(c(i,cs[1]-i,rs[1]-i,cs[2]-(rs[1]-i)), nrow=2) |
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
x <- seq(-1,1, length.out=100) | |
x2 <- 1*(x>0) | |
X <- cbind(x, x2, x*x2) | |
B <- c(0.5,2,-1) | |
mu <- c(X%*%B) | |
set.seed(2024);y <- mu + rnorm(100,0,0.1) | |
fit <- lm.fit(X,y) | |
muhat <- c(X%*%c(fit$coefficients)) |
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
library(animation) | |
pvfun <- Vectorize(function(r, y){ | |
poisson.test(y, T = tau, r = r)$p.value | |
}) | |
postprob <- function(r, x, tau){ | |
pl <- pgamma(r, shape = x+0.5, rate = tau, lower.tail = FALSE) | |
pu <- pgamma(r, shape = x+0.5, rate = tau, lower.tail = TRUE) | |
2*pmin(pl,pu) | |
} |
NewerOlder