خرید بک لینک

Vote count: 0

I have a dataset with this structure:

# libraries
library(Zelig) # 5.0-12
library(datatable)

# create data 
time <- factor(rep(-12:12, 50))
treatment <- rbinom(length(time), 1, .75)
outcome <- orm(length(time), 1, 3) + 3 * b 

dat <- data.table(outcome, time, treatment)
dat

            outcome time treatment
   1: 5.2656458  -12         0
   2: 4.8888805  -11         1
   3: 2.6322592  -10         1
   4: 8.2449092   -9         1
   5: 0.5752739   -8         0
  ---                         
1246: 2.1865924    8         0
1247: 1.6028838    9         1
1248: 2.4056725   10         1
1249: 2.0257008   11         1
1250: 6.1503307   12         1

I run a LS model interacting time and treatment:

z <- zls$new()
z$zelig(out ~ time * treatment, data = dat)
summary(z)

Here a trimmed output...

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)
(Intercept)        2.40264    0.71552   3.358  0.00081
time-11           -1.61292    1.08177  -1.491  0.13622
time-10           -1.03283    0.99850  -1.034  0.30116
time-9            -1.47934    1.02667  -1.441  0.14987
time-8            -0.35614    1.02667  -0.347  0.72874
time-7            -1.05803    1.04304  -1.014  0.31061
time-6            -2.25316    1.16178  -1.939  0.05269
.... 
treatment          1.28097    0.89440   1.432  0.15234
time-11:treatment  2.86965    1.30927   2.192  0.02859
time-10:treatment  1.69479    1.25788   1.347  0.17813
time-9:treatment   1.78684    1.27330   1.403  0.16078
time-8:treatment   0.82332    1.27330   0.647  0.51801
time-7:treatment   1.62808    1.28334   1.269  0.20482
time-6:treatment   2.64653    1.36895   1.933  0.05344
time-5:treatment   3.08572    1.36895   2.254  0.02437
....

I would like to estimate the first differences (treatment = 1, treatment = 0) for each time so that I can plot the effects by time.

Any ideas? Thank you in advance

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 20 فروردين 1395 ساعت: 0:31

صفحه بندی