Quantcast
Channel: R snippets
Browsing all 25 articles
Browse latest View live

Missing tikzDevice

I love using tikzDevice. When preparing LaTeX documents I switched to prepare all graphs in GNU R and then port them to TeX using tikzDevice. Recently I have moved to GNU R 3.0.0 and was shocked to...

View Article



Model fitting exam problem

Recently I have run an exam where the following question had risen many problems for students (here I give its shortened formulation). You are given the data generating process y = 10x + e, where e is...

View Article

Image may be NSFW.
Clik here to view.

Regression regularization example

Recently I needed a simple example showing when application of regularization in regression is worthwhile. Here is the code I came up with (along with basic application of parallelization of code...

View Article

Testing function arguments in GNU R

Recently I have read a nice post on ensuring that proper arguments are passed to a function using GNU R class system. However, I often need a more lightweight solution to repetitive function argument...

View Article

Image may be NSFW.
Clik here to view.

Genetic drift simulation

While preparing for the new teaching semester I have created an implementation of NetLogo GenDrift P local in GNU R.The model works as follows. Initially a square grid having side size is randomly...

View Article


Image may be NSFW.
Clik here to view.

Visualizing optimization process

One of the approaches to graph drawing is application of so called force-directed algorithms. In its simplest form the idea is to layout the nodes on plane so that all edges in the graph have...

View Article

Image may be NSFW.
Clik here to view.

Cont model back after a year

During ESSA2013 conference I had a discussion about Cont model I have commented a year ago. In original paper Cont highlights that his model produces distribution of returns characterized by positive...

View Article

Image may be NSFW.
Clik here to view.

Cont model - Part II

In my last post I have investigated properties of Cont model (you can download the paper here). Today I would like to show how we can use simulations to further simplify its analysis.First let us start...

View Article


Image may be NSFW.
Clik here to view.

Calibration of p-value under variable selection: an example

Very often people report p-values for linear regression estimates after performing variable selection step. Here is a simple simulation that shows that such a procedure might lead to wrong calibration...

View Article


Image may be NSFW.
Clik here to view.

Simulation speed: GNU R vs Julia

Recently there is a lot of noise about Julia. I have decided to test its speed in simulation tasks on my toy Cont model. I thought I had vectorized my GNU R code pretty well, but Julia is much...

View Article

Speeding up model bootstrapping in GNU R

After my last post I have recurringly received two questions: (a) is it worthwhile to analyze GNU R speed in simulations and (b) how would simulation speed compare between GNU R and Python. In this...

View Article

GNU R vs Julia: is it only a matter of devectorization?

Recently I have read a post on benefits of code devectorization in Julia. The examples given there inspired me to perform my own devectorization exercise. I decided to use bootstrapping as a test...

View Article

Tuning optim with parscale

I often get questions what is the use of parscale parameter in optim procedure in GNU R. Therefore I have decided to write a simple example showing its usage and importance. The function I test is a...

View Article


RGolf

Its time for some fun today - because its Friday as David Smith says :). There are many code golf sites, even some support R. However, most of them are algorithm oriented. A true RGolf competition...

View Article

RGolf: rolling window

I have learned a lot from my last RGolf post. Therefore today I have another problem from practice.You have a data set on values of contracts signed by ten salesmen. It has three columns: person id...

View Article


Image may be NSFW.
Clik here to view.

RGolf: NGSL Scrabble

It is last part of RGolf before summer. As R excels in visualization capabilities today the task will be to generate a plot.We will work with NGSL data - a list of 2801 important vocabulary words for...

View Article

Image may be NSFW.
Clik here to view.

R Scrabble: Part 2

Ivan Nazarov and Bartek Chroł gave very interesting comments to my last post on counting number of subwords in NGSL words. In particular they proposed large speedups of my code. So I thought to try...

View Article


Comparing localsolver with Rglpk on k-medoids example

Recently I have coauthored a new localsolver package that can be used to solve large scale optimization problems from R. It is a wrapper around commercial solver that is free for academia. If you are...

View Article

Sequence generation in R, Python and Julia

Recently I was comparing implementation of sequence generation functions in R, Python (numpy) and Julia. Interestingly even such basic functions have slight differences in implementation. In my opinion...

View Article

Telco churn prediction with R+H2O

Recently together with my friend Wit Jakuczun we have discussed about a blog post on Revolution showing application of SQL Server R services to build and run telco churn model. It is a very nice...

View Article
Browsing all 25 articles
Browse latest View live




Latest Images