Wednesday, December 12, 2012

MATLAB External Links on Indexing, Structure & Functions

Join our MATLAB for financial engineering course (http://www.wiziq.com/course/7225-matlab-for-financial-engineering) & get 15% discount. Ask for discount code, email - info@qcfinance.in



Three major topics:

Indexing MATLAB

http://www.mathworks.in/company/newsletters/articles/Matrix-Indexing-in-MATLAB/matrix.html

http://www.mathworks.in/help/matlab/math/matrix-indexing.html;jsessionid=fb0677fdc592efa46a4cecf14a0e?s_tid=doc_12b

http://www.psi.toronto.edu/~vincent/matlabindexrepmat.html

http://stackoverflow.com/questions/4842512/matlab-indexing-question

http://www.mathworks.in/help/matlab/learn_matlab/array-indexing.html

http://stackoverflow.com/questions/11023010/matlab-indexing-into-2d-array-using

http://www.mathworks.in/help/matlab/cell-arrays.html

http://www.mathworks.in/help/matlab/indexing.html

http://www.mathworks.com/matlabcentral/newsreader/view_thread/270741

http://blogs.mathworks.com/steve/2008/01/28/logical-indexing/

http://blogs.mathworks.com/loren/2006/06/21/cell-arrays-and-their-contents/#3

http://www.eng.utah.edu/~cs5310/cs1000/notes11.html

http://www.psi.toronto.edu/~vincent/matlabindexrepmat.html

http://www.mathworks.in/help/matlab/math/matrix-indexing.html?s_tid=doc_12b


Structure

http://stackoverflow.com/questions/1882035/how-do-i-access-matlab-structure-fields-within-a-loop

http://www.mathworks.in/help/matlab/structures.html

http://www.mathworks.in/help/matlab/ref/struct.html

http://www.mathworks.in/help/matlab/ref/getfield.html

http://www.cs.utah.edu/~germain/PPS/Topics/Matlab/structures.html

http://www.atmos.washington.edu/~mitchell/matlab_strings.html

http://www.mathworks.in/help/stats/statset.html

http://www.mathworks.in/help/matlab/ref/cell2struct.html

http://www.mathworks.com/matlabcentral/fileexchange/22752-compare-structures

http://www.mathworks.in/help/matlab/matlab_prog/cell-vs-struct-arrays.html


Array & Functions

http://web.cecs.pdx.edu/~gerry/MATLAB/programming/basics.html

http://amath.colorado.edu/computing/Matlab/Tutorial/Programming2.html

http://www.math.tamu.edu/~fnarc/psfiles/matlab_fn.pdf

http://www.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html

http://ws2.binghamton.edu/fowler/fowler%20personal%20page/EE521_files/MATLAB%20Functions.pdf

http://ocw.mit.edu/resources/res-18-002-introduction-to-matlab-spring-2008/other-matlab-resources-at-mit/tutorial06.pdf

http://www.ele.uri.edu/Courses/ele541/tutorials/matlab.html

http://www.life.illinois.edu/mcb/419/matlab/html/tut3.html 

http://en.wikibooks.org/wiki/MATLAB_Programming/Struct_Arrays

http://www.mathworks.in/products/matlab/examples.html?file=/products/demos/shipping/matlab/strucdem.html


Application:

Portfolio

http://www.mathworks.in/discovery/portfolio-optimization.html

http://www.mathworks.in/help/finance/examples/mean-variance-efficient-frontier.html

http://www.mathworks.in/help/finance/portcons.html


Regression

http://www.mathworks.in/help/stats/regress.html

http://www.mathworks.in/help/stats/understanding-linear-regression-outputs.html

http://www.mathworks.in/help/matlab/data_analysis/linear-regression.html

http://www.mathworks.in/help/econ/examples/time-series-regression-vii-forecasting.html

http://dynsys.uml.edu/tutorials/Regression_Analysis/regression_analysis_tutorial_012005.pdf

http://chemwiki.ucdavis.edu/@api/deki/pages/2962/pdf

http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/LinearCurveFit.html

http://www.mathworks.in/help/nnet/ref/regression.html

Sunday, October 7, 2012

SAS Statistical Business Analyst Using SAS 9 Prep

SAS Statistical Business Analyst Using SAS 9 Prep




Exam topics include:


ANOVA

  • Verify the assumptions of ANOVA.
  • Analyze differences between population means using the GLM and TTEST procedures.
  • Perform ANOVA post hoc test to evaluate treatment effect.
  • Detect and analyze interactions between factors.
Linear Regression

  • Fit a multiple linear regression model using the REG and GLM procedures.
  • Analyze the output of the REG procedure for multiple linear regression models.
  • Use the REG procedure to perform model selection.
  • Assess the validity of a given regression model through the use of diagnostic and residual analysis.
Logistic Regression

  • Perform logistic regression with the LOGISTIC procedure.
  • Optimize model performance through input selection.
  • Interpret the output of the LOGISTIC procedure.
  • Score new data sets using the LOGISTIC and SCORE procedures.
Prepare Inputs for Predictive Model Performance

  • Identify potential problems with input data.
  • Use the DATA step to manipulate data with loops, arrays, conditional statements and functions.
  • Reduce the number of categorical levels in a predictive model.
  • Screen variables for irrelevance using the CORR procedure.
  • Screen variables for non-linearity using empirical logit plots.
Measure Model Performance

  • Apply the principles of honest assessment to model performance measurement.
  • Assess classifier performance using the confusion matrix.
  • Model selection and validation using training and validation data.
  • Create and interpret graphs (ROC, lift, and gains charts) for model comparison and selection.
  • Establish effective decision cut-off values for scoring.
Prerequisite Basic Concepts 
  • descriptive statistics
  • inferential statistics
  • steps for conducting a hypothesis test
  • basics of using your SAS software
Introduction to Statistics 
  • examining data distributions
  • obtaining and interpreting sample statistics using the UNIVARIATE and MEANS procedures
  • examining data distributions graphically in the UNIVARIATE and SGPLOT procedures
  • constructing confidence intervals
  • performing simple tests of hypothesis
t Tests and Analysis of Variance 
  • performing tests of differences between two group means using PROC TEST.
  • performing one-way ANOVA with the GLM procedure.
  • performing post-hoc multiple comparisons tests in PROC GLM.
  • performing two-way ANOVA with and without interactions.
Linear Regression 
  • producing correlations with the CORR procedure.
  • fitting a simple linear regression model with the REG procedure.
  • understanding the concepts of multiple regression.
  • using automated model selection techniques in PROC REG to choose from among several candidate models.
  • interpreting models.
Linear Regression Diagnostics 
  • examining residuals
  • investigating influential observations
  • assessing collinearity
Categorical Data Analysis 
  • producing frequency tables with the FREQ procedure
  • examining tests for general and linear association using the FREQ procedure
  • understanding exact tests
  • understanding the concepts of logistic regression
  • fitting univariate and multivariate logistic regression models using the LOGISTIC procedure
Predictive Modeling 
  • business applications
  • analytical challenges
Fitting the Model 
  • parameter estimation
  • adjustments for oversampling
Preparing the Input Variables 
  • missing values
  • categorical inputs
  • variable clustering
  • variable screening
  • subset selection
Classifier Performance 
  • ROC curves and Lift charts
  • optimal cutoffs
  • K-S statistic
  • c statistic
  • profit
  • evaluating a series of models


Link: http://support.sas.com/certify/creds/sba.html#t2



Friday, August 31, 2012

SAS Base Certification Preparation Advice Strategy


Data Step
Proc Step

Library referring

VB is more to excel linked work, which handles less data, like 2-3 lack entries
SQL is generic and common to all MATLAB SAS VBA
it is database methodology
R is a free solution for MATLAB SAS
SAS is more database manatment less maths
MATLAB is more maths less database

Saturday, August 25, 2012

Market Risk Credit Risk FRM L2 (Book1) Prep Strategy Info [Learn FRM using MATLAB/R/VBA]

Market Risk FRM L2

Three most interesting areas in Market Risk Uni variate and Multi Variate :
  1. EVT
  2. Multi Variate Models
  3. Back Testing
  4. Monte Carlo
  5. Copula

4 Chapters in which the area is divided:
  1. Uni variate
  2. Multivariate
  3. Volatility
  4. MBS: OAS, etc. Pre payment, trenching, etc

The first two might be theoretical and more maths, but the last 2 are seen extensively in the market. Volatility index is something which is often seen and an important area.


Credit risk
A highly practical subject
  1. Includes CDO, CDS, pre payments, etc
  2. default probability and CDS
  3. sovereign rating: GDP, currency and debt of the nation
  4. measuring default from market prices
  5. spread and default
  6. merton model
  7. currency swap interest rate swap
  8. CDO structure trenching: junior senior

Other topics
Hedge fund risk / portfolio risk

MATLAB VAR:
http://gloria-mundi.com/library_journal_view.asp?journal_id=8769
http://www.mathworks.com/matlabcentral/fileexchange/32154-estimation-value-at-risk-by-using-conditional-copula-garch
http://www.mathworks.com/help/finance/conditional-value-at-risk-portfolio-optimization.html
http://www.mathworks.com/help/finance/portvrisk.html
http://www.docstoc.com/docs/73976635/Matlab-Code-for-Value-at-Risk-Methods
http://www.analyticsresearch.net/Documents/VALUE%20AT%20RISK.new4practical.pdf
http://datavir.com/?p=304
http://www.thetaris.com/wiki/Value_at_Risk
http://www.mathfinance.cn/value-at-risk-estimation-with-copula/
http://www.sfu.ca/~rgencay/evim.pdf
https://editorialexpress.com/cgi-bin/conference/download.cgi?db_name=ESAM2011&paper_id=145
http://phd.london.edu/pnath.phd98/MatlabUtilities.htm

Wednesday, August 22, 2012

R for Financial Engineering Course on Applying R in Quantitative Finance/ Analytics & Projects at qcfinance.in

R for Financial Engineering / Quantitative Finance


R is mix of MATLAB and SAS, if I relate to the other 2 tools used in Finance.
R is having mix of maths and data handling powers of SAS and given that it is open source and the best choice for research.

R is MATLAB when it comes to syntax.
When it comes to data handling it uses RMySQL in the very same way as SAS does.
Hence, it does things that SAS+MATLAB do for free.
SQL has inherent limitations of doing quant computations, and MATLAB is heave and requires too much resources. MATLAB is not very good to deal with SQL at system level.

But to start with, one also needs to know VBA for entry level and for easy task, VBA is preferred.


Divisions:
  1. 10 hours on handling data, functions, indexing, structures, data linkages, importing, SQL, etc
  2. 10 hours on Financial Commands, tools, pre-built libraries.


I will discuss in detail about R and its application in this post.

Keep checking it for updates.


Ref: R in a Nutshell

For getting some info you can join my MATLAB Course at:
http://stockcreditfinancecfa.blogspot.com/2012/07/50-hours-course-in-matlab-for-finance.html

Join our MATLAB for financial engineering course (http://www.wiziq.com/course/7225-matlab-for-financial-engineering) & get 15% discount. Ask for discount code, e-mail:- info@qcfinance.in.


Course based on:

http://www.unicom.co.uk/quant-finance/R-for-Finance.php

http://www.optirisk-systems.com/papers/FinancewithR.pdf

http://www.optirisk-systems.com/events/finance-with-r.asp

https://www.rmetrics.org/ebooks-basicr

http://www.r-bloggers.com/search/finance

http://www.rinfinance.com/RinFinance2009/presentations/ChicagoWuertz.pdf

http://blog.revolutionanalytics.com/2011/11/course-financial-data-modeling-and-analysis-in-r.html

http://braverock.com/brian/R/PerformanceAnalytics/html/PerformanceAnalytics-package.html

http://www.quantmod.com/documentation/00Index.html

http://tradeblotter.files.wordpress.com/2012/06/uw_r_seminar_may_2012.pdf


Introduction to R
  • Some background on R, how to obtain and how to install it.
  • R documentation and help and web resources available.
  • R Console and R GUI.
  • Data import, data types and variables.
  • Elementary import functions.
  • Data types.
  • Variable generation, inspection and modification.
  • Graphics in R.
  • Command "plot" and where to plot.
  • Setting the par.
  • High-level and low-level plotting functions legends.
  • Math in plots.  
  • Hands-on Session—data handling & graphics.
  • Simulations in R.
  • Simulating from given distributions.
  • Risk management basics.
  • Data Structures in R.
  • Review of types of objects.    
  • Additional object types.
  • Basics of the R Language. 
  • Conditionals & Loops. 
  • Writing R Functions: Basic functions.
  • Object-orientation.
  • Debugging.
  • Application in Finance.
  • Calculating Value at Risk.
  • Packages for Portfolio Optimization. 


Functions of R/R Commands to be covered in the course:
Caution: Always save workspace.
Use “c” when you want to use it a signal in black scholes formula.

read.table function will be used to get the data into R (/\ used opposite
than the one used in windows)
http://www.ats.ucla.edu/stat/r/faq/inputdata_R.htm.

Example 1
> test.txt <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My
Documents/test.txt", header=T)
> print(test.txt)
> column <- test.txt[,c('make','price')].

Example 2
grb <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My
Documents/GRB_afterglow.dat", header=T, skip=1)
x <- (grb[,1]).

Grabbing data from tables into a single dimensional array
x <- (grb[,1])
y <- log(grb[,1]).

Another way to create returns for stock daily return is
f=dft$age/dft$price (using dollar sign extraction)
Deleting column http://www.sr.bham.ac.uk/~ajrs/R/r-manipulate_data.html
> add <- add[-2] to delete the element 2nd
Adding data to array busing column command
> add <- c(1,d).


Using Data frames
Data.frame is used to combine the arrays back into table format
people = data.frame (x,y)
Write.CSV command executed
write.csv(people,"filename.csv")

grb <- read.table ("C:/Documents and Settings/satyadhar.joshi/My
Documents/GRB_afterglow.dat", header=T, skip=1)
x <- (grb[,1])
y <- log(grb[,1])
people = data.frame (x,y)
write.csv(people,"filename.csv")

These methods can be used to compute beta from columns of a csv file.


Working formula of Black Scholes
BS <-
function(S, K, T, r, sig, type="C"){
d1 <- (log(S/K) + (r + sig^2/2)*T) / (sig*sqrt(T))
d2 <- d1 - sig*sqrt(T)
if(type=="C"){
value <- S*pnorm(d1) - K*exp(-r*T)*pnorm(d2)
}
if(type=="P"){
value <- K*exp(-r*T)*pnorm(-d2) - S*pnorm(-d1)
}
return(value)
}

Black Scholes <- function(s, k, r=.1, t=5, sigma=.9,call=TRUE) {
#calculate call/put option
d1 <- (log(s/k)+(r+sigma^2/2)*t)/(sigma*sqrt(t))
d2 <- d1 - sigma * sqrt(t)
ifelse(call==TRUE,s*pnorm(d1) - k*exp(-r*t)*pnorm(d2),k*exp(-r*t)
* pnorm(-d2) - s*pnorm(-d1))
}


Predefined Black schools model:
http://shafik.net/~shafik/FinancialEngineering/Code/
black_scholes ("c",5600,5600,.1,.08,.22 )
this depicts use of functions in R.


Merton Distance to Default (different as per needs)
(modified from Black Scholes formula, still
unsure about pnorm() function)
d1 <- (log(s/k)+(sigma^2/2))/(sigma)
pnorm(d1)

3 files are needed to run the demos which are available on internet by various authors:
  1. black_scholes.R
  2. GRB_afterglow.dat
  3. test.txt.

ARIMA and Forecasting Using R

Commands:

library(Quandl)
> Quandl.auth("1LkmpypqJskJzKcpd2TV")

>stockData=Quandl("YAHOO/INDEX_GSPC", start_date="2004-01-01", end_date="2014-04-17")

stockData[,7]

// ran Arima here:
results2=arima(stockData[,7], order = c(3,0,0))

fit <- arima(myts, order=c(p, d, q)

fit <- arima(stockData[,7],order = c(3,0,0))

results=arima(stockData[,7])

fit <- arima(stockData[,7],order = c(3,0,0))

predict(arima(stockData[,7], order = c(3,0,0))

results=arima(stockData[,7])

x2=(forecast(fit, 100))

plot(x2).


Excel and R:
http://rcom.univie.ac.at/download.html#statconnDCOM
http://www.r-bloggers.com/a-million-ways-to-connect-r-and-excel/
http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf
http://cran.r-project.org/web/packages/XLConnect/XLConnect.pdf
https://stat.ethz.ch/R-manual/R-patched/library/base/html/getwd.html


Playing with arrays and matrix
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f
https://stat.ethz.ch/pipermail/r-help/2008-February/154088.html
http://stat.ethz.ch/R-manual/R-devel/library/base/html/rev.html.

ARIMA and Predict statement
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/predict.arima.html
http://people.duke.edu/~rnau/411arim.htm
http://www.statmethods.net/advstats/timeseries.html
http://stackoverflow.com/questions/14272937/time-series-prediction-using-r
http://www.inside-r.org/packages/cran/forecast/docs/forecast.Arima.

Market check
http://www.bloomberg.com/quote/SPX:IND/chart.

Other good References
http://heather.cs.ucdavis.edu/~matloff/132/NSPpart.pdf.


One on One Customized Training:
qcfinance.in believes in personalized touch so that our clients are completely satisfied with our service. In this regard, we offer One on One Customized Training to our clients.
These Trainings are provided on request by our clients & are customized according to their individual needs.
The course structure & timings for these training are highly flexible, classes are scheduled as per the convenience of our clients. 

Contact Us for More details: info@qcfinance.in.

Saturday, July 21, 2012

20 hours online course on MATLAB for Financial Engineering / Quants

20 Hours Course On MATLAB For Financial Engineering @Wiziq.com


Class TopicDuration
1
Introduction To Programming in MATLAB
2 Hours
2
Introduction To Quant Corporate Finance
2 Hours
3
Data Handling & Visualization in MATLAB
2 Hours
4
Five MATLAB Toolboxes for Finance
2 Hours
5
Fixed Income
2 Hours
6
Financial Time Series
2 Hours
7
Distributions & VAR
2 Hours
8
Portfolio Optimization
2 Hours
9
Black Scholes & Monte Carlo
2 Hours
10
Revision
2 Hours


Course highlights:
  • Useful for financial analysts, accountants & others to perform analysis.
  • Requires no programming knowledge - if you use word, you can use MATLAB.
  • Demo class can be registered as per convenience.
  • Course consists of 35-40% live classes.
  • Scheduling of doubt clearing class as per convenience.

Key points about the course:
  1. Requires absolutely no knowledge of programming.
  2. Highly flexible and tailored as per needs of individual.
  3. Sensitization on derivative, quant, fixed income, portfolio, VAR modelling.
  4. Gives introduction to all features of MATLAB in Finance.
  5. Provide introduction about all Quantitative roles in Finance.
  6. Helpful for passing FRM, CFA, BAT exams.
  7. Prepares for Master level studies in Finance or career change.
  8. Right mix of data handling, scripting, mathematical skills.
  9. Helpful for technical analysis.
  10. Contains right blend of learning and practice (Ratio 6:4).

Course Link:

To know more about the platform, you can also join our free course on wizIQ:

http://www.wiziq.com/course/708-CFA-Classes-Discussions-Study-Group-for-Self-Prep


Course agenda in detail:

Class 1:

  • Utility of course.
  • How it takes you beyond excel.
  • Comparison of MATLAB-SAS-R-Excel/VBA.

Class 2:
  • Matrix, types of data.
  • Types of array/matrix/data types/vector arrays etc.
  • Reducing and selecting of Matrix.
  • Looping for data handing in Excel.
  • Movement and arrays of data.
  • Data management or data cleaning or data optimization skills used in MATLAB.
  • Loop for data correction like addressing blank or data types management.
  • Data cleaning, data modifications, data arrays, struct, rating matrix, selection of elements from rating matrix.
Class 3:
  • Array handling & how to manage Data for Quant Finance.
  • Preparing Data For Final Analysis of Algorithmic Trading & VAR Computations.
  • Reading Data from SQL Database & Linking the System.
  • MATLAB Database Toolbox.
  • Making Chart.
Class 4:
  • Statistical Toolbox.
  • Symbolic computation toolbox.
  • Fixed income. 
  • Econometrics (Monte Carlo).
  • Derivatives.
Class 5:
  • Financial Terms Used.
  • Basics of all Terms.
  • Generic Knowledge About the industry - Spreads Changing, Bank Rating Consumer, Shorting CDS, Cause & Role of Goldman or Greece Crisis.
Class 6:
  • Box Cox Transformation Method.
  • Ito Process.
  • ARCH GARCH.
  • Stochastic Volatility. 
Class 7:

Normalizing and making data relevant by Data cleaning (playing with matrix) example for financial times series.

Class 8:

  • Statistical Modelling.
  • VAR Modelling.
  • Risk Assessment.
  • FRM Level 2 Library.
  • FRM Level 2 Terms in MATLAB.
  • Statistics Toolbox.
  • Copula.
Class 9:
  • Scenario & Sensitivity Analysis.
  • Portfolio Optimization.
  • Asset Liability Management.
  • Monte Carlo.
  • Algorithmic Trading.
Class 10:

Revision Class - Thorough Review of studied areas & doubt clearing session.


Books recommended:
  • MATLAB Basics and Beyond (This book has lot of graphics and data type forms).
  • MATLAB Primer.
Topics for Advanced MATLAB:
  • Functions overloading.
  • Random generation.
  • Matrix manipulation.
  • Advanced indexing.
  • Dimension expansion.
  • User input.
  • Inline functions.
  • Newton Raphson.
  • Call Function input.
  • Call Function.
  • Array Slicing.
  • Mesh grids.
  • Sums & cumulative products.
  • Loop: manipulate/do while vs. while/switch cases, while loop, when to use which.


MATLAB CFA overlap:
  • Fixed Income (80%)
  • Derivatives (80%)
  • Quant (100%)
  • Portfolio (70%)

Youtube Videos:




References:


http://www.mathworks.in/help/techdoc/ref/struct.html
http://www.mathworks.in/help/techdoc/ref/size.html

http://www.mathworks.in/help/techdoc/ref/f16-42340.html

http://www.mathworks.in/products/matlab/demos.html?file=/products/demos/shipping/matlab/demo.html




Uploaded by Shivgan on WizIQ Tutorials



Links To some of the Recordings:



Contact Us

Course Teacher: Shivgan Joshi (shivgan@qcfinance.in/shivgan3@gmail.com).

Course Manager: Arpit (arpit@qcfinance.in).



ONE ON ONE CLASSES ALSO AVAILABLE ON REQUEST.



One on One Customized Training:
qcfinance.in believes in personalized touch so that our clients are completely satisfied with our service. In this regard, we offer One on One Customized Training to our clients.
These Trainings are provided on request by our clients & are customized according to their individual needs.
The course structure & timings for these training are highly flexible, classes are scheduled as per the convenience of our clients.
We have four to five teachers specialized in different areas of MATLAB, and our teachers can be reached on flexible timings. Our teachers have also recorded their videos which are uploaded on the course.

Contact Us for More details: info@qcfinance.in



Modules Under Development:


Monte Carlo methods for Equity Projections (MATLAB for Equity Research in Investment Banking), where the main focus is on revenue growth and then growing other things in a custom way. Other things that increases the complexity of models is decisions such as (what to do with extra cash: repo, dividend  debt reduction, etc). Robust environment of MATLAB with lots of predefined functions help the analysis very easy. 

http://www.mathworks.in/help/finance/portsim.html.


Step 1: Returns.

Step 2: Correlations.
Step 3: Random number.
Step 4: Running simulation.


Quantitative Game theory applications in MATLAB, where the search is for Nash Equilibrium and finding out the best strategy that work given what would happen at each path. The area is niche and involves cooperative and non cooperative games.