Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of dist="t(df)" when df.residual(fit) is not NULL #8

Closed
wviechtb opened this issue Feb 8, 2023 · 1 comment
Closed

Use of dist="t(df)" when df.residual(fit) is not NULL #8

wviechtb opened this issue Feb 8, 2023 · 1 comment

Comments

@wviechtb
Copy link

wviechtb commented Feb 8, 2023

Thanks for writing this package!

I tried this out in combination with the metafor package. Given that df.residual(res) is not NULL, according to the docs I would have expected sim() to simulate using dist="t(df)" but that is not what is happening. Am I misunderstanding something or is this a bug?

A reproducible example:

library(metafor)
library(clarify)

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### random-effects model
res <- rma(yi, vi, data=dat)
res

### average risk ratio with 95% CI
predict(res, transf=exp)

### use clarify
set.seed(1234)
sims <- sim(res)
sims # sampled from MVN
sav <- sim_apply(sims, function(coefs) c(RR = mean(exp(coefs))), verbose=FALSE)
summary(sav, null=c(`RR`=1))

# but according to the docs, it should use dist="t(df)" when df.residual(res) is not NULL
df.residual(res)
@ngreifer
Copy link
Collaborator

ngreifer commented Feb 8, 2023

Thank you for the comment and sorry about this confusion! The documentation is outdated and needs to be fixed. We no longer rely on df.residual() but rather on functions in insight that attempt to extract the right degrees of freedom, in particular insight::get_df(). insight has detected that the distribution of the model coefficients is normal, so that makes its way to clarify as well. Of course, you can supply your own df, and in practice, this will not make much of a difference. But I will definitely fix that documentation issue.

@ngreifer ngreifer closed this as completed May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants