## March 4, 2014

### Salmon index in Norway

At the last Tokyo R meetup, I heard that the value of landings of salmon in Norway was correlated to the volume in the previous year.

Today, I try to check the relationship between the price and the catch of salmon.

At Norway StatBank, I found salmon statistics.

Here is the plot with data from site above.

## So What?

Apparently, the salmon catch and the price have periodicity. When the salmon catch goes up in a certain year, salmon price rises in the next year. At the same time, the salmon catch falls.

Why do both index move in such a way? At the meeting, I heard that there was a simple answer. It is called Fishermen's psychology. Every year, they decide the amount of the catch regarding the price of the previous year. When the price is high, the higher amount they set. As a result, both index, of the salmon price and the catch, have periodicity.

## Code

``````library(rCharts)
periods <- unique(unlist(salmon_data[1,]))
periods <- periods[nchar(periods)>1]
salmon_header <- c("group", paste(sep="-", rep(periods, each=2), c("catch", "price")))
salmon_data.m <- reshape2::melt(salmon_data, id.var="group")
salmon_data.m <- cbind(salmon_data.m[,-2], do.call("rbind", strsplit(split="-", as.character(salmon_data.m\$variable))))
colnames(salmon_data.m) <- c("group", "amount", "period", "contents")
salmon_data.m\$amount <- as.numeric(salmon_data.m\$amount)
salmon_data.m <- subset(salmon_data.m, (group=="Fish-farm bred salmon, frozen") & !(grepl("^2014", salmon_data.m\$period)))
calconv <- function(x){
txt <- as.character(x)
res <- as.Date(paste0(substr(txt,1,4), "-01-01"))+
(as.numeric(paste0(substr(txt,6,7)))-1)*7
}
salmon_data.m\$period2 <- calconv(salmon_data.m\$period)
n1 <- nPlot(data=salmon_data.m,
amount~period2, group="contents", type="multiChart", width=600)
n1\$params\$multi = list(
catch = list(type="line",yAxis=1),
price = list(type="line",yAxis=2)
)
n1\$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Date( d * 86400000 ));}!#" )
n1\$setTemplate(script = system.file(
"/libraries/nvd3/layouts/multiChart.html",
package = "rCharts"
))
n1\$show("iframesrc", cdn=TRUE)

``````