pitakakariki / simr

Power Analysis of Generalised Linear Mixed Models by Simulation
70 stars 20 forks source link

Summary of power curve: nrows or nlevels #155

Open AlexHmann opened 5 years ago

AlexHmann commented 5 years ago

Hi!

This may be a stupid question, but I don't know how to solve my problem.

I have a binomial GLMM: model1 <- glmer(cbind(a, b) ~ c + (1 | obs), family = "binomial", data = x)

... where a and b are numerical responses and c is factorial with two categories.

I am running a powerCurve with along = "obs", i.e. along the observation id. powerCurve(model1 , fixed("c", "lr"), along = "obs")

The summary of the powerCurve has two columns, nrow and nlevels. nrow is always 2*nlevels and its maximum value is 2 times the length of my initial table. The powerCurve clearly uses nlevels for the x values. But the curve crosses 0.8 at unexpectedly low number of observations. So, I was just wondering if the x-values should instead maybe be the nrow column? Does 1 unit of nlevels stand actually for 2 datapoints, one for each level? What in general stand these two columns for? Thanks!

pitakakariki commented 5 years ago

nlevels should be the number of unique values for obs.

nrows should be the total number of rows corresponding to nlevels of whatever is supplied to along.

It looks like you have to measurements for each obs, one for each level of c?

AlexHmann commented 5 years ago

Yes, exactly! I have a table with four columns. Column "obs" is the observation ID, and column "a" and "b" are the measurements for each ID. Column "c" has two levels and tells me to which group an ID belongs (e.g. "species 1" and "species 2").

obs a b c 1 10 15 species1 2 4 9 species2 3 6 6 species2 4 5 3 species1 .....

If simr tells me now that my power curve hits 0.8 at nlevels=10, does this mean I need 10 rows/obs. of the type of table I supply or that I need 10 rows for each, "species 1" and "species 2" ("c" column)?