Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulate results #10

Closed
Johnzav888 opened this issue Apr 18, 2018 · 1 comment
Closed

Simulate results #10

Johnzav888 opened this issue Apr 18, 2018 · 1 comment
Labels

Comments

@Johnzav888
Copy link

Dear Kristoffer,

I am very glad to see that you updated the powerlmm package and that you are trying to improve it! Keep up the good work!

To my problem now, I am working on longitudinal models. More precisely, I have 2 level structure with subjects randomized in 2 treatments and they are followed over time. Treatment is the only covariate in the data along with Time and their interaction, where I am most interested in.

I try to simulate some data. When I use the following input, the time and the treatment estimates seem to mess up with each other. In the input I understand that the Time estimate(slope in the control group) is given through the parameter “fixed_slope”, but looking at the results further below, I see that the theta for Time is 0 while the input that I specified(fixed_slope = 0.2) is given to the Treatment theta! And in addition, I see that the mean estimate of the time is 0.20( as it should be)!! Is this a bug or have I misunderstood something here?

P.S. What is the differnece between Power & Power_bw ?

Input

      p1 <- study_parameters(n1 = 10, # number of measurements per subject
                             n2 = 10, # number of subjects per treatment
                             fixed_intercept = 2.4,
                             fixed_slope = 0.20,
                             sigma_subject_intercept = 0.61,
                             sigma_subject_slope = 0.03,
                             cor_subject = -0.30,
                             sigma_error = 0.78,
                             effect_size = -0.8)

Sim

      ttt <- simulate(p1, nsim = 5000)

Output

 Model:  correct 
Random effects

     parameter     M_est   theta est_rel_bias prop_zero  is_NA
subject_intercept  0.3925  0.3721        0.055    0.0044 0.0000
 subject_slope     0.0018  0.0009        1.038    0.0014 0.0000
         error     0.6019  0.6084       -0.011    0.0000 0.0000
   cor_subject    -0.2174 -0.3000       -0.275    0.4922 0.0044

Fixed effects

  parameter       M_est  theta  M_se  SD_est  Power Power_bw Power_satt
(Intercept)       2.4032  2.400  0.242  0.240   1.00       NA        NaN
  treatment      -0.0076  0.200  0.342  0.339   0.06       NA        NaN
      time        0.2000  0.000  0.030  0.029   1.00       NA        NaN
 time:treatment  -0.0884 -0.089  0.042  0.040   0.54      0.49        NaN
---
 Number of simulations: 5000  | alpha:  0.05
 Time points (n1):  10
 Subjects per cluster (n2 x n3):  10 (treatment)
                                     10 (control)

Thanks,
John

@rpsychologist
Copy link
Owner

rpsychologist commented Apr 18, 2018

Hi John, thanks for reporting this. You have specified your model correctly, this is a small bug in the summary() method. The theta column is displayed incorrectly, as you note the thetas for 'treatment' and 'time' have switched place, and should be 0.2 for time.

Power use the normal approximation to calculate p-values (Wald test), and Power_bw use the t-distribution with tot_n - 2 degrees of freedom (for a 2-level model).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants