+ All Categories
Home > Documents > Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician,...

Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician,...

Date post: 18-Dec-2015
Category:
Upload: allan-freeman
View: 216 times
Download: 0 times
Share this document with a friend
27
Jian Chen 1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML
Transcript
Page 1: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 1

Presented by

Jian ChenPhD (Applied Statistics)

MS (Computer Science)

Sr. Statistician, Credigy

Statistical computing with SAS/IML

Page 2: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 2

SAS/IML

SAS Interactive Matrix Language:

Beyond!

Page 3: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 3

Outline

• Overview of SAS/IML.

• Language nuts and bolts.

• An example in Bayesian Analysis.

• Applications.

• References.

Page 4: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 4

Features of SAS/IML

• The simple SAS/IML program:Proc iml;Print ‘Hello World!’;Quit;

• Is a programming language operating on matrices.

• Has a complete set of control statements. • Has a powerful vocabulary of operators. • Can use operators that apply to entire matrices. • Can be interactive.

Page 5: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 5

Features of SAS/IML (2-2)

• Many Base SAS functions are accessible from SAS/IML and has many built-in functions.

• Can define function or subroutine and write the core algorithm.

• Can call a C program (or Fortran, Cobol, PL/I programs) within SAS/IML via the module() functions (Windows only).

Page 6: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 6

With SAS/IML

• Edit existing SAS data sets or create new ones.• Access external files with an extensive set of

data processing commands for data input and output.

Page 7: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 7

Numerical Functions and Algorithms

• Subroutines:– Outlier detection and robust regression.– Performs numerical integration of scalar functions in one

dimension over infinite, connected semi-infinite, and connected finite intervals

– Optimization: for minimizing or maximizing a continuous nonlinear function f = f(x) of n parameters.

• Produce graphics with a powerful set of graphics commands (Need SAS/Graph).

• Kalman Filters.• Time Series Analysis.• Wavelet Analysis.• Genetic Algorithms – Experimental.• Sparse Matrices – Experimental.

Page 8: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 8

An example

– Problem: Assume we know Y(1),…,Y(n), what are the future values: Y(n+1), Y(n+2), ……?

– The p-th autoregressive model: AR(p)

where

)1(,...,...,1)()()(1

nttitYtYp

ii

0/1),0(~))'(),...,1(( 21 INn

Page 9: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 9

Priors• Bayes Approach:• Under the Normal-Gamma prior

where

)()|(),( 21

e12 )(

)()'(22/

