rain <- read.table('time_series_rain_ubatuba.txt', header=T)
rain
rain$Ano
plot(ts(rain$ago))
plot(ts(rain$ago, start=1935))
ago_ts <- ts(rain$ago, start=1935)
model <- decompose(ago_ts)
?ts
ago_ts <- ts(rain$ago, start=1935, frequency=1)
model <- decompose(ago_ts)
plot(ago_ts)
?filter
?decompose
ago_ts.1 <- filter(ago_ts, filter=rep(1/5,5))
plot(ago_ts.1)
ago_ts.2 <- filter(ago_ts, filter=rep(1/25,25))
plot(ago_ts.2)
?par
?par
?par
 op <- par(mfrow = c(2, 2), pty="s")
par(op)
plot(ago_ts.1)
plot(ago_ts.2)
?par
 op <- par(mfrow = c(2, 2), pty="s")
plot(ago_ts.1)
plot(ago_ts.2)
plot(log(ago_ts.2))
lago <- log(ago_ts)
fit <- lm( lago ~ t )
fit <- lm( lago ~ t + 1 )
?lm
lago
lago <- log(rain$ago)
fit <- lm( lago ~ t + 1 )
lago
?lm
rain
rain$Ano
t <- seq(1935, 2001)
t
fit <- lm( lago ~ t + 1 )
plot(fit)
plot(fit$fit)
plot(lines(fit$fit)
)
plot(ago_ts)
plot(ago_ts)
plot(ago_ts)
plot(ago_ts)
fit
lago <- rain$ago
fit <- lm( lago ~ t + 1 )
plot(fit$fit)
fit <- lm( lago ~ t^2 + t + 1 )
plot(fit$fit)
fit <- lm( lago ~ t^2 + t)
plot(fit$fit)
plot(ago_ts)
lines(lm(lago~t+t2)$fit,col=2,lwd=2)
lines(lm(lago~t+t^2)$fit,col=2,lwd=2)
plot(lm(lago~t+t^2)$fit,col=2,lwd=2)
t
lago <- rain$ago
t2 <- t^2
fit <- lm(lago~t+t2)$fit,col=2,lwd=2
fit <- lm(lago~t+t2)
plot(fit$fit)
t
t2
lago
fit
?lm
fit$fit
?lm
fit <- lm(lago~t+t2, na.action = NULL)
lago <- rain$ago
lago <- lago[1:(length(lago)-1)]
lago
t <- seq(1935, 2000)
fit <- lm(lago ~ t + t^2)
plot(fit$fit)
fit <- lm(lago ~ t + t^2, na.action = NULL)
plot(fit$fit)
?lm
names(fit)
fit$fit
plot(x=seq(1935,2000), y=fit$fit)
 op <- par(mfrow = c(2, 2), pty="s")
plot(x=seq(1935,2000), y=fit$fit)
plot(ago_ts)
plot(ago_ts.2)
?lines
?lines
lines(x=seq(1935,2000), y=fit$fit, col="red")
fit
t2 <- t^2
fit <- lm(lago ~ t + t2, na.action = NULL)
lines(x=seq(1935,2000), y=fit$fit, col="blue")
fit
ls()
op
ls()
rain
head(rain)
plot(rain$Anual)
plot(ts(rain$Anual, start=1935))
ls()
??SQLite
help(package='RSQLite')
?query
library(RSQLite)
?query
?SQLite
?dbConnect
dbConnect(SQLite(), '~/tools/sqlite3-dbix/examples/ubajobs/db/ubajobs_test.db')
conn = dbConnect(SQLite(), '~/tools/sqlite3-dbix/examples/ubajobs/db/ubajobs_test.db')
conn <- dbConnect(SQLite(), '~/tools/sqlite3-dbix/examples/ubajobs/db/ubajobs_test.db')
?
?dbConnect
dbListTables(con)
ls()
dbListTables(conn)
query(conn, 'SELECT * from word')
?query
df <- dbGetQuery(con, "SELECT * FROM word")
df <- dbGetQuery(conn, "SELECT * FROM word")
df
df <- dbGetQuery(conn, "SELECT * FROM resume")
df
df <- dbGetQuery(conn, "SELECT * FROM employee")
df
df$birthday
d <- as.Date(df$birthday)
d
d[which("9878-09-04"])
d[which("9878-09-04")]
?which
which(d == "9878-09-04")
d[which(d == "9878-09-04")] <- NA
d
plot(d)
hist(d)
?hist
hist(d, breaks=8)
df
df <- dbGetQuery(conn, "SELECT * from experience_skill")
df
df$left_on - df$begin_on
as.Date(df$left_on) - as.Date(df$begin_on)
diffs <- as.Date(df$left_on) - as.Date(df$begin_on)
summary(diffs)
summary(diffs)
as.numeric(diffs)
ls()
rain
ls()
ls()
dbGetQuery(conn, "SELECT * from experience_skill")
library(RSQLite)
dbGetQuery(conn, "SELECT * from experience_skill")
rain
?RSQLite
help(package='RSQLite')
?dbWriteTable
conn <- dbConnect(SQLite(), '~/tools/statistic/time_series/sqlite.db')
df
ls()
dbWriteTable(conn, rain)
?dbWriteTable
dbWriteTable(conn, 'rain', rain)
?dbWriteTable
dbDisconnect(conn)
boxplot(rain[,2:13])
help.start()
?output
help("Rscript")
?jpeg
rain
decompose(rain$ago)
decompose(ts(rain$ago, start=1935))
decompose(ts(rain$ago, start=1935, frequency=10))
decompose(ts(rain$ago, start=1935, frequency=1))
?ts
decompose(ts(rain$ago, start=1935, frequency=1))
?decompose
ls9)
ls()
model <- lm(ts(rain$ago, start=1935) ~ t + t2)
ago_ts <- ts(rain$ago, start=1935)
model <- lm(ago_ts ~ t + t2)
ago_ts
t
model <- lm(ago_ts ~ t + t2, na.action=NULL)
ago_ts <- ts(rain$ago, start=1935, end=2000)
ago_ts
model <- lm(ago_ts ~ t + t2)
model
plot(model)
 op <- par(mfrow = c(2, 2), pty="s")
