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
--- | |
title: "EID Class - Fall 2021" | |
author: "Grant Brown" | |
date: "9/28/2021" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
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
--- | |
title: "R ABSEIR - R0 and EA-R0 issue" | |
output: html_document | |
--- | |
## Issue | |
Modified code below | |
```{r Setup, echo=TRUE} |
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
==14436== Memcheck, a memory error detector | |
==14436== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. | |
==14436== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info | |
==14436== Command: /usr/lib64/R/bin/R -f class_test.R --restore --save --no-readline | |
==14436== | |
==14441== Memcheck, a memory error detector | |
==14441== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. | |
==14441== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info | |
==14441== Command: /usr/bin/uname -m | |
==14441== |
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("XBART") | |
data(iris) | |
y <- matrix(0, nrow = nrow(iris), ncol = 3) | |
for (i in 1:nrow(iris)){ | |
y[i, as.numeric(iris$Species)[i]] <- 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
sims <- replicate(1000,{ | |
X <- as.data.frame(matrix(rnorm(200*25), ncol = 25, nrow = 200)) | |
colnames(X)[1] <- "Y" | |
has.cor <- sapply(2:ncol(X), function(i){cor.test(X$Y, X[,i])$p.value < 0.2}) | |
lm.out.1 <- lm(Y~., data = X) | |
lm.out.2 <- lm(Y~., data = X[,c(1, which(has.cor))]) | |
ftest <- function(lmrslt){ | |
fs <- summary(lmrslt)$fstatistic |
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(ABSEIR) | |
# read in the data set | |
data(Kikwit1995) | |
lastTpt <- 80 | |
# Create a model to relate observe data to epidemic process | |
count <- Kikwit1995$Count | |
count[(lastTpt+1):length(count)] <- NA | |
data_model = DataModel(count, |
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
Date,Count | |
1995-03-06,1 | |
1995-03-07,1 | |
1995-03-08,1 | |
1995-03-09,0 | |
1995-03-10,0 | |
1995-03-11,0 | |
1995-03-12,0 | |
1995-03-13,2 | |
1995-03-14,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
library(gbm) | |
data(iris) | |
q = gbm(Species~., | |
distribution="multinomial", | |
data=iris, | |
interaction.depth=4, | |
shrinkage = 0.01, | |
n.minobsinnode=max(30,ceiling(nrow(iris)*0.001)), | |
n.cores=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
==13519== Memcheck, a memory error detector | |
==13519== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. | |
==13519== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info | |
==13519== Command: /usr/lib/R/bin/R -f gbmtest.R --restore --save --no-readline | |
==13519== | |
==13520== Memcheck, a memory error detector | |
==13520== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. | |
==13520== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info | |
==13520== Command: /bin/uname -m | |
==13520== |
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(ncvreg) | |
generateData <- function(n,p,nNonzeroBeta, binomial=FALSE){ | |
trueBetaIndex <- (1:p)[order(runif(p,0,1))][1:nNonzeroBeta] | |
X <- matrix(rnorm(n*p), nrow=n,ncol=p) | |
trueBeta <- rep(0,p) | |
trueBeta[trueBetaIndex] <- rnorm(nNonzeroBeta) | |
if (binomial){ | |
eEta <- exp(X %*% trueBeta) |
NewerOlder