DOC PREVIEW
PSU STAT 401 - Statistical Simulations

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 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 13 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 13 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 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Preliminaries"Proof" by SimulationMatrices in RThe apply function"Proof" of E(S2)=2"Proof" of Var(X+Y)=Var(X-Y)=X2+Y2 for X, Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.OutlinePreliminaries”Proof” of E(S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.Lab4: Introduction to Statistical SimulationsM. George AkritasM. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.Preliminaries”Proof” by SimulationMatrices in RThe apply function”Proof” of E(S2) = σ2”Proof” of Var(X + Y ) = Var(X − Y ) = σ2X+ σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.”Proof” by SimulationMatrices in RThe apply functionIA simulation consists of repeated generation of randomsamples and application of a statistical procedure on eachsample.IIt is used for providing numerical evidence in support of, or incontradiction to, certain probabilistic/statistical claims, orsimply for investigating properties of a statistical procedure.IWe will use simulations to verify thatES2= σ2, while E (S) 6= σ.IIn the process we will also verify that1. As the sample size n → ∞), S2→ σ2, and S → σ.2. For independent X1, X2,Var(X1+ X2) = Var(X1− X2) = σ21+ σ22M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.”Proof” by SimulationMatrices in RThe apply functionNew terminology: Consistent and Unbiased estimatorsIBecause S2→ σ2, as n → ∞, we say that S2is a consistentestimator of σ2. S is also a consistent estimator of σ.IBecause ES2= σ2, we say that S2is an unbiasedestimator of σ2.IBecause E (S) 6= σ, S is a biased estimator of σ.IAll estimators used in statistics are consistent, but some arebiased.IX is both consistent and unbiased estimator for µ, andbp isboth consistent and unbiased estimator for p.M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.”Proof” by SimulationMatrices in RThe apply function1. The matrix command: ”m=matrix(1:10,nrow=2,ncol=5)”I”m=matrix(1:10,nrow=2), m=matrix(1:10, 2)”I”m=matrix(1:10,ncol=2), m=matrix(1:10, 5)”ITry ”m[4,1], m[3,2], m[4,], m[,2]”2. The cbind and rbind commands: ”cbind(m[,1],m[,2]),rbind(m[,1],m[,2])”3. The transpose of a matrix: ”t(m)”4. The diagonal matrix: ”diag(1:4)” or ”x=1:4, diag(x)”5. The identity matrix: ”diag(3), diag(c(1,1,1)), diag(rep(1,3))”6. The inverse of a square matrix A: ”solve(A)”IFor example: ”A=matrix(runif(9,1,5),3), solve(A)”INote: ”diag(A)” returns the diagonal elements of the matrix A.7. Matrix multiplication: A%*%B. Try ”A%*%solve(A)”M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.”Proof” by SimulationMatrices in RThe apply functionIapply is an incredibly useful function for simulations, i.e. formaking the same calculation/procedure repeatedly over manysamples stored as the columns or rows of a matrix.IThe apply function takes three arguments:1. the matrix you wish to apply the procedure to,2. either 1 or 2 depending on whether you are working on therows or the columns, and3. the procedure you wish to apply.IFor example: ”m=matrix(1:10,ncol=2), m”. Try1. ”apply(m,2,sum), apply(m,1,sum)”2. ”x=apply(m,2,sum), sum(x)”, or simply”sum(apply(m,2,sum))”NOTE: A fundamental design feature of R is that the output frommost functions can be used as input to other functions.M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.IThe statement ES2= σ2allows the sample X1, . . . , Xntocome from any population distribution, and n to be anyinteger ≥ 2.IRecalling that expected values are approximated by averages,numerical verification of ES2= σ2entails1. Choosing any population distribution, and any sample size n.2. Generate a large number (say B) of samples of size n fromthat distribution, and calculate S2from each sample.3. Checking that the average of the S2values equals (or is closeto, since we cannot make n = ∞) the population variance σ2.ISimilarly, E (S) 6= σ can be verified by checking that thecorresponding average of the S values is not close to thepopulation standard deviation.M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.IChoose the N(0, 1) distribution, so that σ2= σ = 1.IWe will generateB = 10, 000 samples of size n = 5 from the N(0, 1) distribution:m = matrix(rnorm(50000),ncol=10000)IUse ”mean(apply(m,2,var))” for the average of the 10,000sample variances. This should be close to 1, verifying theunbiasedness of S2.IUse ”mean(apply(m,2,sd))” for the average of the 10,000sample standard deviations. This should not be so close to 1,verifying that S is biased.M. George Akritas Lab4: Introduction to Statistical SimulationsOutlinePreliminaries”Proof” of E (S2) = σ2”Proof” of Var(X+Y ) = Var(X −Y ) = σ2X+σ2Yfor X , Y indep.Lab Assignment #4. Due date: 10/21. Email to Ms. Kraus.The five rows of the matrix m can be thought of as five samples ofsize n = 10, 000.IUse ”mean(apply(m,1,var))” for the average of the fivesample variances. This should be close to 1, verifying theconsistency of S2.ITry also var(m[1,]) for the sample variance of the first row.This should also be


View Full Document
Download Statistical Simulations
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 Statistical Simulations 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 Statistical Simulations 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?