plot(model)
ago_ts
hist(ago_ts)
boxplot(ago_ts)
plot(ago_ts)
?qq
?quantile
quantile(ago_ts)
plot(quantile(ago_ts))
model <- lm(ago_ts ~ t + 1)
plot(model)
plot(ago_ts)
lines(x=seq(1935,2000), y=model$fitted.values)
lines(x=seq(1935,2000), y=model$fitted.values, col="red")
jul_ts <- ts(rain$jul, start=1935, end=2000)
plot(jul_ts)
model_jul <- lm(jul_ts ~ t + 1)
lines(x=seq(1935,2000), y=model_jul$fitted.values, col="red")
model_jul$fitted.values
length(model_jul$fitted.values)
length(seq(1935,2000))
length(jul_ts)
jul_ts
lines(x=seq(1935,1999), y=model_jul$fitted.values, col="red")
boxplot(ago_ts)
boxplot(jul_ts)
?decompose
?stl
library(graphics)
??scatter
ls()
length(model_jul)
length(jul_ts)
length(ago_ts)
plot(ago_ts, jul_ts)
plot(ago_ts[1:3], jul_ts[1:3])
plot(ago_ts[1:66], jul_ts[1:66])
?deltat
deltat(ago_ts)
increments <- ago_ts[2:66] - ago_t[1:65]
increments <- ago_ts[2:66] - ago_ts[1:65]
plot(increments)
increments_jul <- jul_ts[2:66] - jul_ts[1:65]
plot(increments_jul)
hist(increments)
hist(increments_jul)
?density
d_jul <- density(increments_jul)
d_jul <- density(increments_jul, na.rm=T)
?density
?density
lines(density, col="red")
lines(d_jul, col="red")
d_jul <- density(increments_jul, na.rm=T)
d_jul
hist(increments_jul, freq=T)
hist(increments_jul, density=T)
?hist
hist(increments_jul, freq=F)
lines(d_jul, col="red")
hist(increments, freq=F)
lines(density(increments), col="red")
ls()
lines(density(increments), col="red")
hist(increments, freq=F)
lines(density(increments), col="red")
ls()
plot(ago_ts)n
lines(x=seq(1935,2000), y=model$fitted.values, col="red")
summary(ago_ts)
sd(ago_ts)
model
?lm
f <- function(h) { -1.174*h + 2413.957 }
f(2015)
f(2015) + 73.77
ls()
d
rm(d)
ls()
f
f(2016)
f(2015
)
sd
var
 op <- par(mfrow = c(2, 4), pty="s")
rain[2:9]
?for
?'for'
names(rain)
 op <- par(mfrow = c(2, 6), pty="s")
