January 2013

El Nino and ggplot2

January 21, 2013 | fernando tenorio

Some days ago i've got stucked in what appears to be a simple task: read some El Nino data, and then plot it. The problem was the data file format, which you can find here: El Nino Data. There's a mix between 'white space' and '.' characters, so read.... [Read more...]

Americans Live Longer and Work Less

January 21, 2013 | John Myles White

Today I saw an article on Hacker News entitled, “America’s CEOs Want You to Work Until You’re 70″. I was particularly surprised by this article appearing out of the blue because I take it for granted that America will eventually have to raise the retirement age to avoid bankruptcy. ... [Read more...]

Improved evolution of correlations

January 21, 2013 | FelixS

Update June 2013: A systematic analysis of the topic has been published:Schönbrodt, F. D., & Perugini, M. (2013). At what sample size do correlations stabilize? Journal of Research in Personality, 47, 609-612. doi:10.1016/j.jrp.2013.05.009 Check also the supplementary website, where you can find the PDF of the paper. As an update ... [Read more...]

Clustering and sector strength

January 21, 2013 | Pat

An exploration of the usefulness of sectors. Previously This subject was discussed in “S&P 500 sector strengths”. Idea Stocks are put into groups based on the sector that the company is considered to be in.  Cluster analysis is a statistical technique that finds groups.  If sectors really move together, then ... [Read more...]

Passing user-supplied C++ functions

January 21, 2013 | Rcpp Gallery

