You are on page 1of 5

Statistics for Data Analysis @NikB 6/13/2014

Two Variable
Till now, We dealt with one variable
Correlation and Regression Lets try to find out,
How two things are connected?
How they effect each other?

Nikesh Bajaj
nikesh.14730@lpu.co.in
Asst. Prof., ECE Dept.
Lovely Professional University 117 By Nikesh Bajaj

Concert and Weather Lets Analyze and predict


Guys: organizing concerts Sunshine and Attendance of audience
Concert are best in open air
Ticket sales in summer look promising

Scenario: Temperature is dipping, look like rain, guys


want to predict attendance of audience for given hours of
sun shine.
If attendance will be less than 3500, where ticket wont
even cover the expenses they will cancel the event.

What you can do with given data?


118 By Nikesh Bajaj 119 By Nikesh Bajaj

What sort of analysis you


suggest? Exploring types of Data
Univariate Data: Frequency or probability of one
variable, e.g. weight, players score etc. One thing
It does not tell connection between two
If

120 By Nikesh Bajaj 121 By Nikesh Bajaj

1
Statistics for Data Analysis @NikB 6/13/2014

Exploring types of Data Visualizing bivariate data


Bivariate Data: Values of two variable for each Scatter plot or scatter diagram: DOES IT HELPS?
observation.

Independent or Explanatory variable SO WHAT YOU


One of variable has been controlled in some way or used to CAN
explain other OBSERVE??
Dependent or Response variable
So Which is which for our example?

122 By Nikesh Bajaj 123 By Nikesh Bajaj

Correlation Correlation
Scatter diagram shows the correlation between two
variable
Correlation
Linear: If it is straight line, can be others

124 By Nikesh Bajaj 125 By Nikesh Bajaj

Correlation Coefficient r Computing r


r tells you kind of correlation,
positive, negative, perfect or no

126 By Nikesh Bajaj 127 By Nikesh Bajaj

2
Statistics for Data Analysis @NikB 6/13/2014

Correlation and Causation Lets See example


If there is correlation between two variable Does that One intern was given many scatter plot of..
mean one caused the value of other??

128 By Nikesh Bajaj 129 By Nikesh Bajaj

Correlation and Causation So for Concert


If there is correlation between two variable Does that Sunshine effect Attendance very much
mean one caused the value of other?? Good but
What about attendance of 3500 people??
Not always
Lets see example

130 By Nikesh Bajaj 131 By Nikesh Bajaj

Predict the Attendance Find a Line y = a + bx


Line of Best Fit

132 By Nikesh Bajaj 133 By Nikesh Bajaj

3
Statistics for Data Analysis @NikB 6/13/2014

Line with minimum Error Lets find Line y= a + bx


Error b: Steepness of line, Slop

No need proof right now

Find b = ?

134 By Nikesh Bajaj 135 By Nikesh Bajaj

What about a ??? Solution (Linear Regression)


How to compute? Line of best fit
y = a + bx

136 By Nikesh Bajaj 137 By Nikesh Bajaj

Now Answer Concert guys Answers


y = 15.8 + 5.32x Ans 1: y =47.72 means 4772 people
Q1. When predicted sunshine is 6 Hours what would Ans 2: x=3.61 Hours
be attendance of audience in concert?

Q2. what should be sunshine hours for at least


audience of 3500

138 By Nikesh Bajaj 139 By Nikesh Bajaj

4
Statistics for Data Analysis @NikB 6/13/2014

Correlation Coefficient r Computing r


r tells you kind of correlation,
positive, negative, perfect or no

140 By Nikesh Bajaj 141 By Nikesh Bajaj

Compute r (Correlation Coeff.) Answer

142 By Nikesh Bajaj 143 By Nikesh Bajaj

Exercise Housing Prices (Portland, OR)

500

400
Price 300
(in 1000s 200
of dollars) 100

0
0 500 1000 1500 2000 2500 3000
Size (feet2)
Supervised Learning Regression Problem
Given the right answer for Predict real-valued output
each example in the data.
144 By Nikesh Bajaj