for( i in 2:13){ plot(ts(rain[,i], start=1935)) }
names(rain)[2]
?plot
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=names(rain)[i]) }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=c("Rain ", names(rain)[i]), " (mm)") }
?join
??join
?plot
"a" + "b"
"a" . "b"
??concat
paste("a","b")
??concat
paste(c("a", "b"))
cat(c("a", "b"))
paste(c("a", "b"))
paste(c("this is ", "something"))
paste("this is ", "something")
?paste
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste("Rain", names(rain)[i]), "(mm)") }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste names(rain)[i] }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste("Rain", names(rain)[i]), "(mm)")) }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste("Rain", names(rain)[i], "(mm)")) }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste("Rain in", names(rain)[i], "(mm)")) }
for( i in 2:13){ plot(ts(rain[,i], start=1935), ylab=paste(names(rain)[i], "(mm)")) }
for( i in 2:13){ ts_ <- ts(rain[,i], start=1935, end=length(rain[,i])); model <- lm(ts_ ~ t + 1) ; plot(ts(rain[,i], start=1935), ylab=paste(names(rain)[i], "(mm)")); lines(x=seq(1935, length(rain[,i]), model$fitted.values, col="red") }
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935, end=length(rain[,i])); model <- lm(ts_ ~ t + 1) ; plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(x=seq(1935, length(rain[,i]), model$fitted.values, col="red") }
?lm
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935) ; model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(x=seq(1935, length(rain[,i]), model$fitted.values, col="red") }
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")) }
t
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(1935, length(ts)); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")) }
t
?seq
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_)); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")) }
t
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")) }
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t, model$fitted.values, col="red") }
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t[1:length(model$fitted.values)], model$fitted.values, col="red") }
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t[1:length(model$fitted.values)], model$fitted.values, col="red") }
 op <- par(mfrow = c(2, 6), pty="s")
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t[1:length(model$fitted.values)], model$fitted.values, col="red") }
plot(ts(rain$Anual, start=1935))
t
ts_ <- lm(rain$Anual ~ t + 1)
lines(x=seq(1935,2001), y=model$fitted.values, col="red")
lines(x=seq(1935,2000), y=model$fitted.values, col="red")
lines(x=seq(1935,2000), y=ts_$fitted.values, col="red")
lines(x=seq(1935,2001), y=ts_$fitted.values, col="red")
ls()
ls()
ifelse(0, "ok", "nok")
ifelse(1, "ok", "nok")
??PAC
 op <- par(mfrow = c(2, 6), pty="s")
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t[1:length(model$fitted.values)], model$fitted.values, col="red") }
ls()
1.6/6
(1.6/6)*10^4
2666/8
1.6*10^5/60
2666.667/365
2666.667/24
2666.667/8
1.60*10^4*15
240000/60
4000/8
240000/60
8000/12
ls()
ls()
lago
??algebra
??eigen
for(i in 2:13) { ts_ <- ts(rain[,i], start=1935); t <- seq(from=1935, to=1935 + length(ts_) -1 ); model <- lm(ts_ ~ t + 1, na.action=na.exclude); plot(ts_, ylab=paste(names(rain)[i], "(mm)")); lines(t[1:length(model$fitted.values)], model$fitted.values, col="red") }
model
plot(model)
?rnorm
?rnorm
x <- rnorm(30, 7,3)
?quantile
?qqplot
qqplot(x)
?qqplot
qqplot(rnorm(20, 5, 2), x)
qqplot(rnorm(20, 7, 3), x)
ls()
plot(model_jul)
plot(jul_ts)
??leverage
??leverage
ls9)
ls()
lines(1935:2001, model_jul$fitted.values, col="red")
lines(1935:2000, model_jul$fitted.values, col="red")
length(model_jul$fitted.values)
length(1935:2000)
lines(1935:1999, model_jul$fitted.values, col="red")
ls()
plot(model_jul)
plot(jul_ts)
lines(1935:1999, model_jul$fitted.values, col="red")
?point
?lines
?points
?points
points(mean(1935:1999), mean(jul_ts))
?points
points(c(mean(1935:1999)), c(mean(jul_ts)))
?points
points(c(mean(1935:1999)), c(mean(jul_ts)), pch = 19)
mean(1935:2000)
mean(jul_ts)
?mena
?mean
mean(jul_ts, na.rm=T)
points(c(mean(1935:1999)), c(mean(jul_ts, na.rm=T)), pch = 19)
ls()
ls()
ls()
?outer
outer(1:10, 10:1)
# Time Series Plotting
library(ggplot2)
library(xts)
library(dygraphs)
install.packages('xts')
install.packages('dygraphs')
ibm_url <- "http://real-chart.finance.yahoo.com/table.csv?s=IBM&a=07&b=24&c=2010&d=07&e=24&f=2015&g=d&ignore=.csv"
lnkd_url <- "http://real-chart.finance.yahoo.com/table.csv?s=LNKD&a=07&b=24&c=2010&d=07&e=24&f=2015&g=d&ignore=.csv"
yahoo.read <- function(url){
   dat <- read.table(url,header=TRUE,sep=",")
   df <- dat[,c(1,5)]
   df$Date <- as.Date(as.character(df$Date))
   return(df)}
ibm <- yahoo.read(ibm_url)
ibm
plot(ibm)
plot(ts(ibm))
ibm$Date
ibm$Close
?ts
ts(ibm$Close)
head(ibm$Date)
tail(ibm$Date)
plot(ibm$Close)
plot(ts(ibm$Close))
plot(x=ibm$Date, y=ibm$Close)
plot(x=ibm$Date, y=ts(ibm$Close))
?abline
?abline
?segments
?abline
?lines
plot()
lines(x=ibm$Date, y=ts(ibm$Close))
?lines
lines(x=ibm$Date, y=ts(ibm$Close))
plot(x=ibm$Date, y=ibm$Close)
lines(x=ibm$Date, y=ts(ibm$Close))
?poly
?polypath
polypath(x=ibm$Date, y=ibm$Close)
polypath(x=ibm$Date, y=ibm$Close)
plot.new
plot.new()
lines(x=ibm$Date, y=ts(ibm$Close))
?plot.new
ibm_url
ls()
ls()
ls()
ts_
ls()
t
ls()
ls()
ls()
ls()
ls()
x
plot(x)
ago_ts.1
ago_ts.2
plot(ago_ts.1)
plot(ago_ts.2)
ls()
source('stats.R')
