Skip to content

Posts from the ‘R’ Category

2012 in review by The WordPress.com


Here is a 2012 annual report for this blog produced by The WordPress.com.

My top post this year based on number of views are

  1. R-Uni (A List of Free R Tutorials and Resources in Universities webpages)
    29 COMMENTS February 2012
  2. R Style Guide
    7 COMMENTS June 2012

Click here to see the complete report.

Learn to use R for FREE with Coursera


coursera_logo_RGB

Coursera is offering free courses about R among other interesting subjects. The first one on the application of R in financial econometrics is happening this week (but you can still enroll). There are two more courses starting in January 2013 are more about using R to analyse the data. The differences between the two are stated that:

“This course (Data Analysis by Jeff Leek) will focus on how to plan, carry out, and communicate analyses of real data sets. While we will cover the basics of how to use R to implement these analyses, the course will not cover specific programming skills. Computing for Data Analysis will cover some statistical programming topics that will be useful for this class, but it is not a prerequisite for the course”.

There are more FREE online tutorials about R apart from those in Coursera. Here is the like to list of more than 90 R tutorials.

Introduction to Computational Finance and Financial Econometrics

by Eric Zivot

Learn mathematical and statistical tools and techniques used in quantitative and computational finance. Use the open source R statistical programming language to analyze financial data, estimate statistical models, and construct optimized portfolios. Analyze real world data and solve real world problems.

Next session: Dec 17th 2012 (10 weeks long)

More information: here

Data Analysis 

by Jeff Leek

Learn about the most effective data analysis methods to solve problems and achieve insight.

Next Session:
Jan 2nd 2013 (4 weeks long) You are enrolled!
Workload: 3-5 hours/week

More information: here

Computing for Data Analysis

Roger D. Peng

This course is about learning the fundamental computing skills necessary for effective data analysis. You will learn to program in R and to use R for reading data, writing functions, making informative graphs, and applying modern statistical methods.

Next Session:
Jan 22nd 2013 (8 weeks long) You are enrolled!
Workload: 3-5 hours/week

More information: here

The VDO of this course are also available in YouTube channel of Dr.Roger Peng. So you can check it out below.

Playlist: Week 1

Playlist: Week 2

Playlist: Week 3

Playlist: Week 4

Visualising Tourism Data using R with googleVis package


Inspired by Mages’s post on Accessing and plotting World bank data with R (using googleVis package), I created one visualising tourism receipts and international tourist  arrivals of various countries since 1995. The data used are from the World Bank’s country indicators.

To see the motion chart, double click a picture below.

Tourism googleVis

R_logo_small

 Code

install.packages("googleVis")
library('googleVis')

getWorldBankData <- function(id='SP.POP.TOTL', date='1960:2010',
 value="value", per.page=12000){
 require(RJSONIO)
 url <- paste("http://api.worldbank.org/countries/all/indicators/", id,
 "?date=", date, "&format=json&per_page=", per.page,
 sep="")

 wbData <- fromJSON(url)[[2]]

 wbData = data.frame(
 year = as.numeric(sapply(wbData, "[[", "date")),
 value = as.numeric(sapply(wbData, function(x)
 ifelse(is.null(x[["value"]]),NA, x[["value"]]))),
 country.name = sapply(wbData, function(x) x[["country"]]['value']),
 country.id = sapply(wbData, function(x) x[["country"]]['id'])
 )

 names(wbData)[2] <- value

 return(wbData)
}

getWorldBankCountries <- function(){
 require(RJSONIO)
 wbCountries <-
 fromJSON("http://api.worldbank.org/countries?per_page=12000&format=json")
 wbCountries <- data.frame(t(sapply(wbCountries[[2]], unlist)))
 wbCountries$longitude <- as.numeric(wbCountries$longitude)
 wbCountries$latitude <- as.numeric(wbCountries$latitude)
 levels(wbCountries$region.value) <- gsub(" \\(all income levels\\)",
 "", levels(wbCountries$region.value))
 return(wbCountries)
}

