+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 17 of 17

Thread: compute true values monte carlo simulation

  1. #16
    Points: 1,647, Level: 23
    Level completed: 47%, Points required for next Level: 53

    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts



    OK, thanks again!

  2. #17
    Points: 1,647, Level: 23
    Level completed: 47%, Points required for next Level: 53

    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hi there,

    In continuation to what I posted before in this thread, I'm still confused about the following:

    suppose data is generated as:

    W1=rnorm(n,0,1)
    W2=runif(n,-2,2)
    W3=rnorm(n,1,1)
    A <- rbinom(n,1, .5)
    Y <- 3.5*A - .75*W1 - 1.5*W2 - .75*W3 + 1.75*(A*W3) + rnorm(n)

    where A is a treatment variable. Then the true treatment effect is 5.25, which can be seen straightaway from Y (3.5+1.75) or can be computed as shown in previous posts by MC simulation.

    Now, when A is changed to :
    A <- rbinom(n,1, 1/(1+exp(-(.4*W1 + .5*W2 + .4*W3))))
    it is not as straightforward right?

    so I figured the treatment effect can be computed as follows (in R):

    n=10000
    n.sim=500
    y1 =rep(NA,n.sim)
    y0 =rep(NA,n.sim)
    for (s in 1:n.sim){
    W1=rnorm(n,0,1)
    W2=runif(n,-2,2)
    W3=rnorm(n,1,1)
    A <- rbinom(n,1, 1/(1+exp(-(.4*W1 + .5*W2 + .4*W3))))
    Y <- 3.5*A - .75*W1 - 1.5*W2 - .75*W3 + 1.75*(A*W3) + rnorm(n)
    dat=as.data.frame(cbind(A,Y))
    y1[s]=mean(dat$Y[A==1])
    y0[s]=mean(dat$Y[A==0])
    }
    mean(y1)-mean(y0)

    which gives a treatment effect of approximately 4.08

    however, I'm not sure this is correct??

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

           




Similar Threads

  1. monte carlo simulation
    By mathsohard in forum R
    Replies: 1
    Last Post: 03-05-2011, 09:19 PM
  2. Replies: 2
    Last Post: 02-15-2011, 06:37 AM
  3. Replies: 2
    Last Post: 03-21-2010, 01:25 AM
  4. What is a monte carlo simulation?
    By brad henrie in forum Statistical Research
    Replies: 1
    Last Post: 10-22-2009, 08:53 PM
  5. Replies: 4
    Last Post: 07-23-2009, 02:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats