3. What if the scatterplot is not
linear?
• Of course not all data is linear!
• Our method in statistics will involving
mathematically operating on one or both
of the explanatory and response variables
• An inverse transformation will be used to
create a non-linear regression model
• This will be a little “mathy”
4. Transformations
• Before we begin transformations,
remember that some well known
phenomenon act in predictable ways
– I.e. when working with time and gravity, you
should know that there is a square
relationship between distance and time!
5. The Basics
• The data from measurements (raw data)
must be operated on.
• Apply the same mathematical
transformation on the raw data
– Ex. “Square every response”
• Use methods from the previous chapter to
find the LSRL for the transformed data
• Analyze your regression to ensure the LSRL is
appropriate
• Apply an inverse transformation on the LSRL
to find the regression for the raw data.
6. Example
Please refer to p 265 exercise 4.2
Length (cm) Period (s)
16.5 0.777
17.5 0.839
19.5 0.912
22.5 0.878
28.5 1.004
31.5 1.087
34.5 1.129
37.5 1.111
43.5 1.290
46.5 1.371
106.5 2.115
9. Example
• L3 = L2^.5 (square
root)
• LinReg L1, L3
• Note that the value
of r2 has increased
• Note that the value
of the residual of the
last point has
decreased
10. Exponential Models
• Many natural phenomenon are explained
by an exponential model.
• Exponential models are marked by sharp
increases in growth and decay.
• Basic model: y = A·Bx
• For this transformation, you need to take
the logarithm of the response data.
• You may use “log10” or “ln” your choice.
– I prefer “ln” (of course)
11. Exponential Models
After the transformation, we have the
following linear model: ln(y) = a + b·x
1. ln(y) = a + b·x
2. eln(y) = e(a + b·x) exponentiate
3. y = ea · ebx property of logarithms
4. Let ‘A’ = ea redefine variables
‘B’ = eb
5. y = A·Bx this is our model
12. Exponential Models
• Since this is an ‘applied math’ course,
you need not remember how to apply the
inverse transformation
• Whew
• BUT you do need to memorize:
when ln(y) = a + bx
y = A·Bx
where ‘A’ = ea and ‘B’ = eb
27. Power Models
• These models are used when the rate of
increase is less severe than an
exponential model, or if you suspect a
‘root’ model
• For this model, you will find the
logarithms of both the expl var and the
resp var
28. Power models
LSRL on transformed data yields:
ln(y) = a + b·ln(x)
1. ln(y) = a + b·ln(x)
2. e ln(y) = e(a + b·ln(x))
3. y = ea·eln(x^b)
4. y = ea ·xb
5. Let ‘A’ = ea
6. y = A · xb
46. Power models
• Much like the exponential model, you
only need to know how the transformed
model becomes the model for the raw
data.
• When ln(y) = a + b·ln(x),
y = A · xb
where ‘A’ = ea
47. Transformation thoughts
• Although this is not a major topic for the
course, you still need to be able to apply
these two transformations (exp and power)
• Be sure to check the residuals for the LSRL
on transformed data! You may have picked
the wrong model :/
• If one model doesn’t work, try the other. I
would start with the exponential model.
• Don’t transform into a cockroach. Ask Kafka!
50. Marginal Distributions
• Tables that relate two categorical variables
are called “Two-Way Tables”
– Ex 4.11 pg 292
• Marginal Distribution
– Very fancy term for “row totals and column
totals”
– Named because the totals appear in the margins
of the table. Wow.
• Often, the percentage of the row or column
table is very informative
56. Marginal Distributions “Age Group”
Age
Group
Female Male Total Marg. Dist.
15-17 89 61 150
18-24 5668 4697 10365
25-34 1904 1589 3494
35 or
older
1660 970 2630
Totals 9321 7317 16639
57. Marginal Distributions “Age Group”
Age
Group
Female Male Total Marg. Dist.
15-17 89 61 150
18-24 5668 4697 10365
25-34 1904 1589 3494
35 or
older
1660 970 2630
Totals 9321 7317 16639
Row total / grand total
150/16639=0.009
58. Marginal Distributions “Age Group”
Age
Group
Female Male Total Marg. Dist.
15-17 89 61 150 0.9%
18-24 5668 4697 10365
25-34 1904 1589 3494
35 or
older
1660 970 2630
Totals 9321 7317 16639
Row total / grand total
150/16639=0.009
59. Marginal Distributions “Age Group”
Age
Group
Female Male Total Marg. Dist.
15-17 89 61 150 0.9%
18-24 5668 4697 10365 62.3%
25-34 1904 1589 3494 21.0%
35 or
older
1660 970 2630 15.8%
Totals 9321 7317 16639 100%
Adds to 100%
60. Marginal Distributions “Gender”
Age
Group
Female Male Total
15-17 89 61 150
18-24 5668 4697 10365
25-34 1904 1589 3494
35 &up 1660 970 2630
Totals 9321 7317 16639
Margin
dist.
56% 44% 100%
Similarly for columns
61. Describing Relationships
• Some relationships are easier to see when
we look at the proportions within each
group
• These distributions are called “Conditional
Distributions”
• To find a conditional distribution, find each
percentage of the row or column total.
• Let’s look at the same table, and find the
conditional distribution of gender, given
each age group
62. Conditional Distributions
Age
Group
Female Male Total
15-17 89 61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
63. Conditional Distributions
Age
Group
Female Male Total
15-17 89 61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
We will look at the
conditional
distribution for this
row
64. Conditional Distributions
Age
Group
Female Male Total
15-17 89 61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
This cell is 89/150
(cell total /row total)
=53.9%
65. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
This cell is 89/150
(cell total /row total)
=59.3%
66. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
This cell is 61/150
(cell total /row total)
=40.7%
67. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
This cell is 61/150
(cell total /row total)
=40.7%
68. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
69. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
The table with
complete conditional
distributions for each
row
70. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
For an analysis of the
effect of age groups,
compare a row’s
conditional
distribution…
71. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
With the marginal
distribution for the
columns…
72. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
They should be close
…
73. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
… unless there is an
effect caused by the
age group (?)
74. Conditional Distributions
Age
Group
Female Male Total
15-17 89
(59.3%)
61
(40.7%)
150
(100%)
18-24 5668
(54.7%)
4697
(45.3%)
10365
(100%)
25-34 1904
(54.5%)
1589
(45.5%)
3494
(100%)
35 or
older
1660
(63.1%)
970
(36.9%)
2630
(100%)
Totals 9321
(56%)
7317
(44%)
16639
(100%)
… and these are not
close to the marginal
distribution!
75. Conditional Distributions
• Based on the previous table, the
distribution of “gender given age group”
are not that different.
• We can see that the “35 and older” group
seems to differ slightly from the overall
trend.
76. Conditional Distributions
“age group given gender”
Age
Group
Female Male Total
15-17 89
(1%)
61
(0.8%)
150
(0.9%)
18-24 5668
(60.8%)
4697
(64.2%)
10365
(62.3%)
25-34 1904
(20.4%)
1589
(21.7%)
3494
(21.0%)
35 or
older
1660
(17.8%)
970
(13.3%)
2630
(15.8%)
Totals 9321
(100%)
7317
(100%)
16639
(100%)
77. Conditional Distributions
“age group given gender”
Age
Group
Female Male Total
15-17 89
(1%)
61
(0.8%)
150
(0.9%)
18-24 5668
(60.8%)
4697
(64.2%)
10365
(62.3%)
25-34 1904
(20.4%)
1589
(21.7%)
3494
(21.0%)
35 or
older
1660
(17.8%)
970
(13.3%)
2630
(15.8%)
Totals 9321
(100%)
7317
(100%)
16639
(100%)
Here is the same chart
with the conditional
distributions by
gender…
78. Conditional Distributions
“age group given gender”
Age
Group
Female Male Total
15-17 89
(1%)
61
(0.8%)
150
(0.9%)
18-24 5668
(60.8%)
4697
(64.2%)
10365
(62.3%)
25-34 1904
(20.4%)
1589
(21.7%)
3494
(21.0%)
35 or
older
1660
(17.8%)
970
(13.3%)
2630
(15.8%)
Totals 9321
(100%)
7317
(100%)
16639
(100%)
Is there a gender
effect noticeable from
this table?
79. Conditional Distributions
“age group given gender”
Age
Group
Female Male Total
15-17 89
(1%)
61
(0.8%)
150
(0.9%)
18-24 5668
(60.8%)
4697
(64.2%)
10365
(62.3%)
25-34 1904
(20.4%)
1589
(21.7%)
3494
(21.0%)
35 or
older
1660
(17.8%)
970
(13.3%)
2630
(15.8%)
Totals 9321
(100%)
7317
(100%)
16639
(100%)
80. Conditional Distribution
Conclusions from the previous chart
• Females are more likely to be in the “35 and
older group” and less likely to be in the “18
to 24” group
• Males are more likely to be in the “18 to 24”
group and less likely to be in the “35 and
older” group
• These differences appear slight. Are
actually “significant” with respect to the
overall distribution?
81. Conditional Distribution
• No single graph portrays the form of the
relationship between categorical
variables.
• No single numerical measure (such as
correlation) summarizes the strength of
the association.
82. Simpson’s Paradox
• Associations that hold true for all of
several groups can reverse direction
when teh data is combined to form a
single group.
• EX 4.15 pg 299
• This phenomenon is often the result of an
“unaccounted” variable.
85. Different Relationships
• Suppose two variables (X and Y) have
some correlation
– i.e. when X increases in value, Y increases as
well
– One of the following relationships may hold.
86. Different Relationships
Causation
• In this relationship, the explanatory
variable is somehow affecting the
response variable.
• In most instances, we are looking to find
evidence of a causation relationship
88. Different Relationships
Common Response
• In this relationship, both X and Y are
correlated to a third (unknown) variable
(Z).
• EX, When Z increases X increases and Y
increases.
• Unless we known about Z, it appears as
though X and Y have a causation
relationship.
90. Different Relationships
Confounding
• X and Y have correlation,
• An (often unknown) third variable ‘Z”
also has correlation with Y
• Is X the explanatory variable, or is Z the
explanatory variable, or are the both
explanatory variables?
92. Causation
• The best way to establish causation is
with a carefully designed experiment
– Possible ‘lurking variables’ are controlled
• Experiments cannot always be conducted
– Many times, they are costly or even unethical
• Some guidelines need to be established in
cases where an observational study is the
only method to measure variables.
93. Causation- some criteria
• Association is strong
• Association is consistent (among different
studies)
• Large values of the response variable are
associated with stronger responses
(typo?)
• The alleged cause precedes the effect in
time
• The alleged cause is probable