- WELCOME TO THE FIRST EXAMPLE OF LINEAR REGRESSION.
THE GOALS OF THIS VIDEO ARE TO PERFORM LINEAR REGRESSION
ON THE TI84 GRAPHING CALCULATOR,
DETERMINE HOW WELL THE LINE OF BEST FIT REPRESENTS THE DATA,
AND THEN ALSO MAKE PREDICTIONS USING THE REGRESSION EQUATION.
SO HERE WE'RE GIVEN A SET OF DATA THAT COMPARES THE YEAR
TO THE PER PERSON ANNUAL CONSUMPTION OF SPORTS DRINKS.
SO OUR FIRST COLUMN IS THE YEAR,
AND OUR SECOND COLUMN IS THE NUMBER OF GALLONS PER PERSON.
SO THE FIRST STEP TO ANALYZING DATA IS TO CREATE A SCATTER PLOT
OF THE DATA,
TO SEE WHAT TYPE OF FUNCTION WOULD BE A GOOD MODEL
FOR THE DATA.
HOWEVER, BEFORE WE DO THAT, WHEN OUR X VALUES ARE YEARS,
IT'S COMMON PRACTICE TO SET THE BASE YEAR AS X = 0.
SO X WILL BE THE NUMBER OF YEARS SINCE 2002.
SO WE'LL USE 0 FOR 2002, 1 FOR 2003, 2 FOR 2004,
3 FOR 2005, AND 4 FOR 2006.
SO THE FIRST POINT THAT WE'LL PLOT WILL BE 0,2.7.
THE SECOND POINT WILL BE 1,3, AND SO ON.
SO LET'S GO AHEAD AND LABEL OUR X AND Y AXES.
SO THE X AXIS WILL BE THE NUMBER OF YEARS AFTER 2002,
AND THE Y AXIS WILL REPRESENT THE NUMBER OF GALLONS
PER PERSON.
AND THE LARGEST VALUE OF X IS 4, SO LET THIS = 4,
AND WE'LL SCALE IT BY ONES.
THE LARGEST VALUE OF Y IS 4.5,
SO WE'LL SCALE THE Y AXIS FROM 0 TO 5.
NOW WE'LL GO AHEAD AND PLOT THE POINTS.
THE FIRST POINT IS (0,2.7), (1,3), (2,3.4),
(3,4.1), AND (4,4.5).
SO WE CAN SEE FROM OUR SCATTER PLOT,
THESE POINT DO APPEAR TO HAVE A LINEAR RELATIONSHIP
WHERE THE LINE WOULD HAVE A POSITIVE SLOPE.
NOW WHAT WE'RE GOING TO DO
IS GO AHEAD AND DUPLICATE THIS SCATTER PLOT
ON THE GRAPHING CALCULATOR,
AND THEN DETERMINE THE EQUATION OF THE LINE OF BEST FIT.
SO THE FIRST THING WE'RE GOING TO DO IS ENTER IN THE DATA.
SO WE'LL PRESS STAT, ENTER.
IF YOU HAVE ANY OLD DATA IN HERE,
YOU CAN GO TO THE TOP OF THE COLUMN, PRESS CLEAR,
AND THEN ENTER,
AND IT WILL CLEAR THE ENTER COLUMN.
SO HERE WE'LL HAVE 0, 1, 2, 3, 4,
AND THEN FOR L2 WE'LL HAVE THE GALLONS PER PERSON.
NOW THAT WE HAVE OUR DATA IN,
LET'S GO AHEAD AND ADJUST THE WINDOW,
SO THAT WHEN WE CREATE OUR SCATTER PLOT,
THE POINTS WILL SHOW.
SO PRESS WINDOW.
REMEMBER, OUR X AXIS WENT FROM 0 TO 4,
BUT I'M GOING TO GO AHEAD AND EXTEND THAT.
SO I'M GOING TO GO FROM -1 TO 5 ON THE X AXIS.
AND FOR THE X SCALE, THAT'S HOW OFTEN YOU WANT A TICK MARK.
LET'S ENTER ONE HERE.
AND IF THE Y AXIS WENT FROM 0 TO 5,
LET'S GO AHEAD AND GO FROM -1 TO 6.
AND AGAIN, WE'LL SCALE IT BY ONES.
SO NOW IF WE PRESS SECOND, Y =,
HERE'S WHERE WE CAN TURN THE STAT PLOT ON.
SO WE PRESS ENTER, AND THEN IT'S BLINKING ON "ON."
SO IF WE JUST PRESS ENTER,
IT'S ALREADY ON THE SCATTER PLOT OPTION, THE FIRST OPTION HERE.
L1 AND L2 ARE X AND Y,
AND THE POINTS WILL BE THE LITTLE SQUARES.
SO IF WE PRESS GRAPH NOW,
WE HAVE A NICE SCATTER PLOT THAT RESEMBLES WHAT WE DID BY HAND.
BUT NOTICE HOW I HAVE AN EQUATION HERE SHOWING UP.
THAT'S BECAUSE I HAVE AN EQUATION IN Y1.
SO IF I GO AHEAD AND PRESS Y =,
I'M GOING TO GO AHEAD AND CLEAR OUT
ANY EQUATIONS I HAVE IN HERE.
NOW, BEFORE WE PERFORM THE LINEAR REGRESSION,
IF WE WANT R AND R SQUARED TO SHOW ON THE SCREEN,
WE HAVE TO MAKE SURE THAT OUR DIAGNOSTIC FEATURE IS TURNED ON.
SO IF WE PRESS SECOND 0, THIS BRINGS UP THE CATALOG,
AND WE CAN JUST SCROLL DOWN TO D, OR PRESS D.
I'LL GO AHEAD AND JUST SCROLL DOWN.
I'M LOOKING FOR DIAGNOSTIC ON. HERE IT IS.
I'M GOING TO PRESS ENTER, AND THEN ENTER,
AND NOW R AND R SQUARED WILL SHOW UP
WHEN I PERFORM LINEAR REGRESSION.
SO NOW WE'LL PERFORM THE REGRESSION BY PRESSING STAT,
RIGHT ARROW ONCE, AND THEN OPTION 4 IS LINEAR REGRESSION.
SO I CAN GO AHEAD AND SCROLL DOWN TO 4,
OR JUST PRESS THE NUMBER 4,
AND NOW I'LL PRESS ENTER.
SO OUR LINE OF BEST FIT IS Y = .47X + 2.6.
NOTICE R IS APPROXIMATELY .99,
AND R SQUARED IS APPROXIMATELY 98%.
SO THIS IS A VERY GOOD MODEL FOR THE GIVEN DATA.
AND THERE'S ONE MORE THING I WANT TO SHOW HERE.
WE WANT TO GRAPH THAT LINE ON THE SCATTER PLOT.
SO WE CAN EITHER ENTER THIS IN MANUALLY INTO Y1,
OR WE CAN HAVE THE CALCULATOR DO IT FOR US.
LET ME SHOW YOU HOW YOU CAN DO THAT.
WE'RE GOING TO RUN THE REGRESSION AGAIN.
PRESS STAT, RIGHT ARROW, OPTION 4.
BUT NOW BEFORE WE PRESS ENTER,
WE'RE GOING TO PRESS THE VARS KEY.
RIGHT ARROW ONCE TO Y VARS, PRESS ENTER,
AND THEN ENTER TO SELECT Y1.
NOW THIS WILL AUTOMATICALLY PERFORM THE REGRESSION,
AND STORE THE EQUATION IN Y1.
SO THIS SAVES US FROM HAVING TO ENTER IN THE LINEAR EQUATION
BY HAND.
SO AGAIN, IT'S THE SAME EQUATION,
BUT NOW IF WE PRESS Y =, THE EQUATION IS ALREADY IN Y1.
NOW, IF WE PRESS GRAPH,
IT WILL SHOW THE LINE ON THE SCATTER PLOT,
AND WE CAN SEE THAT THE LINE IS AN EXCELLENT MODEL
FOR THE GIVEN DATA.
LET'S GO AHEAD AND ANSWER SOME QUESTIONS NOW.
REMEMBER, OUR EQUATION WAS Y = .47X + 2.6.
NUMBER ONE, IS THE EQUATION A GOOD FIT FOR THE DATA?
THE ANSWER IS YES, BECAUSE OUR CORRELATION COEFFICIENT,
OR R, IS APPROXIMATELY = .99, WHICH IS VERY CLOSE TO 1.
AND THE COEFFICIENT OF DETERMINATION,
OR R SQUARED, = .98,
WHICH AGAIN, IS VERY CLOSE TO 1.
NUMBER TWO, IF THE GROWTH OF CONSUMPTION OF SPORTS DRINKS
CONTINUES,
WHAT WILL THE CONSUMPTION BE IN THE YEAR 2015?
REMEMBER, THE BASE YEAR WAS 2002.
SO IF WE TAKE 2015 AND SUBTRACT 2002,
THAT WILL GIVE US THE X VALUE THAT WE SUB INTO OUR EQUATION.
THIS WILL BE 13.
SO WE WANT TO KNOW THE VALUE OF Y WHEN X = 13.
THIS WOULD GIVE US OUR PREDICTION FOR THE YEAR 2015,
OR WE COULD JUST GO TO OUR T TABLE.
SO IT'S APPROXIMATELY 8.7 GALLONS PER PERSON
IN THE YEAR 2015.
NUMBER THREE, WHEN WILL THE CONSUMPTION REACH 20 GALLONS
PER PERSON PER YEAR?
LET'S GO BACK TO THE CALCULATOR.
SO NOW WE WANT TO KNOW WHAT YEAR IT WOULD BE WHEN Y = 20.
SO WE CAN SOLVE THIS ALGEBRAICALLY.
WE WOULD SUBTRACT 2.6 ON BOTH SIDES.
THAT WOULD GIVE US 17.4 = .47X.
WE WOULD DIVIDE BOTH SIDES BY .47
SO X = APPROXIMATELY 37.
THAT'S THE NUMBER OF YEARS PAST 2002,
SO THE ACTUAL YEAR WOULD BE 2002 + 37, OR THE YEAR 2039.
AND THEN FOR NUMBER THREE, WHAT IS THE MEANING OF THE SLOPE
OF THE LINE OF BEST FIT?
REMEMBER, THE SLOPE IS THE COEFFICIENT OF X,
SO OUR SLOPE IS .47.
IF WE WANT TO UNDERSTAND WHAT THIS MEANS,
IT'S OFTEN HELPFUL TO WRITE THIS AS A FRACTION.
LET'S GO AHEAD AND PUT THIS OVER 1.
REMEMBER, THE SLOPE TELLS US THE CHANGE IN Y
WITH RESPECT TO THE CHANGE OF X.
WELL, WHAT DOES Y TELL US?
Y TELLS US THE NUMBER OF GALLONS OF CONSUMPTION PER YEAR,
AND X TELLS US THE YEAR.
SO THE MEANING OF THE SLOPE IS THAT WE HAVE AN INCREASE
OF .47 GALLONS PER PERSON
WHEN X CHANGES BY 1, OR PER YEAR.
AND THE LAST QUESTION, WHAT IS THE MEANING OF THE Y INTERCEPT
OF THE BEST FIT LINE?
WE KNOW THE Y INTERCEPT IS THE 0,2.6.
0 REPRESENTS THE NUMBER OF YEARS PAST 2002,
AND Y IS THE AMOUNT OF CONSUMPTION.
SO THE MEANING OF THIS Y INTERCEPT IS,
ACCORDING TO THE MODEL, IN 2002 THE CONSUMPTION WAS
2.6 GALLONS PER PERSON.
THIS ACTUALLY IS INCORRECT.
IF WE GO BACK AND LOOK AT OUR DATA,
THE TRUE CONSUMPTION WAS 2.7 GALLONS PER PERSON.
AND THIS IS JUST TELLING US THAT THERE IS A MARGIN OF ERROR
WITH OUR MODEL.
IT'S NOT A PERFECT MODEL.
ALL MODELS HAVE THEIR LIMITATIONS.
BUT IN THIS CASE, THE MARGIN OF ERROR IS OBVIOUSLY VERY SMALL.
WE'LL TAKE A LOOK AT A SECOND EXAMPLE IN THE NEXT VIDEO.
THANK YOU FOR WATCHING.