Intermediate Statistics II - Partial Exam
1. Dummy coding
2. Moderation analysis
3. Mediation analysis
Week 1: Dummy coding
Dummy coding → categorical variables with more than 2 categories (e: religion: buddhism,
christianism, prothesant) are coded into variables all of which have values of only 0 or 1.
Dummy coding steps
1. Dummy variables = number of variables minus 1 (n-1)
2. Choose one of your groups as baseline reference category (if not given it is usually the
control group)
3. Having chosen baseline, assign that group values of 0 for all your dummy variables
4. For first dummy variable, assign 1 to the first group you want to compare against
baseline, all others 0
, 5. Continue step 4 for each group, until you have no dummies left
6. Place dummy variables into regression analysis in the same block
Example: creating dummies for occupation with nurse as baseline (n-1).
→
Present the regression equation for a constant and the dummy variables
𝑦𝑖 = β0 + β1(𝑥1𝑖) + β2(𝑥2𝑖) + ..... β𝑘(𝑥𝑘𝑖) + ε𝑖
→ 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠𝑖 = β0 + β1(𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟𝑖) + β2(𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖) + β3(𝑡𝑒𝑎𝑐ℎ𝑒𝑟𝑖) + ε𝑖
Where
- β0 = happiness of nurse (reference)
- β1 = difference in happiness of financial trader versus nurse
- β2 = difference in happiness of pianist versus nurse
- β3 = difference in happiness of teacher versus nurse
Present the regression equation (with coefficient values) for a constant and 3 dummies
𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒 𝑖 = β0 + β1(𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟𝑖) + β2(𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖) + β3(𝑡𝑒𝑎𝑐ℎ𝑒𝑟𝑖) + ε𝑖
1. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒 𝑖 = β0 + 0 + 0 + 0
- 66.875 = β0
2. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟 𝑖 = β0 + β1(1) + β2(0) + β3(0)
- 35.625 = 66. 875 + β1
- -31.25 = β1
3. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖 = β0 + β1(0) + β2(1) + β3(0)
- 60.625 = 66.875 + β2
- -6.25 = β2
4. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑡𝑒𝑎𝑐ℎ𝑒𝑟 𝑖 = β0 + β1(0) + β2(0) + β3(1)
5. 57.500 = 66.875 + β3
6. -9.375 = β3
1. Dummy coding
2. Moderation analysis
3. Mediation analysis
Week 1: Dummy coding
Dummy coding → categorical variables with more than 2 categories (e: religion: buddhism,
christianism, prothesant) are coded into variables all of which have values of only 0 or 1.
Dummy coding steps
1. Dummy variables = number of variables minus 1 (n-1)
2. Choose one of your groups as baseline reference category (if not given it is usually the
control group)
3. Having chosen baseline, assign that group values of 0 for all your dummy variables
4. For first dummy variable, assign 1 to the first group you want to compare against
baseline, all others 0
, 5. Continue step 4 for each group, until you have no dummies left
6. Place dummy variables into regression analysis in the same block
Example: creating dummies for occupation with nurse as baseline (n-1).
→
Present the regression equation for a constant and the dummy variables
𝑦𝑖 = β0 + β1(𝑥1𝑖) + β2(𝑥2𝑖) + ..... β𝑘(𝑥𝑘𝑖) + ε𝑖
→ 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠𝑖 = β0 + β1(𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟𝑖) + β2(𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖) + β3(𝑡𝑒𝑎𝑐ℎ𝑒𝑟𝑖) + ε𝑖
Where
- β0 = happiness of nurse (reference)
- β1 = difference in happiness of financial trader versus nurse
- β2 = difference in happiness of pianist versus nurse
- β3 = difference in happiness of teacher versus nurse
Present the regression equation (with coefficient values) for a constant and 3 dummies
𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒 𝑖 = β0 + β1(𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟𝑖) + β2(𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖) + β3(𝑡𝑒𝑎𝑐ℎ𝑒𝑟𝑖) + ε𝑖
1. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒 𝑖 = β0 + 0 + 0 + 0
- 66.875 = β0
2. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑓𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙 𝑡𝑟𝑎𝑑𝑒𝑟 𝑖 = β0 + β1(1) + β2(0) + β3(0)
- 35.625 = 66. 875 + β1
- -31.25 = β1
3. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑝𝑖𝑎𝑛𝑖𝑠𝑡𝑖 = β0 + β1(0) + β2(1) + β3(0)
- 60.625 = 66.875 + β2
- -6.25 = β2
4. 𝐻𝑎𝑝𝑝𝑖𝑛𝑒𝑠𝑠 𝑜𝑓 𝑡𝑒𝑎𝑐ℎ𝑒𝑟 𝑖 = β0 + β1(0) + β2(0) + β3(1)
5. 57.500 = 66.875 + β3
6. -9.375 = β3