Presentation is loading. Please wait.

Presentation is loading. Please wait.

Haas MFE SAS Workshop Lecture 3: Peng Liu Haas School.

Similar presentations


Presentation on theme: "Haas MFE SAS Workshop Lecture 3: Peng Liu Haas School."— Presentation transcript:

1 Haas MFE SAS Workshop Lecture 3: Peng Liu http://faculty.haas.berkeley.edu/peliu/computing http://faculty.haas.berkeley.edu/peliu/computing Haas School of Business, Berkeley, MFE 2006

2 Commonly used PROCedures in Financial Economics Peng Liu http://faculty.haas.berkeley.edu/peliu/computing http://faculty.haas.berkeley.edu/peliu/computing Haas School of Business, Berkeley, MFE 2006

3 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 3 Basic Statistical Analysis Univariate statistics PROC MEANS; PROC UNIVARIATE; PROC FREQ; Bivariate and Multivariate Statistics PROC CORR; PROC NPAR1WAY; PROC TTEST;

4 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 4 Comparison of PROC MEANS and PROC UNIVARIATE PROC MEANS DESCRIPTIVE STATISTICS CLM CSS CV KURTOSIS LCLM MAX MEAN MIN N NMISS RANGE SKEWNESS STD STDERR SUM SUMWGT UCLM USS VAR QUANTILE STATISTICS MEDIAN|P50 Q1|P25 Q3|P75 P1 P5 P10 P90 P95 P99 RANGE HYPOTHESIS TESTING PROBT T PROC UNIVARIATE DESCRIPTIVE STATISTICS CSS CV KURTOSIS MAX MEAN MIN MODE N NMISS RANGE SKEWNESS STD STDMEAN SUM SUMWGT USS VAR QUANTILE STATISTICS MEDIAN| P1 P5 P10 P90 P95 P99 Q1 Q3 RANGE QUANTILE STATISTICS NORMAL PROBN MSIGN PROBM SIGNRANK PROBS T PROBT ROBUST STATISTICS GINI MAD QN SN STD_SINI STD_MAD STD_QN STD_QRANGE STD_SN

5 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 5 PROC MEANS PROC MEANS DATA=mfe.loan; VAR appraisal ltv; CLASS state; RUN; The default output for PROC MEANS are variable label N Mean Std Dev Min max median min max clm alpha=0.05 are examples of options you can specify. You can get summary statistics for many variables CLASS statements will produce summary stat for each grouping class. You can suppress print using NOPRINT option You can save the result in a self-defined sas dataset. PROC MEANS DATA=mfe.loan max min; VAR appraisal ltv; OUTPUT OUT=m max=maxvalue maxltv min=minvalue minltv; RUN;

6 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 6 PROC UNIVARIATE PROC UNIVARIATE DATA=mfe.loan ; VAR ltv; ID id; RUN; Use VAR to specify which variable you want to analyze, otherwise, this PROC will produce all variables Use ID to identify Extreme Observations, without ID statement it will use observation number by default Can plot histogram, quantile-quantile plots etc. Can do twosided T test, etc. PROC UNIVARIATE DATA=mfe.loan; VAR ltv; HISTOGRAM; QQPLOT /normal; RUN;

7 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 7 PROC FREQ PROC FREQ DATA=mfe.loan; TABLE term; RUN; One-way v.s two-way frequency table /CHISQ or /BINOMIAL option can be used to test equal proportion In one TABLE statement, you can produce more than one frequency tables You can suppress col percentage or/and row percentage by option /nocol norow PROC FREQ DATA=mfe.loan; TABLE state state*term/nocol norow; RUN;

8 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 8 PROC CORR PROC CORR DATA=mfe.loan; VAR rate ltv fico_orig; RUN; The CORR procedure computes Pearson correlation coefficients, three nonparametric measures of association (Spearman rank- oder correlation, Kendall’s taub and Hoeffding’s measure of dependence D), and the probabilities associated with these statistics for numeric variables; The default is Pearson correlation. COV option evolke the computation of covariance PROC CORR DATA=mfe.loan COV SPEARMAN; VAR rate ltv fico_orig; RUN;

