Psych 285: Computational Statistics
and Statistical Visualization

Professor Forrest Young

Luke Tierney's Datasets

The following data are given in Luke Tierney's text. You may copy this page and use it so that you don't have to type in the data.
#|
Datasets used in examples and exercises appearing in:
Luke Tierney, Luke, "Lisp-Stat: An object-Oriented Environment 
for Statistical Computing and Dynamic Graphics, Wiley, 1990.
|#

;Section 2.2.1, p 14
;Precipitation in Minneapolis-St.Paul in March over 30 years
(def precipitation 
     (list .77 1.74 .81 1.20 1.95 1.20 .47 1.43 3.37 
           2.20 3.30 3.09 1.51 2.10 .52 1.62 1.31 .32 
           .59 .81 2.81 1.87 1.18 1.35 4.75 2.48 .96 
           1.89 .90 2.05))

#|Exercise 2.3 p. 17
Acid Rain: Average emission rates of SO2, in pounds/million BTU, from utility 
boilers for 47 states and DC (not including ID, Alaska, and Hawaii).
|#

(def SO2 (list 2.3 0.6 0.5 0.2 0.7 0.5 1.5 1.0 1.7 2.9
               2.7 4.2 2.2 1.0 3.6 0.1 1.4 2.1 1.8 1.8
               1.5 1.3 4.5 0.7 1.0 0.6 2.9 0.9 0.6 1.4
               1.5 1.2 3.8 0.2 0.7 2.5 1.0 1.9 1.7 3.7
               0.3 0.4 1.2 1.4 1.7 2.7 3.4 1.0))

; Section 2.2.1 p. 17
; Blood chemistry of two socioeconomic groups in Guatamala
(def urban (list 184 196 217 284 184 236 189 206 179 170 205 
                 190 204 330 217 242 222 242 249 241))
(def rural (list 166 146 144 204 158 143 158 180 223 194 194 
                 175 171 155 143 145 131 181 148 144 220 129))

;Exercise 2.4 p. 18
;Fuel economy tests (in miles per gallon) of 45 cars tested in 1965 and 1975
(def mpg1965 
     (list 17.14 12.17 12.22 13.89 16.47 15.88 16.10 16.74 17.54 17.43
           14.57 12.90 12.81 14.95 16.25 17.13 14.46 14.20 16.90 11.34
           12.57 13.15 16.53 13.60 13.34 13.67 14.23 15.81 16.63 11.40
           14.94 13.66  9.79 13.08 14.57 14.93 14.01 14.43 16.35 15.65
           11.52 17.46 14.67 15.92 16.02 13.46 13.70 14.98 14.57 15.72))
(def mpg1975 
     (list 24.57 24.79 22.21 25.84 25.35 22.19 24.37 21.32 22.74 23.35
           25.10 28.03 29.09 29.34 24.41 25.12 25.27 27.46 27.65 27.95
           21.67 22.15 24.36 26.32 24.05 28.27 26.57 26.10 24.35 30.04
           25.18 27.42 24.50 23.21 25.10 23.59 26.98 22.64 25.27 25.84
           27.18 24.69 26.35 23.05 23.37 25.46 28.84 22.14 25.42 21.76))

;Section 2.2.2 p 20
;Motor vehicle emissions for 46 automobiles
(def hc 
     '(.5 .46 .41 .44 .72 .83 .38 .60 .83 .34 .37 .87 .65 .48 .51 
       .47 .56 .51 .57 .36 .52 .58 .47 .65 .41 .39 .55 .64 .38 .50 
       .73 .57 .41 1.02 1.10 .43 .41 .41 .52 .70 .52 .51 .49 .61 .46 .55))
(def co 
     '(5.01 8.60 4.95 7.51 14.59 11.53 5.21 9.62 15.13 3.95 4.12 
      19.00 11.20 3.45 4.10 4.74 5.36 5.69 6.02 2.03 6.78 6.02 5.22 
      14.67 4.42 7.24 12.30 7.98 4.10 12.10 14.97 5.04 3.38 23.53 
      22.92 3.81 1.85 2.26 4.29 14.93 6.35 5.79 4.62 8.43 3.99 7.47))

;Exercise 2.6, p. 22
;Effects of cross-country skiing on the matabolism as measured by CPK
(def age (list 19 21 24 24 24 25 32 33 35 37 37 44 50 51 52 55 57 62))
(def cpk (list 520 300 480 1040 1360 580 440 180 490 520 380 640 360 
               240 420 280 400 260))

