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
plotNormal = function(lb, ub, mu = 0, sigma = 1) | |
{ | |
# Generate X an Y pairs for normal curve | |
X = seq(mu - 4*sigma, mu + 4*sigma, 0.1) | |
Y = dnorm(X, mean = mu, sd = sigma) | |
# Plot the normal curve line, lablel axes and plot | |
plot(X,Y, type = "l", main = "Normal PDF", xlab = "x", ylab = "Density(x)") | |
# Calculate visible bounds (no use plotting tails that are off the screen) | |
lb2 = min(max(lb, mu-4*sigma), min(ub, mu+4*sigma)) | |
ub2 = max(max(lb, mu-4*sigma), min(ub, mu+4*sigma)) |
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
BMI FatPct | |
27.2 34.6 | |
23.7 39.5 | |
24.9 41.3 | |
32.2 33.3 | |
36.8 43 | |
20 32.3 | |
29.5 31.5 | |
29.3 36.5 | |
44.6 41.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
# T Distribution Illustration | |
TimeDelay = 0.5 | |
plotT = function(df, add = FALSE) | |
{ | |
f = function(x) | |
{ | |
return(dt(x, df)) | |
} | |
curve(f, xlim = c(-6,6), ylim = c(0, 0.5), add = add, main = "T Distribution vs. Standard Normal",ylab = "Density") |
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
# 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) | |
{ |
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
county | HeartCrude | HeartAgeAdj | DiabetesCrude | DiabetesAgeAdj | |
---|---|---|---|---|---|
adair | 441.6 | 211.3 | 28.7 | 14.6 | |
adams | 352.9 | 174.4 | 29 | 24.5 | |
audubon | 318.9 | 149.9 | 32.2 | 17 | |
clarke | 389.2 | 261.6 | 39.6 | 31 | |
davis | 252.7 | 172.7 | 53.8 | 36.8 | |
decatur | 301.2 | 202.1 | 28.7 | 19.2 | |
fremont | 289.1 | 169.1 | 42.4 | 25.2 | |
greene | 351.2 | 177 | 18.7 | 11.4 | |
howard | 379.4 | 197 | 25.2 | 14.9 |
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
# To illustrate the use of confidence bands, let's just make up | |
# a data example. First, to ensure that everyone's simulated data | |
# looks the same in case you want to work together, let's tell R | |
# to use the same starting point for random number generation. | |
# (don't worry about how this works) | |
set.seed(12345) |
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
# Homework 3 R code template | |
# Before doing anything else, get a copy of HeartDiseaseDiabetes.csv | |
# This file is available on the github site, and an excel version is | |
# available on icon. Remember that to use the excel version, you need | |
# to open it in excel or libre office and save a copy as a csv. | |
# Once you have obtained a copy of the data set in csv format, take | |
# note of where you've saved it. We need to tell R to use that folder |
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
IQ DI | |
73 38 | |
82 43 | |
84 36 | |
88 34 | |
89 30 | |
91 23 | |
98 26 | |
98 32 | |
101 19 |
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
County | AllCancerMortalityCrude | PctFarmCorn | GraduationRate | HospitalBeds | NursingFacilities | CCDI_Facilities | |
---|---|---|---|---|---|---|---|
adair | 308.3 | 27.8 | 0.97 | 25 | 3 | 1 | |
adams | 275.5 | 24.2 | 0.947368421 | 22 | 1 | 0 | |
allamakee | 244.2 | 8.1 | 0.961538462 | 25 | 4 | 1 | |
appanoose | 299.1 | 14 | 0.782258065 | 45 | 2 | 0 | |
audubon | 335 | 37.3 | 0.961538462 | 25 | 2 | 2 | |
benton | 185.9 | 40.1 | 0.95 | 25 | 3 | 1 | |
black.hawk | 210.4 | 40.3 | 0.901639344 | 675 | 11 | 1 | |
boone | 238.5 | 40.3 | 0.921259843 | 42 | 4 | 2 | |
bremer | 187.3 | 35.6 | 0.91503268 | 50 | 4 | 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
# 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) | |
# Perform the regression: | |
MyMLR = lm(AllCancerMortalityCrude ~ GraduationRate + HospitalBeds + PctFarmCorn, data = CancerData) | |
# Take a look at the regression summary: |
OlderNewer