Skip to content

Instantly share code, notes, and snippets.

@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
@grantbrown
grantbrown / HousingData.csv
Created June 24, 2013 21:09
HousingData.csv
HouseAge HouseSize HousePrice
201.527404291113 2 71070.5079595287
94.2024885946334 2 74816.492188726
152.27541964276 3 82961.80114856
147.102697959987 3 93921.3139520607
54.6764066301875 3 92954.4300141439
45.3843956164123 2 78265.1130040834
27.0776491481433 1 63702.3190749916
101.407357022128 2 79153.6384587674
56.8029020549195 1 57338.8476613027
@grantbrown
grantbrown / SBP.csv
Created June 23, 2013 22:56
Systolic Blood Pressure Data for Section 5
Age Gender SBP
58 0 158.65711773507
65 0 159.342444046151
56 0 153.516056039745
61 0 155.236047551483
65 1 149.324298269595
48 0 140.730171877834
53 1 137.740735663033
54 1 141.256213419939
67 0 159.101029802287
@grantbrown
grantbrown / Homework5Template.R
Created June 20, 2013 22:04
Brief template for Homework 5 code
# 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:
@grantbrown
grantbrown / Homework5.csv
Created June 20, 2013 17:08
Data for homework 5
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
@grantbrown
grantbrown / IQ_DI.txt
Created June 16, 2013 16:35
IQ by Delinquency Index Data Set for Section 3
IQ DI
73 38
82 43
84 36
88 34
89 30
91 23
98 26
98 32
101 19
@grantbrown
grantbrown / Homework3Template.R
Created June 16, 2013 02:48
R code template for working on homework 3
# 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
@grantbrown
grantbrown / ConfidenceBandExample.R
Created June 16, 2013 02:47
Example code and comments for creating a confidence interval at a particular X0 for the mean of Y in a simple linear regression problem.
# 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)