Monthly Archives: July, 2013

Enjoy R

Estimate an equation of lagged variables When you deal with a multiple time series, you often have to estimate equations for modeling the relationships between variables. And what you always come to do is to lag them, with the hope to find the best description of one time series, given the others. What I wrote …

Continue reading

Enjoy R

Working with strings R has not implemented a direct way to extract characters from a string by specifying their positions. It’s because R doesn’t effectively consider a string as a vector so you cannot use the operator [ ] to manage the characters it is composed of. Some functions (like the ones implemented in the …

Continue reading

Enjoy R

Two functions for normal distributions Function inorm X ~ N (mean = 15, sd = 5) You want to know the interval in which a certain percentage (suppose the 80 %) of X values varies. The following function solves this kind of problem. inorm <- function(p, mean = 0, sd = 1) { if (p …

Continue reading