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

Prediction for Bernoulli model with covariates seems incorrect #2

Open
jchiquet opened this issue Apr 29, 2021 · 4 comments
Open

Prediction for Bernoulli model with covariates seems incorrect #2

jchiquet opened this issue Apr 29, 2021 · 4 comments
Assignees

Comments

@jchiquet
Copy link
Contributor

jchiquet commented Apr 29, 2021

In reference to GrossSBM/sbm#3,

if the following couple of lines are correct,

Screenshot from 2021-04-29 13-50-49

Then it seems that the prediction function in the case of Bernoulli for LBM/SBM with covariates is unexact, isn't it ?

    B <- matrix(0, nrow(adj), ncol(adj))
    for (k in 1:length(covariates)) {
        B <- B + model_parameters[[Q]]$beta[k] * covariates[[k]]
    }
    if (membership_name == "LBM") {
        return(sigmo(memberships[[Q]]$Z1 %*% model_parameters[[Q]]$m %*% 
            t(memberships[[Q]]$Z2) + B))
    }
    else {
        return(sigmo(memberships[[Q]]$Z %*% model_parameters[[Q]]$m %*% 
            t(memberships[[Q]]$Z) + B))

It would be correct only of the Z are indicator matrices but they are posterior probabilities.

Am I missing something?

@jb-leger
Copy link
Owner

You are right. I will fix it. Thanks.

@jb-leger jb-leger self-assigned this Apr 29, 2021
@jchiquet
Copy link
Contributor Author

What an efficient, straight to the point answer!

@jb-leger
Copy link
Owner

I need some time to write a vectorized implementation. The problem is easy to understand, I wrote this with indicator matrices, and I didn't use my brain to obtain the prediction.

@jchiquet
Copy link
Contributor Author

Same problem on my side ;-) Especially since most of the time, at the end of the day, posterior probabilities are almost indicators...

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