# R code

### R Code for A Justification and Application of Eigenvector Centrality

November 8, 2012 |

Leo Spizzirri  does an excellent job of providing mathematical intuition behind eigenvector centrality. As I was reading through it, I found it easier to just work through the matrix operations he proposes using R.  You can find his paper her...

### Do you still have time to sleep ?

June 11, 2012 |

Last week, @3wen (Ewen) helped me to write nice R functions to extract tweets in R and build datasets containing a lot of information. I've tried a couple of time on my own. Once on tweet contents, but it was not convincing and once on the activit... [Read more...]

### Using SNA in Predictive Modeling

April 10, 2012 |

In a previous post, I described the basics of social network analysis. I plan to extend that example here with an application in predictive analytics. Let's suppose we have the following network (visualized in R)Suppose we have used the igraph package ...

### An Introduction to Social Network Analysis with R and NetDraw

April 10, 2012 |

With the rise in the use of social media, data related to social networks is ripe for analysis using techniques from social network analysis and graph theory. According to International Network for Social Network Analysis, ‘Social network analysis is... [Read more...]

### Regression via Gradient Descent in R

November 27, 2011 |

In a previous post I derived the least squares estimators using basic calculus, algebra, and arithmetic, and also showed how the same results can be achieved using the canned functions in SAS and R or via the matrix programming capabilities offered by ...

### Basic Econometrics in R and SAS

November 27, 2011 |

Regression Basicsy= b0 + b1 *X  ‘regression line we want to fit’The method of least squares minimizes the squared distance between the line ‘y’ andindividual data observations yi. That is minimize: ∑ ei2 = ∑ (yi - b0 -  b1 Xi...

November 27, 2011 |

In a previous post I discussed the concept of gradient descent.  Given some recent work in the online machine learning course offered at Stanford,  I'm going to extend that discussion with an actual example using R-code  (the actual code...

### Bayesian Models with Censored Data: A comparison of OLS, tobit and bayesian models

September 17, 2011 |

The following R code models a censored dependent variable (in this case academic aptitude) using a traditional least squares, tobit, and Bayesian approaches.  As depicted below, the OLS estimates (blue) for censored data are inconsistent and will ...

### Elements of Bayesian Econometrics

September 16, 2011 |

posterior = (likelihood x prior) / integrated likelihoodThe combination of a prior distribution and a likelihood function is utilized to produce a posterior distribution.  Incorporating information from both the prior distribution and the likelihood function leads to a reduction in variance and an improved estimator. As n→ ∞ the likelihood centers over the ...

### QTL Analysis in R

August 13, 2011 |

See also: Part 1: QTL Analysis and Quantitative Genetics  Part 2: Statistical Methods for QTL Analysis The 'qtl' package in R allows you to implement QTL analysis using the methods I've previously discussed. The code below is adapted from Broman... [Read more...]

### R Program Documentation Template

August 13, 2011 |

# ------------------------------------------------------------------ # |PROGRAM NAME: # |DATE: # |CREATED BY: MATT BOGARD # |PROJECT FILE: # |---------------------------------------------------------------- # | PURPOSE: ...

### Plotting Cumulative FII & DII Inflow against Nifty spot index

August 10, 2011 |

Now that I have the FII and DII Inflow along with Nifty Index, I tried my hands on charting!The objective is to plot the Cumulative FII, DII and Net Inflow and Nifty Index for current year (2011) on a single graph. This post takes inspiration from Deep... [Read more...]

August 8, 2011 |

My thirst for statistics has been increasing. IV had another requirement, which would eventually be useful to me as well. He currently downloads FII and DII buy and sell values and its impact on Nifty manually in Excel. He suggested me to try and autom...

### Marketing optimization using the nonlinear minimization function nlm

July 28, 2011 |

Guest post by Bob Agnew ([email protected]) —————- Introduction Marketing optimization consists of assigning offers to prospects in order to [Read more...]

### BSE Bhavcopy with Delivery Quantity

July 24, 2011 |

One of my TI forum members IV had a requirement for BSE Quotes along with Delivery Quantity. This made me implement "merge" function of R coding (thanks to the great work done by people behind various packages and guidance available on R Mailing lists)...

July 19, 2011 |

### Extracting EOD Data from NSE

July 19, 2011 |

My prime interest being the Indian financial markets, the first step would be to get the data to play around. NSE India provides EOD of data as bhavcopies. The same are stored as zipped files at their servers. Downloading them one by one for a larger t...

### %EXPORT_TO_R SAS Macro Code

May 6, 2011 |

The SAS Analysis blog post 'A macro calls R in SAS for paneled 3d plotting' influenced my macro coding.   The following macro call: %EXPORT_TO_R(DATA = YOURDATA)  exports the SAS data set 'YOURDATA' as .csv and produces the R code for se...

### An Intuitive Approach to ROC Curves (with SAS & R)

May 6, 2011 |

I developed the following schematic (with annotations) based on supporting documents (link) from the article cited below. The authors used R for their work. The ROC curve in my schematic was output from PROC LOGISTIC in SAS, the scatterplot with m...