Skip to content

Instantly share code, notes, and snippets.

View InzamamRahaman's full-sized avatar

Inzamam Rahaman InzamamRahaman

View GitHub Profile
logged.data <- log(data)
len <- length(logged.data)
logged.data.timeseries <- logged.data[1 : 36]
actual <- logged.data[37 : len]
z12 <- logged.data[(37 - 12): (len - 12)]
z6 <- logged.data[(37-6):(len-6)]
# Now we attempt to fit a time series model
arima.model <- auto.arima(logged.data.timeseries, max.order = 21,
approximation = FALSE,
mape <- function(actual, predicted) {
100 * mean(abs(actual - predicted) / actual)
}
mse <- function(actual, predicted) {
mean((actual - predicted) ^ 2)
}
mae <- function(actual, predicted) {
mean(abs(actual - predicted))
# Plot what we expect
ts.plot(exp(frame.test$Actual))
# Now we develop corrector models
# Firstly, let us use linear regression
# Determines if the vector does not having missing data over the range specified
contains_values <- function(start, end, coll) {
temp <- coll[start:end]
return(length(temp[!is.na(temp)]) == (end - start + 1))
}
# Determines if the data entry at this index is viable for consideration
is_good_index <- function(k, idx, coll) {
return(contains_values(idx - k, idx, coll))
}
prices <- data$Price
idx <- find_good_indicies(3, prices)
three <- prices[sapply(idx, function(x) {x - 3})]
two <- prices[sapply(idx, function(x) {x - 2})]
one <- prices[sapply(idx, function(x) {x - 1})]
actual <- prices[sapply(idx, function(x) {x - 0})]
develop_frame <- data.frame(list('Z3'=three, 'Z2'=two, 'Z1'=one,
'Zt'=actual))
mape <- function(actual, predicted, f) {
100 * mean(abs(f(actual) - f(predicted)) / f(actual))
}
mse <- function(actual, predicted, f) {
mean((f(actual) - f(predicted)) ^ 2)
}
mae <- function(actual, predicted, f) {
mean(abs(f(actual) - f(predicted)))
exec DCIT_CREATE_USER('c806002693','c806002693','c806002693','COMP2700');
exec DCIT_CREATE_USER('c806003295','c806003295','c806003295','COMP2700');
exec DCIT_CREATE_USER('c809001458','c809001458','c809001458','COMP2700');
exec DCIT_CREATE_USER('c809003008','c809003008','c809003008','COMP2700');
exec DCIT_CREATE_USER('c811001109','c811001109','c811001109','COMP2700');
exec DCIT_CREATE_USER('c811001213','c811001213','c811001213','COMP2700');
exec DCIT_CREATE_USER('c811001346','c811001346','c811001346','COMP2700');
exec DCIT_CREATE_USER('c811002293','c811002293','c811002293','COMP2700');
exec DCIT_CREATE_USER('c811003457','c811003457','c811003457','COMP2700');
exec DCIT_CREATE_USER('c811003469','c811003469','c811003469','COMP2700');
exec DCIT_CREATE_USER('c4710376','c4710376','c4710376','COMP2700');
exec DCIT_CREATE_USER('c809000437','c809000437','c809000437','COMP2700');
exec DCIT_CREATE_USER('c810001621','c810001621','c810001621','COMP2700');
exec DCIT_CREATE_USER('c810003303','c810003303','c810003303','COMP2700');
exec DCIT_CREATE_USER('c812003067','c812003067','c812003067','COMP2700');
exec DCIT_CREATE_USER('c813004117','c813004117','c813004117','COMP2700');
exec DCIT_CREATE_USER('c813006410','c813006410','c813006410','COMP2700');
exec DCIT_CREATE_USER('c813117851','c813117851','c813117851','COMP2700');
exec DCIT_CREATE_USER('c814000593','c814000593','c814000593','COMP2700');
exec DCIT_CREATE_USER('c814000831','c814000831','c814000831','COMP2700');
5 5
80 57 3 19 60
56 97 47 23 17
62 45 62 2 11
71 78 1 80 5
77 7 92 61 25
5 6
22 74 40 9 76 72
46 50 10 17 54 49
32 11 31 45 21 83
90 52 73 33 57 1
73 74 27 86 47 19