Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Model-averaged estimates/intervals/distributions #771

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

Draft
strengejacke wants to merge 6 commits into main
base: main
Choose a base branch
Loading
from average_parameters

Conversation

@strengejacke
Copy link
Member

@strengejacke strengejacke commented Sep 5, 2022

cf #768

@strengejacke strengejacke marked this pull request as draft September 5, 2022 14:36
Copy link
Member Author

library(MATA)
library(parameters)
set.seed(0)
n = 20 # 'n' is assumed to be even
x1 = c(rep(0,n/2), rep(1,n/2)) # two groups: x1=0, and x1=1
x2 = rnorm(n, mean=10, sd=3)
y = rnorm(n, mean = 3*x1 + 0.1*x2) # data generation
x1 = factor(x1)
m1 = glm(y ~ x1) # using 'glm' provides AIC values.
m2 = glm(y ~ x1 + x2) # using 'lm' doesn't.
aic = c(m1$aic, m2$aic)
delta.aic = aic - min(aic)
model.weights = exp(-0.5*delta.aic) / sum(exp(-0.5*delta.aic))
residual.dfs = c(m1$df.residual, m2$df.residual)
p1 = predict(m1, se = TRUE, newdata = list(x1 = factor(0), x2 = 10.64), type = "link")
p2 = predict(m2, se = TRUE, newdata = list(x1 = factor(0), x2 = 10.64), type = "link")
theta.hats = c(p1$fit, p2$fit)
se.theta.hats = c(p1$se.fit, p2$se.fit)
# 95% MATA-Wald confidence interval for theta:
mata.wald(theta.hats, se.theta.hats, model.weights, mata.t = TRUE, residual.dfs = residual.dfs)
#> [1] 0.6196654 1.6516695
parameters:::averaged_parameters(m1, m2)
#> [1] 0.619622 1.651641

Created on 2022年09月05日 with reprex v2.0.2

Copy link
Member Author

@bwiernik implementation seems to work, but I'm not sure about the meaning of this function. It returns one estimate (in the above example currently only CIs)? What does this estimate represent?

Copy link

Codecov Report

Merging #771 (d44c8c7) into main (4e62652) will decrease coverage by 0.13%.
The diff coverage is 0.00%.

@@ Coverage Diff @@
## main #771 +/- ##
==========================================
- Coverage 52.99% 52.85% -0.14% 
==========================================
 Files 184 185 +1 
 Lines 12706 12738 +32 
==========================================
 Hits 6733 6733 
- Misses 5973 6005 +32 
Impacted Files Coverage Δ
R/averaged_parameters.R 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

bwiernik commented Sep 6, 2022

No, that's not right. It should be output with the same structure as the input vectors, averaged across models (eg, if 32 predictions from 2 models, then output should be 32 predictions, weighted across the two models). The MATA CIs for the 32 predictions would then be the values for each prediction that satisfy the critical value when averaged across models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /