Thursday, May 17, 2012

Libor Scandal

WSJ Analysis Suggests Banks May Have Reported Flawed Interest Data for Libor
"Confidence in Libor matters, because the rate system plays a vital role in the global economy. Central bankers follow it closely as a barometer of the banking system's health, and to decide how much to adjust interest rates to keep their economies growing. Payments on nearly $90 trillion in dollar-denominated mortgage loans, corporate debt and financial contracts rise and fall according to Libor's movements."


Missteps on Libor Doomed Barclays's Leaders
"Mr. Diamond's downfall may have been hastened because the U.S.-born investment banker, who became chief executive at the start of 2011, had never won acceptance by Britain's political and financial establishment. When the rate-fixing scandal erupted, Mr. Diamond had few allies."


Tuesday, May 17, 2011

R Basics

R object types

Here, for more experienced users, is a list of a few of the more important object types.
Vector:
a one-dimensional array of arbitrary length. Subsets of the vector may be referenced. All elements of the vector must be of the same type--numerical, character, etc.
Matrix:
a two-dimensional array with an arbitrary number of rows and columns. Subsets of the matrix may be referenced, and individual rows and columns of the matrix may be handled as vectors. Again all elements of the matrix must be of the same type.
Array:
as a matrix, but of arbitrary dimension.
Data frame:
a set of data organised similarly to a matrix. However each column of the data frame may contain its own type of data. Columns typically correspond to variables in a statistical study, while rows correspond to observations of these variables. A data frame may be handled similarly to a matrix, and individual columns of the data frame may be handled as vectors.
Function:
see Section .
List:
an arbitrary collection of other R objects (which may include other lists).

Wednesday, April 27, 2011

R reference



I've got a R script for which I'd like to be able to supply several command-line parameters (rather than hardcode parameter values in the code itself). The script runs on Windows.
I can't find info on how to read parameters supplied on the command-line into my R script. I'd be surprised if it can't be done, so maybe I'm just not using the best keywords in my Google search...

Answer:
I made two files: exmpl.bat and exmpl.R.
  • exmpl.bat:
    set R_Script="C:\Program Files\R-3.0.2\bin\RScript.exe"
    %R_Script% exmpl.R 2010-01-28 example 100 > exmpl.batch 2>&1
    Alternatively using Rterm.exe:
    set R_TERM="C:\Program Files\R-3.0.2\bin\i386\Rterm.exe"
    %R_TERM% --no-restore --no-save --args 2010-01-28 example 100 < exmpl.R > exmpl.batch 2>&1
  • exmpl.R:
    options(echo=TRUE) # if you want see commands in output file
    args <- span=""> commandArgs(trailingOnly = TRUE)
    print(args)
    # trailingOnly=TRUE means that only your arguments are returned, check:
    # print(commandsArgs(trailingOnly=FALSE))
    
    start_date <- span=""> as.Date(args[1])
    name <- span=""> args[2]
    n <- span=""> as.integer(args[3])
    rm(args)
    
    # Some computations:
    x <- span=""> rnorm(n)
    png(paste(name,".png",sep=""))
    plot(start_date+(1L:n), x)
    dev.off()
    
    summary(x)
Save both files in the same directory and start exmpl.bat. In result you got:
  • example.png with some plot
  • exmpl.batch with all what was done
Just to add - you could add environment variable %R_Script%:
"C:\Program Files\R-3.0.2\bin\RScript.exe"
and use it in your batch scripts as %R_Script% .......
Differences between RScript and Rterm:



Econometrics in R

Shak.blog.notes 08/20/2024

Thinking Like an Architect - InfoQ tags: blog ...