Skip to main content

Posts

Showing posts from 2016

RQuantlib installation in Windows (RQuantLib version 0.4.2)

The RQuantLib installation in Windows is quite straight forward. Download the windows binaries for either devel or release from here https://CRAN.R-project.org/package=RQuantLib Extract the files and copy the RQuanlib folder into the library folder of your R installation E:\R\R-3.1.3\library Once you copy it there fire up RStudio and when you run > library(RQuantLib) QuantLib version 1.6.2 detected which is older than 1.7. Intra-daily options analytics unavailable with that version. Warning message: package ‘RQuantLib’ was built under R version 3.3.1     The version number is older here because I think the CRAN windows binary upload did not make it in time with the QUantlib version 1.8.0. Running getQuantLibVersion will give you the version     > getQuantLibVersion() [1] "1.6.2"

Regression modelling in practice - Week 1 - Writing About Your Data

Week 1 asks to describe the data management steps taken for the dataset selected by describing 1) the sample, 2) the data collection procedure, and 3) a measures section describing the variables and how its been managed to address the research question. The sample The sample dataset being used for the study is the gapminder dataset. This dataset consists of data on 213 countries. Looking at the sample based on incomeperperson a substantial portion of the countries have income below $10000 (N=143; 66%) and a small percentage above $30000 (N=16; 7.5%). The oilperperson has a substantial portion of country data missing (N=150;70%). Barring this most of the other non missing data have countries (N=51;24%) consuming less than 2 tonnes per year per person. The frequency distribution of the polityscore variable shows that most of the countries are highly democratic i.e. score > 5 score (N=97;45%). The armedforces category shows 23% of the data ...

Data Analysis Tools - Week 4 - Testing a Potential Moderator

Week 4 asks to test the relationship between two variables with the dependence of a moderator. In this program I try to see the influence of the moderator variable democracy score over the relationship between the two variables incomeperperson and oil consumption. Program LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly; DATA new; set mydata.gapminder; format democracycategory $25.; /* Democracy score categorisation */ if polityscore le -5 then democracycategory = 'Tyranny\Autocratic'; else if polityscore lt 6 then democracycategory = 'partly democratic'; else if polityscore ge 6 then democracycategory = 'highly democratic'; /* Insert meaningful lables to the variables */ label country="country" oilperperson="Oil per person" incomeperperson="Income per person ($)(based on 2010 dollar exchange rate)" democracycategory="Democracy category" polityscore="Democracy score...

Data Analysis tools - Week 3 - Pearson correlation

Week 3 asks to generate a correlation coefficient to asses the degree of relationship between two or more quantitative variables. In this program I run a test of the Pearson correlation coefficient on the gapminder dataset on the incomeperperson, armedforcesrate and the oil consumption per country. Program LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly; DATA new; set mydata.gapminder; proc sgplot data=new; scatter x=incomeperperson y=armedforcesrate; xaxis grid; yaxis grid; title 'Scatter plot of response variable (Armed forces rate) versus explanatory variable (incomeperperson)'; run; proc sgplot data=new; scatter x=incomeperperson y=oilperperson; xaxis grid; yaxis grid; title 'Scatter plot of response variable (oilperperson) versus explanatory variable (incomeperperson)'; run; proc sgplot data=new; scatter x=armedforcesrate y=oilperperson; xaxis grid; yaxis grid; title 'Scatter plot of response variable (oilperperson) versus ...

Data Analysis tools - Week 2 - Chi Square Test of Independence

Week 2 asks to perform a Chi Square test of independence on two categorical variables. After running on multiple categories in the explanatory variable it asks to perform pair wise post hoc tests of independence and interpret the results. Program LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly; DATA new; set mydata.gapminder; /* Formatting for income and oil */ format oilcategory $35.; format incomecategory $20.; /* Oil categorisation */ if oilperperson le 1 then oilcategory= '<= 1 ton per year'; else if oilperperson gt 1 then oilcategory= '> 1 ton per year'; /* Income per person categorisation */ if incomeperperson le 15000 then incomecategory = '<= $15000'; else if incomeperperson lt 30000 then incomecategory = '$15000 to $30000'; else if incomeperperson gt 30000 then incomecategory = '$30000 and higher'; /* Insert meaningful lables to the variables */ label country = "c...

Data Analysis tools - Week 1 - Running an analysis of variance

The week 1 assignment asks to run an analysis of variance and then analyze and interpret post hoc paired comparisons in instances where the original statistical test was significant, and examining more than two groups (i.e. more than two levels of a categorical, explanatory variable). I have analysed the gapminder dataset. In the analysis I look at the relationship between the income per person (incomecategory) as the explanatory variable and the oil consumption per person (oilperperson) as the response variable. Program LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly; DATA new; set mydata.gapminder; /* Formatting for income, armed forces and oil */ format oilcategory $35.; format incomecategory $20.; format armedforcescategory $20.; /* Oil categorisation */ if /*oilperperson = . then oilcategory='Missing';*/ oilperperson lt 2 then oilcategory= 'Less than 2 tonnes per year'; else if oilperperson lt 4 then oilcategory= '2 to...

Data Visulaization course - Week 4 - Creating graphs for your data

Week 4 assignment asks to prepare univariate and bivariate graphs of the variables in the study and provide a summary of the graphs. Program LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly; DATA new; set mydata.gapminder; /* Formatting for income, armed forces and oil */ format oilcategory $35.; format incomecategory $20.; format armedforcescategory $20.; /* Oil categorisation */ if oilperperson = . then oilcategory='Missing'; else if oilperperson lt 2 then oilcategory= 'Less than 2 tonnes per year'; else if oilperperson lt 4 then oilcategory= '2 to 4 tonnes per year'; else if oilperperson lt 6 then oilcategory= '4 to 6 tonnes per year'; else if oilperperson lt 8 then oilcategory= '6 to 8 tonnes per year'; else if oilperperson gt 8 then oilcategory= 'Greater than 8 tonnes per year'; /* Income per person categorisation */ if incomeperperson = . then incomecategory='Missing...