tbates / umx

Making Structural Equation Modeling (SEM) in R quick & powerful
https://tbates.github.io/
44 stars 17 forks source link

It would be nice if umxPower accepted dropping more than one path #167

Closed lf-araujo closed 2 years ago

lf-araujo commented 2 years ago

Code such as:

umxPower(
  trueModel = CLPM_run, update = c("bxy12", "byx12"),
  sig.level = .05, explore = T
) 

Generates the error:

Error: The 'name' argument must be a single character argument in mxRename(retval, name)

Also, plotting is not implemented.

mcneale commented 2 years ago

I confirm that this is a bug. Try replacing name = paste0("drop", update) with name = paste0("drop", update[1]) in both places in umxPower() that it occurs.

tbates commented 2 years ago

Thanks for reporting @lf-araujo ! And thanks for the eyes @mcneale !

I now collapse the update string when building a new name - just hadn't tried more than one path change.

try devtools:install_github("tbates/umx") for the new version

t

tbates commented 2 years ago

OK, I now plot (by default) when explore = TRUE.

What else would be useful? On the TODO is to add a vertical line at N yielding power = .8

power now

When explore is F, the output is just a point estimate of power, so nothing to plot:

'result.mxPower' num 1 attr(*, "detail")=List of 5 ..$ method : chr "ncp" ..$ sig.level: num 0.05 ..$ statistic: chr "LRT" ..$ n : num 400 ..$ power : num 1

tbates commented 2 years ago

FYI, here's what plot(pwr::pwr.r.test(power=.8,r=.3)) does, which has been my target for consistency.

power e g

tbates commented 2 years ago

power

mcneale commented 2 years ago

Very nice! The other pieces of info that would be good to include in the Figures are: i) true model’s parameter values (i.e., effect sizes) and ii) the values to which the parameters were fixed. The second should be easy enough (List (singular) of changed paths: “X_with_Y = 0” and the first could also be reported as a list. Yep, I’m being greedy, but this is an important function. Now I think about it, a single table with parameter name, sim value, and fixed value could cover both.