Time Series Forecasting in Python and R

A friend recently made a prediction about the price of oil for the next three months. I thought I would perform some time series forecasting on the West Texas Intermediate prices and see if his numbers were reasonable from a dumb-numbers canned-forecasting perspective. I’m not making the claim that one can reasonably and accurately forecast oil prices with traditional time series techniques. (That’s bogus.) I’m simply doing this to learn more about forecasting.

Monthly petroleum prices can be found at the Energy Information Administration. Ever relevant, Wikipedia has a great write-up on recent trends in oil prices. Also, there is this Times article on the spike and drop in 2008 which had this apt summary,

[Oil prices are] the product of an extremely volatile mixture of speculation, oil production, weather, government policies, the global economy, the number of miles the average American is driving in any given week and so on. But the daily price is actually set — or discovered, in economic parlance — on the futures exchange.

Continue reading Time Series Forecasting in Python and R

Compound Poisson Processes

In this post I’ll discuss compound Poisson processes, which I read about in the final chapter of Hassett and Stewart’s Probability for Risk Management last night. These model a stochastic process where at regular intervals (months, quarters, etc.) some number of events occur according to a Poisson process with rate \lambda, and the intensity of each event is determined independently by another other distribution.

Continue reading Compound Poisson Processes

Working with hdiutil

This is more of a personal note regarding the hdiutil tool.

  • To create a sparse image:
$ hdiutil create NAME -volname NAME -type SPARSE -fs hfs+j
  • To mount the drive:
$ hdiutil attach NAME.sparseimage
  • To add data to the drive:
$ mv data.txt /Volumes/NAME
  • To unmount the drive:
$ hdiutil detach /Volumes/NAME

Then, if we delete the NAME.sparseimage file, it’s gone forever and ever.

Local Variables and Return Values in BASH

In this post, I’ll discuss some lessons learned from BASH programming, in particular, how to pass return values from BASH’s “functions”. BASH does not provide support scoped variables by default, so variables declared in a function are available everywhere once the function has been called. BASH will let you declare local variables within a function through the local keyword. Returning values is then a matter of echoing them out.

Continue reading Local Variables and Return Values in BASH

Randomization Test for a Difference in Mean

In this post, I’ll describe a technique for determining whether the mean of two sets are significantly different. In a previous post I demonstrated how to perform the standard statistical tests using R. Randomization tests are convenient when you can’t say anything about the normality or homoscedasticity (constant variance) of the population, and/or you don’t have access to a truly random sample.

Continue reading Randomization Test for a Difference in Mean