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

Adding Weights #94

Open
ayushpatnaikgit opened this issue Jan 31, 2023 · 6 comments
Open

Adding Weights #94

ayushpatnaikgit opened this issue Jan 31, 2023 · 6 comments

Comments

@ayushpatnaikgit
Copy link
Member

How can we incorporate weights in the models? I want to do bootstrap to calculate the standard errors. The weights will be drawn from the multinomial distribution.

@sourish-cmi
Copy link
Collaborator

Can you please provide more detail about the models you are talking about? Currently, your question bit vague.

@ayushpatnaikgit
Copy link
Member Author

ayushpatnaikgit commented Jan 31, 2023

For any model.
Suppose I have a data frame with 3 columns, X, Y and weights.

df = DataFrame(X = 1:10, Y = 20:29, weights = 1:10)

In GLM.jl, I can do:

glm(@formula(Y ~ X), df, Normal(), IdentityLink(), wts=df.weights)

However, in CRRao, there is no option for wts. We'll need to add keyword arguments in CRRao that will be passed to GLM. Not sure how weights are considered for bayesian regression.

With bootstrap, what I want to do is:

using Distributions
replicates = 1000
dist_coef = [coef(glm(@formula(Y ~ X), df, Normal(), IdentityLink(), wts=df.weights .* rand(Multinomial(10, 10))))[1] for i in 1:replicates]
SE = std(dist_coef)

@sourish-cmi
Copy link
Collaborator

Yes, this feature can be added. GLM can be added quickly. Not sure how to handle the Bayesian model at this stage.

@sourish-cmi sourish-cmi changed the title Weights Adding Weights Jan 31, 2023
@ayushpatnaikgit
Copy link
Member Author

@ShouvikGhosh2048 can you allow fit to accept keyword arguments and then pass them to glm?

@ShouvikGhosh2048
Copy link
Collaborator

ShouvikGhosh2048 commented Feb 5, 2023

@ayushpatnaikgit
Should we allow arbitrary GLM keyword arguments?

Like this:

function fit(formula::FormulaTerm, data::DataFrame, modelClass::LinearRegression; kwargs...)
    model = lm(formula, data; kwargs...)
    return FrequentistRegression(:LinearRegression, model, formula)
end

Or just weights?

@ayushpatnaikgit
Copy link
Member Author

I think all kwargs like you have shown.

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

3 participants