DOC PREVIEW
UW-Madison STAT 371 - Simulation Studies

This preview shows page 1-2-22-23 out of 23 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

IntroductionConfidence IntervalsHypothesis TestsSimulation StudiesSpring 2011Outline1Introduction2Confidence Intervals3Hypothesis TestsOutline1Introduction2Confidence Intervals3Hypothesis TestsLatin Terms for (Some) Different Types of BiologicalExperiments1in vivo = within the living (e.g. animal testing, clinical trials)experimentation using a whole, living organism2in vitro = within the glass (e.g. test tube or petri dish)experimentation using components of an organism thathave been isolated and studied in a controlled biologicalenvironment3in silico = in the computer (fake Latin, playing on silicon)experimentation performed on computer or via computersimulationSee WikipediaSimulation Experiment, in silico1Almost free (compared to very expensive human or animaltesting).2Complete control (the biologist and modeler set exactly theparameters of the system).3A good first approximation for studying a biological system.4Limited by computer precision and human knowledge; howrealistically can you actually model a biological system5NOT meant to replace in vivo or in vitro experiments.Instead use computer simulation to complement theseexperiments.Let’s Focus1The above description of in silico experiments is meant asbackground2The topic of modeling and simulating complex biologicalsystems could be studied in a year long course sequence.3We will focus on a specific type of simulation studycommonly used in statistics: Monte Carlo experiments1rely on repeated random sampling2Named after the Monte Carlo casino (please do NOT befooled into thinking you can beat the house, the housealways wins).4Usually when a statistician says “Simulation Study,” he isreferring to a Monte Carlo experiment (we will use thismeaning of simulation throughout).Simulation Experiments (in a typical statistics study)1Confidence intervals and hypothesis testing have arepeated sampling interpretation.2We do not actually want to collect 1000 different randomsamples from our target population (remember we hopethat a 95% CI would contain the true mean, about 950 outof the 1000 times).3Also, we will never know the true mean in a real,experimental situation. But you know it in a computerexperiment, because you set the mean.4You use the computer to generate pseudo-randomsamplesGame PlanWe will explore simulation studies for one sample problems inthe context of both1Confidence intervals2Hypothesis testsNote - future workWe are focusing on two procedures that we know(confidence intervals, hypothesis tests)The real power of simulation studies comes in exploringthe performance of a statistical procedure (e.g. confidenceinterval) in complex settings where there the distributionaltheory is unknown (e.g. we cannot say the procedure isbased on normality).This is important to remember for those of you whocontinue with quantitative research (e.g. anyone doing aresearch-based masters or PhD; most scientific fields arequantitative)Outline1Introduction2Confidence Intervals3Hypothesis TestsSimulation StudiesWe will explore simulation studies in the context of1Confidence intervals2Hypothesis testsExample1Let’s simulate one data set using R.2We draw a pseudo-random sample of size n = 10 from theN(0, 4) population: rnorm3And then use R to compute a confidence interval: t.testt.test() spits out a lot of information, but in particular, it spitsout the 95% confidence interval for the mean.Example (Continued)> x<-rnorm(n=10,mean=0, sd=4)> x3.7032395 1.3803970 1.9454320 3.0871619-2.1036865 -5.8024249 -0.2351963 -1.58531218.4006722 4.7959016> t.test(x)95 percent confidence interval:-1.509859 4.227096Extend the Example to a Simulation ExperimentRepeat the above procedure 1000 timesAnd check how many times the confidence intervalcontains the true meanWe know the true mean is µ = 0 because we can controleverything in a computer experiment; here we are drawingsamples from a N(0, 4) population, µ = 0 and σ = 4.Continuous data–t-intervals> N = 1000; # number of simulation> count = 0; # counting the number of CI contain 0> for(i in 1:N)+ {+ n=10;+ x = rnorm(n, mean =0, sd = 4);+ x_bar = mean(x);+ s = sd(x);+ l = x_bar-qt(0.975,n-1)*s/sqrt(n);+ u = x_bar+qt(0.975,n-1)*s/sqrt(n);+ if(l<0 & u>0) count = count+1;+ }> count/N[1] 0.952Continuous Data –z-intervalsIf we use critical value of 1.96 (from N(0,1)) instead oft-distribution, we will get a worse result.> N = 1000; # number of simulation> count = 0; # counting the number of CI contain 0> for(i in 1:N)+ {+ n=10;+ x = rnorm(n, mean =0, sd = 4);+ x_bar = mean(x);+ s = sd(x);+ l = x_bar-1.96*s/sqrt(n);+ u = x_bar+1.96*s/sqrt(n);+ if(l<0 & u>0) count = count+1;+ }> count/N[1] 0.915Continuous Data –Uniform distributionInstead of use normal distribution we use the U[-10,10] togenerate data> N = 1000; # number of simulation> count = 0; # counting the number of CI contain 0> count_z = 0; # counting z (using 1.96)> for(i in 1:N){+ n=10; x = runif(n, min =-10, max=10);+ x_bar = mean(x); s = sd(x);+ l = x_bar-qt(0.975,n-1)*s/sqrt(n);+ u = x_bar+qt(0.975,n-1)*s/sqrt(n);+ l_z = x_bar-1.96*s/sqrt(n);+ u_z = x_bar+1.96*s/sqrt(n);+ if(l<0 & u>0) count = count+1;+ if(l_z<0 & u_z>0) count_z = count_z+1}> count/N[1] 0.936> count_z/N[1] 0.903Uniform distribution –increase nWhen number of observation n increases, the central limittheorem works better> N = 1000; # number of simulation> count = 0; # counting the number of CI contain 0> count_z = 0; # counting z (using 1.96)> for(i in 1:N){+ n=30;+ x = runif(n, min =-10, max=10);+ x_bar = mean(x); s = sd(x);+ l = x_bar-qt(0.975,n-1)*s/sqrt(n);+ u = x_bar+qt(0.975,n-1)*s/sqrt(n);+ l_z = x_bar-1.96*s/sqrt(n);+ u_z = x_bar+1.96*s/sqrt(n);+ if(l<0 & u>0) count = count+1;+ if(l_z<0 & u_z>0) count_z = count_z+1;}> count/N[1] 0.949> count_z/N[1] 0.942Discrete Data –Binomial distributionConsider the confidence interval of the population proportion p.Assume x ∼ B(50, p), where we choose p = 0.01, 0.5, 0.99.We compare the covering probability by˜p =x+2n+4andˆp =xn.p 0.01 0.5 0.99cover prob.˜p 0.99 0.928 0.983cover prob.ˆp 0.4 0.928 0.397R codeN = 1000; # number of simulationfor(p in c(0.01,0.5,0.99)){count = 0; # counting the number of CI contain 0count_hat = 0;for(i in 1:N){n=50; x = rbinom(1, size=n, p);p_hat = x/n; p_tilde = (x+2)/(n+4);l = p_tilde-1.96*sqrt(p_tilde*(1-p_tilde)/(n+4));u = p_tilde+1.96*sqrt(p_tilde*(1-p_tilde)/(n+4));l_hat = p_hat-1.96*sqrt(p_hat*(1-p_hat)/(n+4));u_hat = p_hat+1.96*sqrt(p_hat*(1-p_hat)/(n+4));if(l<p & u>p) count =


View Full Document

UW-Madison STAT 371 - Simulation Studies

Documents in this Course
HW 4

HW 4

4 pages

NOTES 7

NOTES 7

19 pages

Ch. 6

Ch. 6

24 pages

Ch. 4

Ch. 4

10 pages

Ch. 3

Ch. 3

20 pages

Ch. 2

Ch. 2

28 pages

Ch. 1

Ch. 1

24 pages

Ch. 20

Ch. 20

26 pages

Ch. 19

Ch. 19

18 pages

Ch. 18

Ch. 18

26 pages

Ch. 17

Ch. 17

44 pages

Ch. 16

Ch. 16

38 pages

Ch. 15

Ch. 15

34 pages

Ch. 14

Ch. 14

16 pages

Ch. 13

Ch. 13

16 pages

Ch. 12

Ch. 12

38 pages

Ch. 11

Ch. 11

28 pages

Ch. 10

Ch. 10

40 pages

Ch. 9

Ch. 9

20 pages

Ch. 8

Ch. 8

26 pages

Ch. 7

Ch. 7

26 pages

Load more
Download Simulation Studies
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Simulation Studies and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Simulation Studies 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?