Author Archive: dav1d00

How impossible is an event with zero probability?

When we look at reality, we always perceive it as extremely complex and hard to model. Modelling reality in a perfect way would essentially mean being able to explain and predict phenomena with no more need of probability. In general, probability is what leads our lives to a choice instead of another, preferring A over …

Continue reading

Enjoy R: Do two consecutive seeds behave independently?

I’ve always wondered whether two random seeds in R provide independent results, whatever they are. In particular, I wanted to check if repeating a sampling operation with two consecutive seeds, say set.seed(20) and set.seed(21), this would produce unrelated outputs as expected. Pseudo-randomness in R is based on algorithms I honestly have read nothing about, and …

Continue reading

Enjoy R: install packages “on the fly”

It is annoying when you load a package and you find out you don’t have it installed. So you need to install it first, and finally load it. As I am used to installing LaTeX packages on the fly, I thought of a simple script to do the same in R. The following is a …

Continue reading

Enjoy R: Looping in R

Loops are run in most applications and are supported by all languages. In general, there are more than one way to execute the same task via looping, and the efficiency of each choice varies among languages. This post is not intended to demonstrate any general truth about R loops, but aims to provide some insights into some …

Continue reading

Enjoy R: how to automatically give readable names to variables in a loop

For making the same operations on each element of a collection — e.g. vector, matrix, list —, we generally use loops. Sometimes, we want to save the results of each iteration in variables which are related only to the current iteration. To do that properly, we should give each variable a name that simoultaneously refers …

Continue reading

An arduous journey into statistical significance

All we know about the world teaches us that the effects of A and B are always different—in some decimal place—for any A and B. Thus asking “are the effects different?” is foolish. This is a quote by John Tuckey, and I’d like to start with that to enter the core of this post. What …

Continue reading

Enjoy R: is my x included in these bounds?

How many times have you written code like the following? if(x > lower_bound & x < upper_bound) return(T)  return(F) Throughout my coding experience so far, I’ve faced that a lot. And everytime this happened, I started thinking that I was not really writing it in the same way as I would have written it using basic …

Continue reading

Enjoy R: A useful function for clearing the workspace

Today I was coding with my supervisor, and we actually had a bunch of things saved in our workspace which we wanted to get rid of. The annoying matter was that we aimed to delete almost all the workspace and keep only a couple of functions. R has a fast way to clear all the workspace, which is rm(list …

Continue reading

Enjoy R: Compare ROC curves of different multinomial classification models

When we think of a ROC curve, we usually refer it to a binary classification problem. For a multiclass case, it comes to be less used, also because it loses most of its explicative power. However, it would be good to use it also in this scenario in order to own one more weapon for diagnostics. …

Continue reading

Enjoy R: Stratified sampling and its application using dplyr

Enjoy R: Stratified sampling and its application using dplyr.

Continue reading