;Section 2.4.1, p. 30
;Yield of three varieties of Tomatos at four different planting densities
(def yield 
     (list 7.9 9.2 10.5 11.2 12.8 13.3 12.1 12.6 14.0 9.1 10.8 12.5 
           8.1 8.6 10.1 11.5 12.7 13.7 13.7 14.4 15.5 11.3 12.5 14.5 
           15.3 16.1 17.5 16.6 18.5 19.2 18.0 20.8 21 17.2 18.4 18.9 ))
(def density 
     (list 1 1 1 2 2 2 3 3 3 4 4 4 
           1 1 1 2 2 2 3 3 3 4 4 4 
           1 1 1 2 2 2 3 3 3 4 4 4))
(def variety 
     (list 1 1 1  1 1 1  1 1 1  1 1 1  
           2 2 2  2 2 2  2 2 2  2 2 2  
           3 3 3  3 3 3  3 3 3  3 3 3))

#|Section 2.5.1, p. 37
|Relationship between amount of material lost when rubber specimens are 
rubbed with an abrasive material, and two characterstics of the specimens.
|#

(def hardness 
     (list  45  55  61  66  71  71  81  86  53  60  64  68  79  81  56 
            68  75  83  88  59  71  80  82  89  51  59  65  74  81  86))
(def tensile-strength 
     (list 162 233 232 231 231 237 224 219 203 189 210 210 196 180 200 
           173 188 161 119 161 151 165 151 128 161 146 148 144 134 127))
(def abrasion-loss 
     (list 372 206 175 154 136 112  55  45 221 166 164 113  82  32 228 
           196 128  97  64 249 219 186 155 114 341 340 284 267 215 148))


#|Exercise 2.12, p. 40
Relationship between rate of flow of sulphate of ammonia crystals in a 
packing process, the initial moisture contents, and crystal shape.
|#
(def flow (list 5.00 4.81 4.46 4.84 4.46 3.85 3.21 3.25 4.55
                4.85 4.00 3.62 5.15 3.76 4.90 4.13 5.10 5.05
                4.27 4.90 4.55 4.39 4.85 4.59 5.00 3.82 3.68
                5.15 2.94 5.00 4.10 1.15 1.72 4.20 5.00))
(def moist (list  21   20   16   18   16   18   12   12   13 
                  13   17   24   11   10   17   14   14   14
                  20   12   11   10   16   17   17   17   15
                  17   21   21   21   26   21   17   11))
(def ratio (list 2.4  2.4  2.4  2.5  3.2  3.1  3.2  2.7  2.7 
                 2.7  2.7  2.8  2.5  2.6  2.0  2.0  2.0  1.9 
                 2.1  1.9  2.0  2.0  2.0  2.2  2.4  2.4  2.4 
                 2.2  2.2  1.9  2.4  3.5  3.0  3.5  3.2))

#|Exercise 2.14, p. 45
Effect of oxygen concentration on fermentation end products. Observed two
types of sugar at four oxygen concentrations. Recorded amount of ethanol.
|#
(def ethanol 
     (list .59 .30 .25 .03 .44 .18 .13 .02 .22 .23 .07 .00 .12 .13 .00 .01))
(def oxygen (list 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4))
(def sugar  (list 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2))

;Bicycle lane effects on travel space and separation between cars and bikes
;Section 2.5.5, p 47
(def travel-space (list 12.8 12.9 12.9 13.6 14.5 14.6 15.1 17.5 19.5 20.8))
(def separation   (list  5.5  6.2  6.3  7.0  7.8  8.3  7.1 10.0 10.8 11.0))


#|Nonlinear regression example, Section 2.8.1, p. 64
Relation between velocity of an exzymatic reaction, y, and substrate 
concentration x. Concentrations when enzyme treated with Puromycin:|#
(def x1 (list 0.02 0.02 0.06 0.06 .11 .11 .22 .22 .56 .56 1.1 1.1))
(def y1 (list 76   47   97   107  123 139 159 152 191 201 207 200))
;Concentrations without Puromycin:
(def x2 (list 0.02 0.02 0.06 0.06 .11 .11 .22 .22 .56 .56 1.1))
(def y2 (list 67 51 84 86 98 115 131 124 144 158 160))
(require "nonlin")
;Nonlinear regression functions:
(defun f1 (theta)
  "The Michaelis-Menten function for the velocity of an enzymatic reaction
as a function of the substrate concentration.  THETA is a parameter
vector of length 2 consisting of the asymptotic velocity and the
concentration at which half the asymptotic velocity is attained."
  (/ (* (select theta 0) x1) (+ (select theta 1) x1)))

