pitakakariki / simr

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

Can not get effect size from fixef #116

Open henganl2 opened 6 years ago

henganl2 commented 6 years ago

Hi,

I am trying to get the effect size for my model by using fixef, but it keeps give me NA. My data set have yield data from three location, and the Treatment is different times of fungicide application.

Here is my model, model_MW <- lmer(Machine_weight~Treatment+(1|Location)+(Location/Treatment)+(Location:Block), data=Raw.data_R_SIMR, REML = FALSE)

I could get information from the powerSim (showing as below)

powerSim(model_MW, fixed("Treatment:Location","f"), nsim=20)

Power for predictor 'Treatment:Location', (95% confidence interval):===============================================| 65.00% (40.78, 84.61) Test: Type-II F-test (package car) Based on 20 simulations, (20 warnings, 0 errors) alpha = 0.05, nrow = 58 Time elapsed: 0 h 0 m 8 s nb: result might be an observed power calculation Warning message: In observedPowerWarning(sim) : This appears to be an "observed power" calculation

But I am not sure why I can't get the effect size for the treatment. fixef(model_MW)["Treatment"]

Did I miss something in the code? Thanks!!

pitakakariki commented 6 years ago

It sounds like Treatment is a factor? If you look at the whole vector of fixed effects with fixef(model_MW), what are the names it gives to the effects?

henganl2 commented 6 years ago

Yes, I have 5 treatments and consider as fixed effect. Here is what I get: fixef(model_MW) (Intercept) Treatment3X Treatment6X Treatment9X TreatmentNIC 51.2939621 -1.1077971 -2.4439621 0.2810379 -1.0856287

pitakakariki commented 6 years ago

Your effects sizes are fixef(model_MW)["Treatment3X"] etc.

henganl2 commented 6 years ago

I got the effect sizes! Thanks for your time :)

henganl2 commented 6 years ago

Hi, Sorry, I have another question.

I want to extend my Location from 3 to 20 and use powerSim. Here is my code:

model_MW_2 <- extend(model_MW, along="Location", n=20) powerSim(model_MW_2, fixed("Treatment", "f"), nsim=20) pc_MW_2 <- powerCurve(model_MW_2, fixed("Treatment", "f"), along="Location", nsim=20) Calculating power at 10 sample sizes along Location

How does it specify the 10 sample size in here? Since I didn't set it in the code. I have used getData(model_MW_2) to check the data set. For each location, the sample size should be 16.

Thanks in advance again!

pitakakariki commented 6 years ago

The 10 sample sizes will be varying numbers of locations - e.g. 3, 5, 7, ... 18, 20. Those are chosen automatically, but you can override them with the breaks argument.

The printout for powerCurve will also tell you the number of rows for each analysis of the curve.

Note that the extend function will recycle the locations from your original dataset. So if you have 16 observations per location, so should the extended data. But if you have, say, 16, 17, and 14, your extended data will have e.g. 16, 17, 14, 16, 17, 14, ... 16.

henganl2 commented 6 years ago

Got it !! Thanks :)

henganl2 commented 6 years ago

Hi, I have another question about the effect size, I read the other post, you mentioned that there is no standardized effect size for the mixed model.

So what formula does fixef used to calculate the effect size? when we change the effect size by using fixef, what we change is the difference between the intercept (control) and the treatments?

Thanks

pitakakariki commented 6 years ago

In the other post I meant there's no standard equivalent to Cohen's d.

Your understanding of fixef looks correct to me.