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

Transpose output lpd of proj_linpred()? #107

Closed
fweber144 opened this issue Apr 6, 2021 · 3 comments
Closed

Transpose output lpd of proj_linpred()? #107

fweber144 opened this issue Apr 6, 2021 · 3 comments

Comments

@fweber144
Copy link
Collaborator

This reprex:

library(projpred)
library(rstanarm)
options(mc.cores = parallel::detectCores(logical = FALSE))
data("df_gaussian", package = "projpred")
mydat <- cbind("y" = df_gaussian$y, as.data.frame(df_gaussian$x))
myfit <- stan_glm(y ~ V1 + V2 + V3 + V4 + V5,
                  family = gaussian(),
                  data = mydat,
                  prior = hs(df = 1, global_scale = 0.01),
                  seed = 1140350788)

mylinpred <- proj_linpred(myfit,
                          solution_terms = c("V3", "V2"),
                          newdata = mydat[1:3, , drop = FALSE],
                          ndraws = 20)
str(mylinpred)

shows that (in the default case of integrated = FALSE) either output element mylinpred$pred or output element mylinpred$lpd should probably be transposed (I guess it should be element mylinpred$lpd to match the behavior of proj_predict() and also to match rstan's convention of having as many rows as posterior draws).

AlejandroCatalina added a commit that referenced this issue Apr 6, 2021
@AlejandroCatalina
Copy link
Collaborator

I have transposed both pred and lpd in proj_linpred.

@fweber144
Copy link
Collaborator Author

Only one of them needed to be transposed; as mentioned above:

either output element mylinpred$pred or output element mylinpred$lpd should probably be transposed (I guess it should be element mylinpred$lpd to match the behavior of proj_predict() and also to match rstan's convention of having as many rows as posterior draws).

@AlejandroCatalina
Copy link
Collaborator

AlejandroCatalina commented Apr 7, 2021 via email

AlejandroCatalina added a commit that referenced this issue Apr 7, 2021
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