Vous êtes sur la page 1sur 5

------------------------------------------------------------------------------------------------------------------------------------name: <unnamed>

log: c:\stata_blog\two_by_two\twobytwo.log
log type: text
opened on: 18 Jan 2016, 20:32:48
.
. /* We begin by looking at average values of opp across our four groups */
. foreach x of varlist fem_int fem_ext mal_int mal_ext{
2.
summ opp if `x'==1
3. }
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+--------------------------------------------------------opp |
26
58.65385
31.38655
0
100
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+--------------------------------------------------------opp |
24
64.875
32.57675
0
100
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+--------------------------------------------------------opp |
26
55.75
29.11057
12.5
100
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+--------------------------------------------------------opp |
27
69.48148
26.35464
15
100
.
.
>
>
>
>
>
>
.
.

/* The above shows, respectively, the mean of opp for the fem_int, fem_ext,
mal_int, mal_ext groups. Perceived fraud opportunity is highest for the
male extrovert group and lowest for the male introvert group.
Next, we run a regression model without a constant term. This will give us
the means of each group, but the stock output will not tell us directly
if the differences in groups are significant. */
reg opp fem_int fem_ext mal_int mal_ext, nocons

Source |
SS
df
MS
-------------+---------------------------------Model | 401614.375
4 100403.594
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 489895.25
103 4756.26456

Number of obs
F(4, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
112.59
0.0000
0.8198
0.8125
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------fem_int | 58.65385 5.856377
10.02 0.000
47.03352
70.27417
fem_ext |
64.875 6.095511
10.64 0.000
52.78018
76.96982
mal_int |
55.75 5.856377
9.52 0.000
44.12968
67.37032
mal_ext | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------.
. /* The means for each group are identical using -summ- or -reg-. Next, we run
a
> regression model with a constant term, the two indicator variables, and the

>
>
>
>
>
>
>

interaction. Since we have an indicator equal to one for female and a second
indicator equal to one for introvert, male extroverts are our base group.
Accordingly, we expect B0 in the regression to be equal to 69.4814 since
this is the mean of opp for the base group. Since B1 is related to the gender
indicator variable, adding B0 to B1 gives us the mean of female extroverts.
Since the mean of male extroverts if 69.4814, and the mean of female
is 64.875,we expect B1 to equal 64.875 - 69.4184= -4.6064. B2 is the indicator

> variable for personality. Adding B0 to B2 gives us the mean of the male
> introvert group which we know is 55.75. Accordingly, we expect B2 to be equal
> to 55.75 - 69.4184 = -13.7314. Next is the potentially tricky part: Ask yourse
lf
> what our expectation is for the parameter estimate of the interaction term? We
> already have male extroverts (B0), female extroverts (B0 + B1), and male
> introverts (B0 + B2). We need to estimate the difference between male extrover
ts
> and female introverts. Let's come back to this after looking at the below
> regression output */
.
. reg opp gen1 pers1 gen_pers
Source |
SS
df
MS
-------------+---------------------------------Model | 3011.88678
3 1003.96226
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 91292.7621
102 895.02708

Number of obs
F(3, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
1.13
0.3424
0.0330
0.0037
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------gen1 | -4.606481 8.377478
-0.55 0.584
-21.22922
12.01625
pers1 | -13.73148 8.205123
-1.67 0.097
-30.01223
2.549263
gen_pers | 7.510328 11.78034
0.64 0.525
-15.86443
30.88508
_cons | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------.
. /* We can see that B0 is equal to 69.4814, B1 is equal to -4.6064, and B2
> is equal to -13.7314. All of this matches to what we expected based on manual
> calculations of mean differences across the groups. Back to the question
> about the expectation of the parameter estimate for B3. We know the mean opp f
or
> male extroverts is 69.4184 and the mean opp for female introverts is 58.6538.
> It might be tempting to then say that we therefore expect B3 to be equal to
> 58.6538 - 69.4814 = -10.8276 , but that is not the result we get. B3 is equal
to
> 7.5103. Why is this? It is because in our female introverts group, we also
> have to add in the indicator variable for female and the indicator variable
> for personality to the interaction term. These are women, so you add the fema
le
> indicator variable. These are introverts, so you add the personality indicato
r
> variable. They also need the interaction term added, as well. If we write th
e
> difference as B0 + B1 + B2 + B3= the mean opportunity for female introvert,
> and we already know what B0, B1, B2 and the mean opportunity for female
> introverts, we can solve for B3. 69.4814 -4.6064 - 13.7314 + x= 58.6538.
> This gives us an anticipated value of B3= 7.5102 which, with rounding,
> is what we obtain from the regression. Return to the Wooldridge

> example of the difference-in-differences estimator, as well. B3 here is our


> difference-in-differences estimator, which gives us the difference in
> mean opportunity for male extroverts and female extroverts minus the differen
ce
> in mean opportunity for male introverts and female introverts. This may be
> seen below */
.
. reg opp fem_int fem_ext mal_int mal_ext, nocons
Source |
SS
df
MS
-------------+---------------------------------Model | 401614.375
4 100403.594
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 489895.25
103 4756.26456

Number of obs
F(4, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
112.59
0.0000
0.8198
0.8125
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------fem_int | 58.65385 5.856377
10.02 0.000
47.03352
70.27417
fem_ext |
64.875 6.095511
10.64 0.000
52.78018
76.96982
mal_int |
55.75 5.856377
9.52 0.000
44.12968
67.37032
mal_ext | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------.
. /* Estimate the difference in means for male_ext and fem_ext minus the
> difference in means for mal_int and fem_int and obtain the standard error
> of the difference. */
. di (69.48148 - 64.875) - (55.75 - 58.65385)
7.51033
.
. reg opp gen1 pers1 gen_pers
Source |
SS
df
MS
-------------+---------------------------------Model | 3011.88678
3 1003.96226
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 91292.7621
102 895.02708

Number of obs
F(3, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
1.13
0.3424
0.0330
0.0037
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------gen1 | -4.606481 8.377478
-0.55 0.584
-21.22922
12.01625
pers1 | -13.73148 8.205123
-1.67 0.097
-30.01223
2.549263
gen_pers | 7.510328 11.78034
0.64 0.525
-15.86443
30.88508
_cons | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------.
.
>
.
.
>
>
>
.

/* The gen_pers parameter estimate agrees to the above and we automatically


have the standard error of this difference. */
/* Next, we turn to various methods to test the statistical significance
between the difference in mean opp for male extroverts and female introverts.
This can be done estimating the mean of each group using regression
without a constant term.... */

. reg opp fem_int fem_ext mal_int mal_ext, nocons


Source |
SS
df
MS
-------------+---------------------------------Model | 401614.375
4 100403.594
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 489895.25
103 4756.26456

Number of obs
F(4, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
112.59
0.0000
0.8198
0.8125
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------fem_int | 58.65385 5.856377
10.02 0.000
47.03352
70.27417
fem_ext |
64.875 6.095511
10.64 0.000
52.78018
76.96982
mal_int |
55.75 5.856377
9.52 0.000
44.12968
67.37032
mal_ext | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------. test _b[mal_ext]== _b[fem_int]
( 1) - fem_int + mal_ext = 0
F( 1,
99) =
Prob > F =
.
.
>
>
>
.

1.74
0.1900

/* ... or by using a regression with a constant term and testing a linear


combination of parameters. Note here the appropriate test is not
_b[gen1] = _b[pers1] = _b[gen_pers] =0. We aren't testing that each are equal
to zero, but rather that the sum is equal to zero. */
reg opp gen1 pers1 gen_pers

Source |
SS
df
MS
-------------+---------------------------------Model | 3011.88678
3 1003.96226
Residual | 88280.8754
99 891.726014
-------------+---------------------------------Total | 91292.7621
102 895.02708

Number of obs
F(3, 99)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
1.13
0.3424
0.0330
0.0037
29.862

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------gen1 | -4.606481 8.377478
-0.55 0.584
-21.22922
12.01625
pers1 | -13.73148 8.205123
-1.67 0.097
-30.01223
2.549263
gen_pers | 7.510328 11.78034
0.64 0.525
-15.86443
30.88508
_cons | 69.48148 5.746903
12.09 0.000
58.07838
80.88458
-----------------------------------------------------------------------------. test _b[gen1] + _b[pers1] + _b[gen_pers]=0
( 1) gen1 + pers1 + gen_pers = 0
F( 1,
99) =
Prob > F =

1.74
0.1900

.
. /* t test vs. regression for difference in means between male extroverts and
> female extroverts. */
. reg opp gen1

Source |
SS
df
MS
-------------+---------------------------------Model | 31.4308152
1 31.4308152
Residual | 91261.3313
101 903.577538
-------------+---------------------------------Total | 91292.7621
102 895.02708

Number of obs
F(1, 101)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

103
0.03
0.8524
0.0003
-0.0096
30.06

-----------------------------------------------------------------------------opp |
Coef. Std. Err.
t
P>|t|
[95% Conf. Interval]
-------------+---------------------------------------------------------------gen1 | -1.105283 5.926228
-0.19 0.852
-12.86133
10.65076
_cons | 62.74528 4.128999
15.20 0.000
54.55446
70.93611
-----------------------------------------------------------------------------. ttest opp, by(gen1)
Two-sample t test with equal variances
-----------------------------------------------------------------------------Group |
Obs
Mean
Std. Err. Std. Dev. [95% Conf. Interval]
---------+-------------------------------------------------------------------0 |
53
62.74528
3.89176
28.33244
54.9359
70.55467
1 |
50
61.64
4.495781
31.78997
52.60539
70.67461
---------+-------------------------------------------------------------------combined |
103
62.20874
2.94781
29.917
56.36177
68.0557
---------+-------------------------------------------------------------------diff |
1.105283
5.926228
-10.65076
12.86133
-----------------------------------------------------------------------------diff = mean(0) - mean(1)
t = 0.1865
Ho: diff = 0
degrees of freedom =
101
Ha: diff < 0
Pr(T < t) = 0.5738

Ha: diff != 0
Pr(|T| > |t|) = 0.8524

.
. /* Above results are equivalent. */
.
end of do-file

Ha: diff > 0


Pr(T > t) = 0.4262

Vous aimerez peut-être aussi