5
$\begingroup$

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.

$\endgroup$
1
  • 3
    $\begingroup$ You could probably do this as a dynamic linear model, but you might need to spell out what model you want to fit. In what sense was the GAM fit not sufficient? $\endgroup$ Jan 16 '14 at 20:16
1
$\begingroup$
  1. Suggestion: Construct an interaction between your time variable and your regressor of interest. Essentially you will then estimate one coefficient for each time period. I chose decades, but looking at your data I think you had something else in mind:

    fishdata <- read.csv("http://dl.dropbox.com/s/4w0utkqdhqribl4/fishdata.csv", header=T)
    fishdata$decade <- cut(fishdata$year, breaks = seq(1949, 2009, by = 10))
    summary(lm(totalfao ~ marinefao:decade, data = fishdata))
    
  2. Suggestion: Estimate a random coefficient model. The advantage from a statistical point of view is, that you have to estimate fewer parameters which will make a real difference in smaller samples. Also the interpretation will differ, however you will find a lot of literature on this topic (mixed models) - so I don't want to comment on that (see point 3):

    library(lme4)
    summary(lmer(totalfao ~ marinefao + (1 + marinefao|decade), fishdata))
    
  3. Looking at your problem you are doing time series analysis. Applying simple regression techniques you will assume stationarity. However, your variables are not looking stationary (constant mean and variance over time) but have a clear trend:

    plot(fishdata$year, fishdata$inlandfao)
    

    You can either estimate the trend or take differenced data (or other approaches). Looking at the first differences of your dependent variable I think it is not necessary to estimate time varying coefficients:

    plot(fishdata$year[-1], diff(fishdata$inlandfao))
    
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.