Classification 1
lag1, lag2,…,lag5: percentage return for each of the five previous trading days
volume: number of shares traded on previous day
today: percentage return on data in question
direction: whether the market was Up or Down on this data
cor(): produces matrix containing all of correlations among the predictors
Here error because “direction” variable is qualitative
Correlations between the lags and today’s returns close to zero => little correlation
Year and volume: substantial correlation
glm(): fits linear models that includes logistic regression (similar to lm() except: family = binomial)
Lag1
smallest p-value
negative coefficient: if
market had positive return
yesterday, then less likely to
go up today
0.15: no clear evidence of
association between Lag1
and direction
, coef(): access coefficients
summary(): access specific aspects of fitted model
predict(): can be used for the probability that the market will go up, given values of predictors
type = “response”: tells R to output probabilities of the form P(Y=1|X)
contrasts(): indicates that R has created a dummy variable
Vector of class predictions based on whether predicted probability of a market increase is greater
than or less than 0.5:
First command: creates vector of 1,250 Down elements
Second command: transforms to Up all of elements for which predicted probability of
market increase exceeds 0.5
table(): produces a confusion matrix
Diagonal elements: correct predictions
Off-diagonal elements: incorrect
Training error rate: 100 – 52.2 = 47.8%
lag1, lag2,…,lag5: percentage return for each of the five previous trading days
volume: number of shares traded on previous day
today: percentage return on data in question
direction: whether the market was Up or Down on this data
cor(): produces matrix containing all of correlations among the predictors
Here error because “direction” variable is qualitative
Correlations between the lags and today’s returns close to zero => little correlation
Year and volume: substantial correlation
glm(): fits linear models that includes logistic regression (similar to lm() except: family = binomial)
Lag1
smallest p-value
negative coefficient: if
market had positive return
yesterday, then less likely to
go up today
0.15: no clear evidence of
association between Lag1
and direction
, coef(): access coefficients
summary(): access specific aspects of fitted model
predict(): can be used for the probability that the market will go up, given values of predictors
type = “response”: tells R to output probabilities of the form P(Y=1|X)
contrasts(): indicates that R has created a dummy variable
Vector of class predictions based on whether predicted probability of a market increase is greater
than or less than 0.5:
First command: creates vector of 1,250 Down elements
Second command: transforms to Up all of elements for which predicted probability of
market increase exceeds 0.5
table(): produces a confusion matrix
Diagonal elements: correct predictions
Off-diagonal elements: incorrect
Training error rate: 100 – 52.2 = 47.8%