pitakakariki / simr

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

Could not find function "test" #140

Open mikeypasek opened 5 years ago

mikeypasek commented 5 years ago

Hi,

I have it a model in lmer and am trying to run powerSim on it. I have been getting an error message for each iteration that reads: "Testing ### could not find function "test""

Any guidance on what might be taking place would be appreciated!

Thank you,

Michael

pitakakariki commented 5 years ago

What was the model specification, and how was your call to powerSim phrased?

mikeypasek commented 5 years ago

Thanks for your reply!

I believe that what happened was some type of package interference. I quit R and cleared the workspace, and once I did so, the model and powerSim ran. In case it is still helpful, I was using a lmer model like:

Power.A <- lmer(DV ~ IV1*IV2 + Covariate1 + Covariate2 + (1|id), REML = "TRUE", data = data)

And the call was :

sim <- powerSim(Power.A, test = fixed(“IV1:IV2”))

With immense appreciation for your contributions to the community,

Michael

On Nov 14, 2018, at 5:06 PM, Peter Green notifications@github.com wrote:

What was the model specification, and how was your call to powerSim phrased?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pitakakariki/simr/issues/140#issuecomment-438836510, or mute the thread https://github.com/notifications/unsubscribe-auth/Aq9J5Rf-fdlkaNEFK7xmFnJ0RPC7OgyAks5uvJP5gaJpZM4Yd_sG.

pitakakariki commented 5 years ago

If it happens again, could you send me the output of sessionInfo() please? There might be some way to avoid that sort of interference.

mikeypasek commented 5 years ago

I'd be happy to.

Thanks! Michael

Sent from my iPhone.

On Nov 15, 2018, at 3:23 PM, Peter Green notifications@github.com wrote:

If it happens again, could you send me the output of sessionInfo() please? There might be some way to avoid that sort of interference.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

mikeypasek commented 5 years ago

Hi again,

I do have one more question I am hoping you might be able to offer guidance on. I have fit a lmer model:

model <- lmer(dv ~ iv1*iv2 + (1 | id), REML = “TRUE”, data = data)

For this model, both iv1 and iv2 are within subject manipulations.

And I successfully ran an observed power analysis on this, as well as a power curve. I am trying to estimate the power for a specific sample size, and have used the code:

model2 <- extent(model, along = “id”, n = 300)

When I do this, which has worked with other models, I receive the error message: “Error in levels <-. factor’(tmp’, value = values) : number of levels differs.

Any guidance you might have on how to decipher this error would be ever so appreciated. Again, thank you for your real service to the broader community!

Michael

On Nov 15, 2018, at 3:26 PM, Mikey Pasek mikeypasek@gmail.com wrote:

I'd be happy to.

Thanks! Michael

Sent from my iPhone.

On Nov 15, 2018, at 3:23 PM, Peter Green <notifications@github.com mailto:notifications@github.com> wrote:

If it happens again, could you send me the output of sessionInfo() please? There might be some way to avoid that sort of interference.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pitakakariki/simr/issues/140#issuecomment-439177564, or mute the thread https://github.com/notifications/unsubscribe-auth/Aq9J5WdohQlQ2xohcmqvaaaP5_zjt9Hkks5uvc0xgaJpZM4Yd_sG.

pitakakariki commented 5 years ago

Not sure what would be causing that, but you might try:

table(data$iv1)
table(getData(model2)$iv1)

and the same for iv2.

jritch commented 4 years ago

I ran into a similar issue.

What was wrong was that I was loading the simr library before I loaded the tidyverse library, and the stringr tidyverse package was masking the fixed() function from simr.

library(simr)
library(tidyverse)

image

Reversing the order in which I loaded the libraries and restarting R fixed the issue.