pitakakariki / simr

Power Analysis of Generalised Linear Mixed Models by Simulation
69 stars 19 forks source link

error msg in powerCurve #145

Open huyang200606 opened 5 years ago

huyang200606 commented 5 years ago

Dear Peter and other simR users, I'm trying to use simR to calculate the sample size of a certain predictor based on the glmer results. However, the powerCurve function always returns the error. Please see the following output:

> accept_fit1 <- glmer(IsAccept ~ 1 + Condition + c.unit + c.Inequality +
                                    (1|SbjID), 
                          data = df_valid, family = "binomial",
                          control = glmerControl(optimizer = c("bobyqa")))
> summary(accept_fit1)

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: IsAccept ~ 1 + Condition + c.unit + c.Inequality + (1 | SbjID)
   Data: df_valid
Control: glmerControl(optimizer = c("bobyqa"))

AIC      BIC   logLik deviance df.resid 
  3129.0   3158.1  -1559.5   3119.0     2438 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.3430 -0.8556  0.3605  0.8539  3.2569 

Random effects:
 Groups Name        Variance Std.Dev.
 SbjID  (Intercept) 0.3425   0.5852  
Number of obs: 2443, groups:  SbjID, 42
Fixed effects:
                Estimate Std. Error z value Pr(>|z|)    
(Intercept)      0.26265    0.10934   2.402   0.0163 *  
ConditionPunish -0.50853    0.08706  -5.841 5.18e-09 ***
c.unit          -0.52483    0.04471 -11.739  < 2e-16 ***
c.Inequality     0.02916    0.04340   0.672   0.5017    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) CndtnP c.unit
ConditnPnsh -0.399              
c.unit      -0.024  0.058       
c.Inequalty  0.002 -0.006 -0.007

> pc <- powerCurve(accept_fit1, along="ConditionPunish", nsim=10)
Error in get(along) : object 'ConditionPunish' not found

I read previous strings but sadly did not find the solution. Could you please help me with that? Thanks for your help and have a nice weekend!

Best, Yang

pitakakariki commented 5 years ago

It doesn't make any sense to use Condition as your along argument. Maybe you meant SbjID?