Books
in black and white
Main menu
Home About us Share a book
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Introduction to Bayesian statistics - Bolstad M.

Bolstad M. Introduction to Bayesian statistics - Wiley Publishing, 2004. - 361 p.
ISBN 0-471-27020-2
Download (direct link): introductiontobayesianstatistics2004.pdf
Previous << 1 .. 108 109 110 111 112 113 < 114 > 115 116 117 118 119 120 .. 126 >> Next

0Introduction to Bayesian Statistics. By William M. Bolstad
ISBN 0-471-27020-2 Copyright ©John Wiley & Sons, Inc.
307
308 USING THE INCLUDED MINITAB MACROS
Table C.1 Minitab commands for sampling Monte Carlo study
Minitab Commands
Meaning
%<insertpath>sscsample.mac cl 100;
strata c2 3;
cluster c3 20;
type 1;
isize 20;
mcarlo 200;
output c6 c7 c8 c9;
"Monte Carlo sample size 200" "c6 contains sample means, c7-c9 contain numbers in each strata"
"data are in c1, N=100"
"there are 3 strata stored in c2" "there are 20 clusters stored in c3"
1=simple, 2=stratified, 3=cluster "sample size n=20"
CHAPTER 2: SCIENTIFIC DATA GATHERING Sampling Methods
We use the sscsample.mac to perform a small-scale Monte Carlo study on the efficiency of simple, stratified, and cluster random sampling on the population data contained in sscsample.mtw. In the "file" menu pull down "open worksheet" command. When the dialog box opens, find the directory BAYESMTW and type in sscsample.mtw in the filename box and click on "open". In the "edit" menu pull down "command line editor" and type the commands from Table C.1 into the command line editor:
Experimental Design
We use the Minitab macroXdesign.mac to perform a small-scale Monte Carlo study, comparing completely randomized design and randomized block design in their effectiveness for assigning experimental units into treatment groups. Type the commands from Table C.2 into the command line editor.
CHAPTER 6: BAYESIAN INFERENCE FOR DISCRETE RANDOM VARIABLES Binomial Proportion with Discrete Prior
BinoDP.mac is used to find the posterior when we have binomial (n, n) observation, andwehaveadiscreteprior for n. For example, suppose n has the discrete distribution with three possible values, .3, .4, and .5. Suppose the prior distribution is given in Table C.3. and we want to find the posterior distribution after n = 6 trials and observing y = 5 successes. In the "edit" menu pull down "command line editor" and type the commands from Table C.4 into the command line editor.
USING THE INCLUDED MINITAB MACROS 309
Table C.2 Minitab commands for experimental design Monte Carlo study
Minitab Commands Meaning
et FT =. 8 "correlation between other and response
variables"
random 80 cl c2; "generate 80 other and response variables
normal 0 1. in c1 and c2 respectively"
let c2=sqrt(1-k1**2)*c2+k1*c1 "give them correlation k1"
desc c1 c2 "summary statistics"
corr c1 c2
plot c2*c1 "shows relationship"
%<insertpath>Xdesign.mac cl c2; "other variable in c1, response in c2"
size 20; "treatment groups of 20 units"
treatments 4; "4 treatment groups"
mcarlo 500; "Monte Carlo sample size 500"
output c3 c4 c5. "c3 contains other means,
c4 contains response means,
c5 contains treatment groups
1-4 from completely randomized design
5-8 from randomized block design"
code (1:4) 1 (5:8) 2 c5 c6
desc c4; "summary statistics "
by c6.
Table C.3 Discrete prior distribution for n
–ü f (n)
.3 .2
.4 .3
.5 .5
CHAPTER 8: BAYESIAN INFERENCE FOR BINOMIAL PROPORTION
Beta(a, b) Prior for n
BinoBP.mac is used to find the posterior when we have binomial (n, n) observation, and we have a beta (a, –™) prior for n. The beta family of priors is conjugate for
310 USING THE INCLUDED MINITAB MACROS
Table C.4 Minitab commands for Bayesian inference on n with a discrete prior
Minitab Commands Meaning
set c1 "puts n in c1"
.3 .4 .5
end
set c2 "puts g(n) in c2"
.2 .3 .4
end
%<insertpath>BinoDP.mac 6; "n=6 trials"
prior c1 c2 "n in c1, prior g(n) in c2"
observation 5; "y=5 successes observed"
likelihood c3; "store likelihood in c3"
posterior c4. "store posterior g(n|y = 5) in c4"
Table C.5 Minitab commands for Bayesian inference on n with a beta prior
Minitab Commands Meaning
%<insertpath>BinoBP.mac 12 ; "n=12 trials"
beta 3 3; "the beta prior"
prior c1 c2; "stores n and the prior g(n)"
observation 4 ; "y=4 was observed"
likelihood c3; "store likelihood in c3"
posterior c4; "store posterior g(n|y = 4) in c4"
binomial (n, n) observations, so the posterior will be another member of the family, beta (a', b') where a' = a + y and b1 = b + n - y. For example, suppose we have n = 12 trials, and observe y = 4 successes, and we use a beta (3, 3) prior for n. In the "edit" menu pull down "command line editor" and type the commands from Table C.5 into the command line editor. We can find the posterior mean and standard deviation from the output. We can determine an (equal tail area) credible interval for n by looking at the values of y1 that correspond to the desired tail area values of invf.
General Continuous Prior for n
BinoGCP.mac is used to find the posterior when we have binomial (n, n) observation, and we have a general continuous prior for n. Note, n must go from 0 to 1 in steps of .001, and g(n) must be defined at each of the n values. For example, suppose we have n = 12 trials, and observe y = 4 successes, and we use a general continuous prior for n stored in c2. In the "edit" menu pull down "command line editor" and type the
Previous << 1 .. 108 109 110 111 112 113 < 114 > 115 116 117 118 119 120 .. 126 >> Next