9 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 9 PROC TTEST DATA; INPUT a b @@ ; DATALINES; 51 55 64 61 75 74 86 90 95 93 68 71 73 72 90 95 ; RUN; DATA step will produce automatic dataset, if user did not specify one. @@ in INPUT lets SAS continuously read from datelines DATALINES; is a SAS statement followed by lines of raw data. Data are typed continuously separated by blank, you can separated into a different line in the way you like. ; should be stand by itself PROC step will perform specified procedure on current dataset in working directory if user did not specify a particular dataset name Paired T-Test PROC TTEST; PAIRED a*b; RUN;

10 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 10 PROC NPAR1WAY PROC NPAR1WAY DATA=mfe.loan; CLASS state; VAR ltv; RUN; NONPARAMETRIC TEST FOR DIFFERENCE ACROSS ONE- WAY CLASSIFICATION. IF the normality assumption does not hold, we may use some nonparametric tests. PROC NPAR1WAY performs nonparametric tests for location and scale differences across a one-way classiication, based on the following scores: Wilcoxin, Median, Van Der Waerden, Savage, Siegel-Tukey, Ansari-Bradley, Klotz, and Modd Scores.

11 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 11 Financial Econometrics using SAS Linear Models (OLS, GLS and their variates) PROC REG PROC GLM (Skip) Logistic Regression PROC LOGISTIC PROC GENMOD Hazard Regression (Cox-P.H.) PROC PHREG

12 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 12 Linear Model: Theory Data: ( y i, x i =(x i1, x i2, … x ik )) for i=1, …, n and y i  R Model: y i =  0 +  -1x i1 + … +  k x ik +  i for i=1,…,n For short y=X  +  where Assumption:  i are i.i.d. normal N(0,  2 ) Ordinary Least Square Estimation  = (X T X) -1 X T y

13 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 13 PROC REG PROC REG is a SAS procedure for simple or multivariate linear regression models with continuous dependent variables. Part of SAS/STAT Model fitting (parameters, residuals, confidence limits, influential statistics, etc) Model selection (forward, backward, stepwise,,etc) Hypothesis testing Model diagnostics Plotting Outputting estimates and statistics

14 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 14 PROC REG –Examples PROC REG DATA=mfe.loan; MODEL ltv = rate; PLOT ltv * rate; QUIT; Begin with PROC REG; end with QUIT; Multiple independent, dependent variables are separated by space; Label “OLS” is optional, useful for multiple MODEL statement in one PROC REG By default, a constant is included; Use /Options to request additional stat or specify model selection method; PLOT creates a scatter plot of your regression data and automatically adds the regression line. MODEL ltv = rate fico_orig; OLS:MODEL ltv term= rate fico_orig; MODEL ltv = rate fico_orig term/SELECTION=F;

15 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 15 Logistic Regression– Theory Data: ( y i, x i =(x i1, x i2, … x ik )) for i=1, …, n and y i is a binary or ordinal response variable. e.g. y i  {0,1} Model: Maximum Likelihood estimate of  Assumption: binomial Variation

16 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 16 Logistic Regression – SAS procedure SAS has several procedures that performs logistic regression, e.g. GENMOD, CATMOD and LOGISTIC PROC LOGISTIC Works for binary or ordinal response variables Performs MLE using different optimization algorithms 4 model selection methods: F, B, Stepwise, Score Outputs statistics to dataset Tests linear hypotheses of parameters

17 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 17 PROC LOGISTIC –Examples PROC LOGISTIC DATA=mfe.loan; CLASS state edu; MODEL default = ltv age edu term rate state/LINK=LOGIT; RUN; Begin with PROC LOGISTIC; end with QUIT; /LINK=LOGIT option can be ignored, other options: PROBIT, CLOGIT, CLOGLOG Use CLASS statement to avoid creating dummy in DATA step /option can be used to request additional stat, or specify selection method. TEST statement

18 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 18 Survival Analysis – Background 1

19 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 19 Survival Analysis – Background 2

20 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 20 Cox Proportional Hazard Regression

21 Haas School of Business, Berkeley, MFE 2006 Peng Liu AND Alexander Vedrashko 21 PROC PHREG - Example PROC PHREG DATA=mfe.loan; MODEL loanage*prepay(0) = age edu race rate ltv fico_orig state; RUN; Use WHERE option to subset sample to want to regress You can define, group variables inside PHREG after MODEL using IF THEN ELSE Handling tied data: /TIES=EXACT, other option: DISCRETE Run PHREG for different group, use BY option, need to sort data. Use CLASS statement to create dummy variables


Download ppt "Haas MFE SAS Workshop Lecture 3: Peng Liu Haas School."

Similar presentations


Ads by Google