1 )|(

Q

p e

Page 10: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 10

Loss Function• Modified Higgins-Tsokos loss function

where and C1 , C2 make the loss function continuous, that is:

0,, 21 aaa

ac

ac

aIfaa

eaea

L

aa

ˆ

ˆ

|-ˆ|1

),ˆ(

2

1

21

)-ˆ(2

)-ˆ(1

12

Page 11: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 11

Loss Function

1

1

21

212

21

211

12

12

aa

eaeac

aa

eaeac

aaaa

aaaa

Page 12: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 12

Loss Function

Page 13: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 13

The k-step Bayes prediction

• The Bayesian predictive density of Wk (k-step ahead Bayes forecasting) is

where Wk=(Y(n+1),Y(n+2),…,Y(n+k) ) and

Sn=(Y(1),…,Y(n));

)2(

|)(|

~)('~'2

)|(

2/1'

2''

QXX

YYQXXQ

SWf

ff

kn

ffff

nk

Page 14: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 14

The k-step Bayes prediction

– where

– Others are the parameters in prior or matrix from n observations.

)'()'(~ 1 YXQXXQ

Page 15: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 15

Example• For Hölfer sunspot data, the shape of the

joint pdf of future two-step ahead forecasting is graphed using (14.1)

Page 16: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 16

Practical k-step ahead forecasting

• Get the one-step ahead forecasting .

• Apply one-step ahead forecasting method again with (Y(1), Y(2), …, Y(n), ) to get .

• ……

)1(~ nY

)1(~ nY

)2(~ nY

Page 17: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 17

K-th step ahead forecasting

• The pdf of one-step ahead forecasting is:

nnnffn

nff

ff

YYQYXQXXQXYQc

QYXQXXXb

XQXXXa

where

nna

bac

a

btt

'''0

1''0

''

''0

1'

'1'

2

2

)())((2

)()(

)(1

)2,)2(

,(

Page 18: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 18

K-th step ahead forecasting• where t-distribution is defined as

)(

))(

1()2(

)21

()(~

),,(

2

12

xt

a

x

axfX

a

Page 19: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 19

Bayes estimate under MHT loss• Bayes expected loss:

dtcdtc

dtaa

eaea

dSpxYLx

axn

na

bac

a

b

ax

nna

bac

a

b

ax

ax nna

bac

a

b

xaxa

nn

)()(

)()1(

)|(),()(

)2,)2(

,(2

)2,)2(

,(1

)2,)2(

,(21

)-(2

)-(1

1

2

2

2

2

2

2

12

Page 20: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 20

Bayes estimate under MHT loss

– Bayes estimate (Bayes action) under MHT loss function.

)(min)1(ˆ xnYMHT

Page 21: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 21

Simulation and Calculation with SAS

– Based on the assumption on priors, simulate the parameters in model (7.1).

– Generate AR(p) series.

– Calculate the one-step ahead Bayes estimate under MHT loss function.

– Calculate the two-step ahead Bayes estimate under MHT loss function.

Page 22: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 22

Simulation and Calculation with SAS

SAS techniques used:– Simulation– Time Series (model identification and

calculation).– SAS/IML:

• Import from/export to SAS dataset. Interface with other SAS PROCs.

• Matrix calculation.• Integration.• Optimization.

Page 23: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 23

Integration

• CALL QUAD ( result, "fun", points <, EPS=eps> <, PEAK=peak>   <, SCALE=scale> <, MSG=msg> <, CYCLES=cycles> ) ;

• CALL QUAD ( r, "fun", points) < EPS=eps> < PEAK=peak> < SCALE=scale> < MSG=msg> < CYCLES=cycles> ;

• The QUAD subroutine quad is a numerical integrator based on adaptive Romberg-type integration techniques. Refer to Rice (1973), Sikorsky (1982), Sikorsky and Stenger (1984), and Stenger (1973a, 1973b, 1978).

Page 24: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 24

Optimization

• Optimization: The IML procedure offers a set of optimization subroutines for minimizing or maximizing a continuous nonlinear function f = f(x) of n parameters, where x = (x1, ... ,xn)’:

– NLPCG Conjugate Gradient Method

– NLPDD Double Dogleg Method

– NLPNMS Nelder-Mead Simplex Method

– NLPNRA Newton-Raphson Method

– NLPNRR Newton-Raphson Ridge Method

– NLPQN (Dual) Quasi-Newton Method

– NLPQUA Quadratic Optimization Method

– NLPTR Trust-Region Method

Page 25: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 25

Applications

• “Computing Group Sequential Boundaries Using the Lan-DeMets Method with SAS”.

• Sample size and power analysis. • SAS for Monte Carlo Studies: A Guide for Quantitative

Researchers: By Xitao Fan, Akos Felsovalyi, Stephen A. Sivo, and Sean C. Keenan: http://support.sas.com/publishing/bbu/companion_site/57323.html

• A collection of SAS macro programs using SAS/IML software to generate, randomize and inspect orthogonal arrays for computer experiments and integration.

http://sunsite.univie.ac.at/statlib/designs/oa.SAS

Page 26: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 26

References

• Jian Chen, Bayes Inferences and forecasting of Time Series, PhD thesis, UNC Charlotte.

• SAS Online Documentation for SAS/IML: http://support.sas.com/onlinedoc/913

/docMainpage.jsp

• Sample programs installed with your installation:

Located in directory: C:\Program Files\SAS\ SAS 9.1 \iml\sample

Page 27: Jian Chen1 Presented by Jian Chen PhD (Applied Statistics) MS (Computer Science) Sr. Statistician, Credigy Statistical computing with SAS/IML.

Jian Chen 27


Recommended