(defun f2 (theta)
  "The Michaelis-Menten function for the velocity of an enzymatic reaction
as a function of the substrate concentration.  THETA is a parameter 
vector of length 2 consisting of the asymptotic velocity and the
concentration at which half the asymptotic velocity is attained."
  (/ (* (select theta 0) x2) (+ (select theta 1) x2)))

;Maximization example, Section 2.8.2, p. 67
;Time between failuses of air-conditioning units on several aircraft.
(def failure-times
     '((413 14 58 37 100 65 9 169 447 184 36 201 118 34 31 
            18 18 67 57 62 7 22 34)
       (90 10 60 186 61 49 14 24 56 20 79 84 44 59 29 118 25 156 
           310 76 26 44 23 62 130 208 70 101 208)
       (74 57 48 29 502 12 70 21 29 386 59 27 153 26 326)
       (55 320 65 104 220 239 47 246 176 182 33 15 104 35)
       (23 261 87 7 120 14 62 47 225 71 246 21 42 20 5 12 120 
           11 3 14 71 11 14 11 16 90 1 16 52 95)))
(def x (select failure-times 1))
(require "maximize")
(defun gllik (theta)
  (let* ((mu (select theta 0))
         (beta (select theta 1))
         (n (length x))
         (bym (* x (/ beta mu))))
    (+ (* n (- (log beta) (log mu) (log-gamma beta)))
       (sum (* (- beta 1) (log bym)))
       (sum (- bym)))))
#|Bayesian Computations example. Section 2.8.3, p. 70
Survival time, in weeks, of leukemia patients vs. white blood cell counts of
patients when they entered the study. Patients were AG+|#
(def wbc-pos (list 2300 750 4300 2600 6000 10500 10000 17000 5400 7000
                   9400 32000 35000 100000 100000 52000 100000))
(def transformed-wbc-pos (- (log wbc-pos) (log 10000)))
(def times-pos (list 65 156 100 134 16 108 121 4 39 143 56 26 22 1 1 5 65))

(require "bayes")
(defun llik-pos (theta)
  (let* ((x transformed-wbc-pos)
	 (y times-pos)
	 (theta0 (select theta 0))
	 (theta1 (select theta 1))
	 (t1x (* theta1 x)))
    (- (sum t1x)
       (* (length x) (log theta0))
       (/ (sum (* y (exp t1x)))
	  theta0))))

(defun lk-sprob (theta)
  (let* ((time 52.0)
         (x (log 5))
         (mu (* (select theta 0) (exp (- (* (select theta 1) x))))))
    (exp (- (/ time mu)))))

#|Stack Loss Data: Section 5.6.2, p. 176
21 observations of the oxidation of ammonia to nitric acid in the operation 
of a manufacturing plant. Independent variables are the airflow through the 
plant, temperature of cooling water; and concentration of acid circulating. 
Dependent variable is loss of ammonia from absorption tower.|#

(def loss 
     (list 42 37 37 28 18 18 19 20 15 14 14 13 11 12  8  7  8  8  9 15 15))
(def air 
     (list 80 80 75 62 62 62 62 62 58 58 58 58 58 58 50 50 50 50 50 56 70)) 
(def temp 
     (list 27 27 25 24 22 23 24 24 23 18 18 17 18 19 18 18 19 19 20 20 20))
(def conc 
     (list 89 88 90 87 87 87 93 93 87 80 89 88 82 93 89 86 72 79 80 82 91))

;Following examples are from the preliminary report about LispStat
;They do not seem to appear in the book

(def purchases (list 0 2 5 0 3 1 8 0 3 1 1 9 2 4 0 2 9 3 0 1 9 8))

(def iron       (list 61 175 111 124 130 173 169 169 160 224 257 333 199))
(def aluminum   (list 13  21  24  23  64  38  33  61  39  71 112  88  54))
(def absorption (list  4  18  14  18  26  26  21  30  28  36  65  62  40))

(def strength 
     (list 14.7 48.0 25.6 10.0 16.0 16.8 20.7 
           38.8 16.9 27.0 16.0 24.9  7.3 12.8))
(def depth 
     (list  8.9 36.6 36.8  6.1  6.9  6.9  7.3 
            8.4  6.5  8.0  4.5  9.9  2.9  2.0))
(def water 
     (list 31.5 27.0 25.9 39.1 39.2 38.3 33.9 
           33.8 27.9 33.1 26.3 37.8 34.6 36.4))