Repository navigation
OneSampleMR 0.1.9 - #19
Merged
Merged
Conversation
Obtain starting values for the logmult link by solving the second stage estimating equations exactly with Newton-Raphson (new internal helper logmult_coef() in R/utils.R) instead of from a gamma regression with zero outcomes replaced by 0.001. Remove the itermax argument, which was not passed to the Nelder-Mead optimizer, so all links use the same gmm::gmm() call. Only warn about non-convergence when the GMM objective function is not essentially zero, since these models are exactly identified. Estimates now agree with ivtsps and ivtsri in the ivonesamplemr Stata package. Add regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New function
lsmm()fits the double logistic structural mean model (LSMM) of Vansteelandt and Goetghebeur (2003), which estimates a causal odds ratio, by two-step GMM with multiple instruments as described by Clarke et al. (2015). It hasprint()andsummary()methods, the summary includes the Hansen J-test of the overidentifying restrictions, and covariates are handled as inmsmm(). It is the same estimator as theivlsmmcommand in the Stata package ivonesamplemr, and its estimates agree withivlsmm.tsps()andtsri()withlink = "logmult"now converge to the solution of the estimating equations. Previously the GMM optimizer often stopped at its iteration limit, giving slightly inaccurate estimates and a non-convergence warning. The starting values are now obtained by solving the second stage estimating equations exactly by Newton-Raphson, rather than from a gamma regression with zero outcomes replaced by 0.001. The estimates now agree with the Stata commandsivtspsandivtsriin the ivonesamplemr package.tsps()andtsri()no longer give a spurious non-convergence warning when the optimizer has reached the minimum of the GMM objective function (which is 0 because these models are exactly identified).msmm()withestmethod = "gmm"or"gmmalt"now uses a tighter convergence tolerance for the Nelder-Mead optimizer (reltol = .Machine$double.eps,maxit = 1E4), so that the estimates converge to the minimum of the GMM objective function. Previously the default tolerance could stop the optimizer early, so estimates depended on the starting values and could differ in the second or third decimal place from the solution of the estimating equations. Estimates from exactly identified models now agree withivtools::ivglm()G-estimation and with Stata'sivpoisson gmm, multiplicative.The parameters in the output of
tsps()andtsri()are now labelled by stage and variable name. First stage parameters are prefixedstage1:, the second stage exposure and covariate parameters take their variable names (previously, e.g.,xhatxhatandxhatcovariatesfortsps()), and the first stage residual intsri()is labelledstage1:residuals(previouslyresres). The same labels are used when the user specifiest0, andtsps()andtsri()now give a clear error message ift0has the wrong length. The documentation oft0has been corrected.The print and summary methods for
tsps()andtsri()fits now only exponentiate the exposure parameter in the causal risk ratio or causal odds ratio table. Previously all the second stage parameters were exponentiated and presented as causal ratios, including the intercept, any covariates, and, fortsri(), the coefficient of the first stage residuals.msmm()now distinguishes covariates (variables included in both the exposure and instrument parts of the formula) from exposures. The causal risk ratio table (crrci) now only contains the exposures; previously it also reported the exponentiated covariate coefficients as causal risk ratios. The covariate adjusted model itself is unchanged, and is the same model as fitted by Stata'sivpoisson gmm, multiplicativewith exogenous covariates. The returned object has a newcovariateselement, the print methods list the covariates adjusted for and note thatE[Y(0)]is then estimated at covariate values of 0, and covariate adjustment is documented with an example in?msmm. Covariates with the"tsls"and"tslsalt"methods now give a clear error message.