I hope you are all doing great.
I am trying to calculate the ttest of x (total dollar's placement) by y (with 1 = inside the US and 0 = outside the US) over the period 1995 and 2000.
I tried the following code:
Code:
ttest x, by(y)
Code:
egen mean_1 = mean(x) if year <= 1998 & y == 1 fillmissing mean_1, with(any) egen mean_2 = mean(x) if year > 1998 & y == 1 fillmissing mean_2, with(any) egen mean_3 = mean(x) gen x_1 = ((mean_1-mean_2)/mean_3) egen mean_11 = mean(x) if year <= 1998 & y == 0 fillmissing mean_11, with(any) egen mean_12 = mean(x) if year > 1998 & y == 0 fillmissing mean_12, with(any) gen x_2 = ((mean_11-mean_12)/mean_3) gen Pre_Post = . replace Pre_Post = x_1 if y == 1 replace Pre_Post = x_2 if y == 0 ttest Pre_Post, by(y)
Thanks in advance,
Eugene
0 Response to Ttest
Post a Comment