Baptiste asked on StackOverflow about letting users supply C++ functions for use with Armadillo / RcppArmadillo. This posts helps with an extended answer. There is nothing specific about Armadillo here, this would the same way with Eigen, the GSL or any other library a user wants to support (and provides his ...
[Read more...]

Translating Weird R Errors

January 20, 2013 | Slawa Rokicki

I love R. I think it's intuitive and clever and overall a great language. But I do get really annoyed sometimes at the completely ridiculous, cryptic error messages it often gives me.  This post will go over some of those seemingly nonsensical err... [Read more...]

Looking to boxplots (Shootout 2012)

January 20, 2013 | jrcuesta

Boxplots are a nice way to compare the three sample sets of the Shoot-out 2012 data files.There is a category variable (Set) in the data frame with the labels (Cal = Training Set, Test = Test Set and Val = Validation Set). # IMPORTING THE SAMPLE SETS #... [Read more...]

Robust Estimators of Location and Scale

January 20, 2013 | Rcpp Gallery

First, the median_Rcpp function is defined to compute the median of the given input vector. It is assumed that the input vector is unsorted, so a copy of the input vector is made using clone and then std::nth_element is used to access the nth sorted element. Since ...
[Read more...]

Coercion of matrix to sparse matrix (dgCMatrix) and maintaining dimnames.

January 20, 2013 | Rcpp Gallery

Consider the following matrix
nr <span><-</span> nc <span><-</span> <span>6</span>
set.seed <span><-</span> <span>123</span>
m  <span><-</span> matrix<span>(</span>sample<span>(</span>c<span>(</span>rep<span>(</span><span>0</span><span>,</span><span>9</span><span>),</span> <span>1</span><span>),</span>nr<span>*</span>nc<span>,</span> replace<span>=</span><span>T</span><span>),</span> nrow<span>=</span>nr<span>,</span> ncol<span>=</span>nc<span>)</span>
sum<span>(</span>m<span>)</span><span>/</span>length<span>(</span>m<span>)</span>
[1] 0.1667
dimnames<span>(</span>m<span>)</span> <span><-</span> list<span>(</span>letters<span>[</span><span>1</span><span>:</span>nr<span>],</span> letters<span>[</span><span>1</span><span>:</span>nc<span>])</span>
m
a b c d e f a 0 0 0 0 0 1 b 0 0 0 1 0 1 c 0 0 0 0 0 0 d 0 0 0 0 0 0 e 1 1 0 0 0 0 f 0 0 0 1 0 0 This matrix can be coerced to a sparse matrix with
library<span>(</span><span>"Matrix"</span><span>)</span>
Loading required package: methods Loading required package: lattice
M1 <span><-</span> as<span>(</span>m<span>,</span> <span>"dgCMatrix"</span><span>)</span>
M1
6 x 6 sparse Matrix of class "dgCMatrix" a b c d e f ...
[Read more...]

Custom as and wrap converters example

January 20, 2013 | Rcpp Gallery

The RcppBDT package interfaces Boost.Date_Time with R. Both systems have their own date representations—and this provides a nice example of custom as() and wrap() converters. Here, we show a simplified example. We start with the forward declarations:
<span>#include <RcppCommon.h></span>

<span>#include <boost/date_time/gregorian/gregorian_types.hpp> 	</span><span>// Gregorian calendar types, no I/O</span>

<span>namespace</span> <span>Rcpp</span> <span>{</span>

    <span>// 'date' class boost::gregorian::date</span>
    <span>//</span>
    <span>// non-intrusive extension via template specialisation</span>
    <span>template</span> <span><></span> <span>boost</span><span>::</span><span>gregorian</span><span>::</span><span>date</span> <span>as</span><span>(</span><span>SEXP</span> <span>dt</span><span>);</span>
    <span>//</span>
    <span>// non-intrusive extension via template specialisation</span>
    <span>template</span> <span><></span> <span>SEXP</span> <span>wrap</span><span>(</span><span>const</span> <span>boost</span><span>::</span><span>gregorian</span><span>::</span><span>date</span> <span>&</span><span>d</span><span>);</span>
<span>}</span>
Given these forward declarations, we can now define the ...
[Read more...]

Weekend Reading – S&P 500 Visual History

January 19, 2013 | systematicinvestor

Michael Johnston at the ETF Database shared a very interesting post with me over the holidays. The S&P 500 Visual History – is an interactive post that shows the top 10 components in the S&P 500 each year, going back to 1980. On a different note, Judson Bishop contributed a plota.recession() function ... [Read more...]

A slightly different introduction to R, part I

January 19, 2013 | mrtnj

Note in Swedish: Jag hoppas läsaren ursäktar att jag skriver på engelska då och då. This will be a brief introduction to using the statistics software R for biologists who want to do some of their data analysis in R. There are plenty of introductions to R (see ... [Read more...]

Sums of Random Variables

January 19, 2013 | Dave Giles

I'm currently teaching first-level course in statistical inference for  (mostly) economics students. They've taken a one-semester course in descriptive (economic) statistics, and now we're dealing with sampling distributions, estimation, hypothesis testing, and simple regression analysis.When dealing with the sampling distribution of the sample mean, based on simple random sampling, ... [Read more...]

R package for Bayes factors

January 19, 2013 | andrew

Richard Morey writes: You and your blog readers may be interested to know that a we’ve released a major new version of the BayesFactor package to CRAN. The package computes Bayes factors for linear mixed models and regression models. Of course, I’m aware you don’t like point-null ... [Read more...]

Using Rcpp to access the C API of xts

January 19, 2013 | Rcpp Gallery

The xts package by Jeff Ryan and Josh Ulrich is an immensely powerful tool that is widely used for timeseries work with R. Recently, the question about how to use it from Rcpp came up on StackOverflow and in a thread on the rcpp-devel list. In fact, xts has had ...
[Read more...]

Using R to create visual illusions

January 18, 2013 | Dan Mirman

This brings together two of my favorite (professional) things: R and visual illusions. Aside from being an extremely impressive application of R, it's a cool way of making it clear that the illusion is, in fact, an illusion. Here's a simple example:lib... [Read more...]

Oracle R Distribution Performance Benchmark

January 18, 2013 | mhornick

Oracle R Distribution Performance Benchmarks Oracle R Distribution provides dramatic performance gains with MKL Using the recognized R benchmark R-benchmark-25.R test script, we compared the performance of Oracle R Distribution with and with...
[Read more...]
1 5 6 7 8 9 17

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)