-
Notifications
You must be signed in to change notification settings - Fork 0
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
initialize package with std_lm #2
Conversation
hi team, I add a basic framework for these analysis. In general, there will be a wrapper around the example
another possibility is to use some special functions in formula
iptw is not implemented yet, but should be similar. any ideas on the basic structure of the package? |
Hi Liming, For unconditional treatment effect of linear models, I suggest that we follow the recommendation in the FDA final guidance as quoted below.
Accordingly, for asymptotic standard error, it should provide:
For the input of std_lm, I suggest adding options for whether to 1) include treatment by covariate interactions in the regression model and 2) to account for stratified randomization for standard error estimation. To include those interactions, the simplest way is to fit separate regression models to each treatment group23. For the output of std_lm, I suggest including a vector of mean outcomes for all treatment groups and its estimated covariance matrix. The unconditional treatment effect for difference, ratio and odds ratio (for binary) can be obtain by another function with the output of std_lm, where its standard error can be computed using the delta method based on the estimated covariance matrix from std_lm. This can save the effort to develop separate function for different summary measures. We can follow a similar way to develop other estimators for unconditional treatment with a similar interface. For IPTW, we may consider to build based on the PWS package, which used the standard error estimator from the paper4 cited by the FDA final guidance. Look forward to hearing thoughts from you and other people. Footnotes
|
design/structure.Rmd
Outdated
|
||
# Implementation of standardization method for linear models | ||
|
||
The function name is `lm_std`, and the arguments are quite similar to `lm`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General idea: any possibility that we start from lm
result and then pipe this to a package function to get the covariate adjustment on top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be, but we lose some general consistency with other methods, like for standardization methods, we usually need to modify the data and create counter factual treatment and predict the results (sometimes also need to check if the data is of correct structure, like binary treatment) , like iptw we need provide weights obtained from the probability of treatment (other methods we don't include weights); in addition, when it comes to some new methods, then we still need a new interface of the regression. So to make other covariate adjustment methods consistent, it might be good to create some wrappers like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. makes sense. Then a consistent prefix with std_
will be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of the class of method coming first in the prefix if that works for others i.e.
- std_ <model/method>_ for standisation
- ipw _ <model/method> _ for inverse weighting ,etc.
This would follow the Morris et al. overview paper / classification of methods.
It feels intuitive, especially if using autocomplete i.e. searching within the method class...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any possibility that we start from
lm
result and then pipe this to a package function
I like this idea a lot. I'm just getting up-to-speed trying to understand the package's interface goals - apologies if I'm over-simplifying things to make this work. Would something like this be feasible:
data %>%
cov_adjust(by = "Species") %>%
lm(Sepal.Length ~ Species) # calls lm.covadj_spec with signature lm(<covadj_spec>, formula)
data %>%
cov_adjust(by = "Species", weights = <weights>) %>%
lm(Sepal.Length ~ Species)
I could see this being more comfortable if the basic parameters are reused across many methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm interesting idea @dgkf ! @clarkliming what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this sounds good but may lead to other confusions, like standardization methods is not actually a linear model, or standardized glm is not a glm; they focus on estimating the treatment effect. so using the lm
as generic can be a little inappropriate I think; but a similar grammar may be adopted to define the treatment variable (anyway, the treatment effect is the key)
Hi @xinzhn, there are some updates to the current design, following your suggestions
@bailliem the namings are updated and in another branch the |
close #1
here to illustrate the package structure,
std_lm
is included here; this is actually the same aslm
but with robust covariance matrix (withsummary
the result is printed to the console)this PR is not completed yet but provide a framework of how collaboration should happen