You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bike<- read.csv("C:/Users/Student/Documents/UVA 2016-2017/RWorkshop/Week 1- Arithmatic and Data Type Intro/bike.csv")
2
+
3
+
###################
4
+
#
5
+
# Time Series
6
+
#
7
+
###################
8
+
9
+
bike.ts<- ts(bike$cnt)
10
+
11
+
# In time series look for 3 things:
12
+
# 1. Trend - overall long acting upward or downward movement
13
+
# 2. Seasonality - repeating patterns within a year
14
+
# 3. Cycles - patterns that repeat in over a year period
15
+
plot(bike.ts)
16
+
17
+
# 1. Modeling for trend
18
+
19
+
# Create a new variable time.bike which is a matrix of (length(bike.ts))
20
+
time.bike<-c(1:(length(bike.ts)-7))
21
+
22
+
# Build a new model, bike.trend which predicts bike.ts based on the time variable, time.bike- use all data except the last week of your bike time series
23
+
bike.trend<-lm(bike.ts[time.bike]~time.bike)
24
+
25
+
# Use the summary() command on bike.trend
26
+
summary(bike.trend)
27
+
28
+
# Is time significant in predicting spam frequency? Yes; p-value <= 0.001
0 commit comments