13. hét [Gazdasági matematika]
Felhasznált adatbázisok:
- Prostitutes in Paris (forrás: http://cran.r-project.org/web/packages/HistData/index.html)
- New York temperature (forrás: http://www.esrl.noaa.gov/)
Adatok beolvasása:
# Parent-Duchatelet's time-series data on the number of prostitutes in Paris read.csv('http://ppke.snowl.net/files/2012/12/Paris.csv') # Daily maximum temperature in NY (1960-1965) read.csv('http://ppke.snowl.net/files/2012/12/NY.csv')
Elemzés:
df <- read.csv('/files/2012/12/Paris.csv') df$ho <- 1:12 df$ev <- rep(1812:1854, each = 12) fit <- lm(df$x ~ poly(df$ho, 2) + df$ev) fit plot(df$x, type = "l") lines(predict(fit), col="red") fit <- lm(df$x ~ poly(df$ev, 6)) plot(df$x, type = "l") lines(predict(fit), col="red") fit <- lm(df$x ~ poly(df$ev, 15)) plot(df$x, type = "l") lines(predict(fit), col="red") t <- ts(df$x, start = c(1812, 1), freq = 12) decompose(t) plot(decompose(t)) ########################################### df <- read.csv('/files/2012/12/NY.csv') fit <- lm(df$temp ~ df$month) plot(df$temp, type = "l") lines(predict(fit), col="red") fit <- lm(df$temp ~ poly(df$month, 2)) plot(df$temp, type = "l") lines(predict(fit), col="red") t <- ts(df$temp, start = c(1960, 1), freq = 365) decompose(t) plot(decompose(t))
Az oldalt utoljára szerkesztette Daróczi Gergely 2012. december hó 6. napján 1:21-kor