tidymodels / broom

Convert statistical analysis objects from R into tidy format
https://broom.tidymodels.org
Other
1.43k stars 301 forks source link

tidy lavaan output #27

Closed Ohlsen closed 6 years ago

Ohlsen commented 9 years ago

Hi! It would be cool to have tidy output for the lavaan-package (https://github.com/yrosseel/lavaan) which is used for structural equation modeling and cfa. Thanks =)

dgrtwo commented 9 years ago

I'd also like to have that included! But I've put some time into exploring tidying methods for lavaan objects, and the objects are pretty intense. Take a look, for instance, at getMethod(summary, "lavaan"): there are many possible contents depending on the kind of fit, and some of them are stored in a counterintuitive way.

It's also unclear what the tidy results would be, as each latent variable model stores multiple tables. I'm sure it's possible to construct a tidied version, but I'm worried I might not be the one to do it (as I'm not familiar with the package as a user).

If you had some specific ideas for the input and output for tidying methods (or better yet, code for some of them) I'd be very happy to help incorporate them into the package!

One thing I was able to cook up was a glance method, but that's just a start:

glance.lavaan <- function(x, ...) {
  ret <- as.data.frame(t(unclass(fitMeasures(x))))
  # rename some to fit conventions of the package
  ret <- plyr::rename(ret, c(aic = "AIC", bic = "BIC", logl = "logLik"))
  names(ret) <- gsub("pvalue", "p.value", names(ret))
  ret
}
tjmahr commented 9 years ago

Just chiming in to agree that glance would wrap fitmeasures, and note that tidy would wrap parameterestimates.

puterleat commented 6 years ago

Ive added a PR here which includes glance and tidy methods. Needs some thought to work out what augment should do.

DominiqueMakowski commented 6 years ago

Any advances on this?

alexpghayes commented 6 years ago

You can follow along at #233. Adding new tidiers is not the highest priority at the moment, so if you're hoping for new tidiers sooner rather than later the best way is to make a PR.

alexpghayes commented 6 years ago

Merged! Small changes likely to come to the column names in glance before the broom 0.5.0 release.

github-actions[bot] commented 3 years ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.