Skip to content

Instantly share code, notes, and snippets.

---
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)
```
---
title: "R ABSEIR - R0 and EA-R0 issue"
output: html_document
---
## Issue
Modified code below
```{r Setup, echo=TRUE}
==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==
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
}
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
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,
@grantbrown
grantbrown / ConfidencePlot.R
Last active May 17, 2016 18:54
Confidence Band Plot - R Function
# Functions to make SLR Confidence and Prediction Band Plots.
# Grant Brown, June 2013
# 171-162
# Internal function used by ConfidenceBandPlot and PredictionBandPlot
BasicRegressionPlot = function(X,Y, main = "", xlab = "",ylab = "", plt = TRUE, matchScale = FALSE)
{
@grantbrown
grantbrown / ScoreData.csv
Created July 3, 2013 12:52
Video Game Score Data
AvgScore Age Caffeine NumberOfGamesPlayed
172.231758565115 41 8.27310138781406 5
344.080816385481 45 166.788674010494 4
158.243974439236 47 0 5
161.762852648026 52 0 4
450.046699030962 50 341.247032165972 7
468.416022742364 63 376.400720606928 4
374.036406183761 38 228.098363606319 3
312.256335733073 59 144.104941199508 11
466.517013106131 55 339.59090467707 6
partQuality machineNumber speedSetting shopTemperature shopHumidity dayOfWeek materialHardness materialColor volumeRemoved
24 1 3 66 55 1 33.3 red 66.4977751111701
100 2 4 82 63 2 75 green 141.814186119158
40 2 4 65 69 5 33.3 red 52.6887914269801
-2 2 1 67 60 5 33.3 blue 90.0792218314648
19 1 1 67 72 6 75 green 72.4268319792361
141 1 8 72 54 4 33.3 red 160.989211437966
60 2 5 68 76 6 33.3 red 100.177360139193
308 2 9 68 44 6 75 green 121.351584377482
31 3 3 72 53 5 33.3 red 74.7642070437819
@grantbrown
grantbrown / Hw6P2.R
Created July 1, 2013 22:14
Homework 6 Problem 2 Solution
# Change my working directory to wherever the data file is stored
setwd("/home/grantbrown/dev/171-162-Materials/Section4/Homework5/")
CancerData = read.csv("Homework5.csv", head = TRUE)
# Fit the reduced model
ReducedModel = lm(AllCancerMortalityCrude ~ HospitalBeds, data = CancerData)
# Fit the full model