This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xlsx) | |
library(forecast) | |
library(tseries) | |
library(strucchange) | |
## load the data from a CSV or Excel file. This example is done with an Excel sheet. | |
prod_df <- read.xlsx(file = 'agricultural_productivity.xls', sheetIndex = 'Sheet1', rowIndex = 8:65, colIndex = 2, header = FALSE) | |
colnames(prod_df) <- c('Rice') | |
## store rice data as time series objects | |
rice <- ts(prod_df$Rice, start=c(1951, 1), end=c(2008, 1), frequency=1) | |
# store the breakpoints | |
bp.rice <- breakpoints(rice ~ 1) | |
summary(bp.rice) | |
## the BIC chooses 5 breakpoints; plot the graph with breakdates and their confidence intervals | |
plot(bp.rice) | |
plot(rice) | |
lines(bp.rice) | |
## confidence intervals | |
ci.rice <- confint(bp.rice) | |
ci.rice | |
lines(ci.rice) | |
Thanks for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi..Please can you share your rice data