Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

> library(class) A > train.x-cbind(Lag1,Lag2) [train,] > test.x-cbind(Lag1,Lag2) [!train,] > train. > Direction-Direction[train] > set.seed(1) > knn. pred knn(train. x, test.x, train. Direction, k=1)

image text in transcribed

> library(class) A > train.x-cbind(Lag1,Lag2) [train,] > test.x-cbind(Lag1,Lag2) [!train,] > train. > Direction-Direction[train] > set.seed(1) > knn. pred knn(train. x, test.x, train. Direction, k=1) > table (knn. pred, Direction. 2005) Direction. 2005 knn. pred Down up Down 72 73 Up 69 99 >(72-99)/(72-73+69+99) [1] 0.5463259 >knn. pred-knn(train.x,test.x, train. Direction, k=3) > table (knn. pred, Direction. 2005) Direction. 2005 knn. pred Down up Down 79 70 up 62 102 > mean (knn. pred--Direction. 2005) [1] 0.5782748

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Cost Accounting A Managerial Emphasis

Authors: Charles T. Horngren, Srikant M.Dater, George Foster, Madhav

14th Edition

978-0132960649, 132960648, 132109174, 978-0132109178

Students also viewed these Mathematics questions