I have time series data on fish catches from 1950-2011.
I wish to implement a regression model with varying coefficients. I'm aware that cox models etc. exist and implementation via the survival
package in R. My data is not survival data, it's just several variables with fish catches and year.
Is there a way in R to implement such models? I've yet to come across this but I don't think it's unreasonable to want to model such data without it being survival data.
I want to model inlandfao
from marinefao
.
Here is my data and some plots:
fishdata <- read.csv("http://dl.dropbox.com/s/4w0utkqdhqribl4/fishdata.csv", header=T)
require(reshape2)
require(ggplot2)
theme_set(theme_bw())
require(scales)
df2 <- data.frame(cbind(year,totalmarinefao, totalinlandfao))
df2
dd <- melt(df2, id.vars = "year")
dd
pp <- ggplot(dd, aes(year, value, colour=variable)) + geom_point() + geom_line(size=1)
pp_final <- pp + xlab("Year") + ylab("Catches (Tons)") + ggtitle("Time Series of Variables (1950-2011)")
pp_final
pp_final2 <- pp_final + scale_colour_discrete(name = "Variable - Catches (FAO)", breaks = c("totalmarinefao", "totalinlandfao"),
labels=c("Marine", "Inland")) +
scale_shape_discrete(name = "Variable (FAO)", breaks = c("totalmarinefao", "totalinlandfao"), labels=c("Marine", "Inland")) +
scale_x_continuous(breaks=seq(1950,2011,10)) + scale_y_continuous(labels=comma)
pp_final2
pp_3 <- pp_final2 + theme(axis.text.x = element_text(vjust=1, size=16)) + theme(axis.title.x = element_text(size=20))
pp_4 <- pp_3 + theme(axis.text.y = element_text(vjust=0, size=16)) + theme(axis.title.y = element_text(size=20, vjust=0.2))
pp_5 <- pp_4 + theme(plot.title = element_text(lineheight=.8, face="bold", size=20))
pp_5
qplot(marinefao, inlandfao, data=fishdata, main="Scatterplot of the Marine & \n Inland
fish Catches (Tons)", xlab="Marine Catches", ylab="Inland Catches") +
scale_x_continuous(labels = comma) + scale_y_continuous(labels = comma)
From these plots, a linear model isn't appropriate. I have fitted GAMs etc. to these data.
Let me more if you require details.