## Create a string 1960:this year, e.g. 1960:2011
years <- paste("1960:", format(Sys.Date(), "%Y"), sep="")

## International Tourism Arrivals
inter.tourist.arrivals<- getWorldBankData(id='ST.INT.ARVL',
 date=years, value="International tourism, number of arrivals")

## International Tourism Receipts
tourism.receipts <- getWorldBankData(id='ST.INT.RCPT.CD', date=years,
 value="International tourism, receipts (current US$)")

## Population
population <- getWorldBankData(id='SP.POP.TOTL', date=years,
 value="population")

## GDP per capita (current US$)
GDP.per.capita <- getWorldBankData(id='NY.GDP.PCAP.CD',
 date=years,
 value="GDP.per.capita.Current.USD")

## Merge data sets
wbData <- merge(tourism.receipts, inter.tourist.arrivals)
wbData <- merge(wbData, population)
wbData <- merge(wbData, GDP.per.capita)

## Get country mappings
wbCountries <- getWorldBankCountries()

## Add regional information
wbData <- merge(wbData, wbCountries[c("iso2Code", "region.value",
 "incomeLevel.value")],
 by.x="country.id", by.y="iso2Code")

## Filter out the aggregates and country id column
subData <- subset(wbData, !region.value %in% "Aggregates" , select=
 -country.id)

## Create a motion chart
M <- gvisMotionChart(subData, idvar="country.name", timevar="year",
 options=list(width=700, height=600))

## Display the chart in your browser
plot(M)

# save as a file
print(M, file="myGoogleVisChart.html")

R in the Press


Here is the list of press reports and news about R

  1. Bits (A blog under The New York Times)
    R you ready for R?
    by Ashlee Vance
    Published: January 8, 2009, 1:52 PM
  2. The New York Times
    Data Analysts Captivated by R’s Power
    by Ashlee Vance
    Published: January 6, 2009
  3.  InfoWorld
    The BI battle isn’t between IBM and SAS
    The little known open source project R may be the disruptor in this billion-dollar market
    By Zack Urlocker
    Published: December 2nd, 2009
  4. TechCrunch
    Big Data Right Now: Five Trendy Open Source Technologies
    by Tim Gasper
    Published: Saturday, October 27th, 2012

My Course Wish List at CMSE next year


Here is the list  of courses I wish to teach next year at Chiang Mai School of Economics, not so sure about the demand there!

Undergraduate (B.Econ.)

Curriculum (pdf) 

  1. ECON 304: Economics Statistics  with an applications in R)
  2. ECON 415: Efficiencies and Productivity Measurement of Industries (Focus on Supply Chain Performance Measurement)
  3. ECON 320: International Business Economics (Focus on Supply Chain Economics for AEC analysis)

or

  • ECON 444: Urban Economics  (Focus on City Logistics in Chiang Mai and other Lanna provinces)
  • ECON 442: Regional Economics (Focus on AEC and GMS)
  • ECON 417: Managerial Economics (Focus on Logistics and Supply Chain Economics)
  • ECON 345: Transportation Economics
  • ECON 408: Research Design in Economics
  • ECON 419: Economic Theory and Entrepreneurship
  • ECON 443: Industrial Economics
  • ECON 4xx: Introduction to Economics of Logistics and Supply Chains (Pre: ECON 301 and Intro. to Business 703103)
  • ECON 4xx: Introduction to Structural Equation Modeling for Economics (Pre: ECON 304) (with R)

Postgraduate

Master (M.Econ.)

  1. ECON 729: Applied Logistics and Supply Chain Economics (Selected Topic in Economic Theory)
  2. ECON 719: Applied  Structural Equation Modeling in Economics (Selected Topics in Quantitative Economics) (with R)

PhD

  1. ECON 829: Advanced Logistics and Supply Chain Economics (Selected Topic in General Economic & Theory)
  2. ECON 819: Advanced  Structural Equation Modeling in Economics (Selected Topics in Advanced Econometrics) (with R)