ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

Can no longer choose between pairwise and multinomial logistic regression for 3 level outcomes #10

Closed ahinton-mmc closed 4 years ago

ahinton-mmc commented 4 years ago

Hi Noah,

Another potential issue I'm running into today.

We have a 3 level outcome and I had been able to force weightit to still use a pairwise logistic regression (rather than multinomial logistic regression) by making sure mlogit was not installed, but now I don't seem to have that 'option'. I get an error that stops my code that says "Error in loadNamespace(name) : there is no package called ‘mlogit’".

Trying a reprex again, let's see if I get it right this time.

Is there a way to choose between the two methods?

Thanks!


library(tidyverse)
library(WeightIt)
library(Hmisc)
#> Loading required package: lattice
#> Loading required package: survival
#> Loading required package: Formula
#> 
#> Attaching package: 'Hmisc'
#> The following objects are masked from 'package:dplyr':
#> 
#>     src, summarize
#> The following objects are masked from 'package:base':
#> 
#>     format.pval, units
# We do NOT want mlogit installed. Make sure its uninstalled here.
remove.packages("mlogit")  
#> Removing package from '/home/ahinton@mmcf.mehealth.org/R/x86_64-pc-linux-gnu-library/3.5'
#> (as 'lib' is unspecified)
#> Error in find.package(pkgs, lib): there is no package called 'mlogit'

women <- women %>% 
  mutate(height_cat = Hmisc::cut2(height, g=3))

weightit(height ~ weight, data = women, estimand="ATE", method="ps", stabilize=T, include.obj = T)
#> A weightit object
#>  - method: "ps" (propensity score weighting)
#>  - number of obs.: 15
#>  - sampling weights: none
#>  - treatment: continuous
#>  - covariates: weight
weightit(height_cat ~ weight, data = women, estimand="ATE", method="ps", stabilize=T, include.obj = T)
#> Error in loadNamespace(name): there is no package called 'mlogit'

Created on 2020-01-03 by the reprex package (v0.2.1)

ngreifer commented 4 years ago

Thank for letting me know about this bug. I'll fix it shortly. You can always request pairwise logistic regressions by setting use.mlogit = FALSE, but I agree that there should be a better error message.

ahinton-mmc commented 4 years ago

Thank you! I didn’t know about the option. That solves my issue!

From: Noah Greifer notifications@github.com Sent: Friday, January 3, 2020 11:51 AM To: ngreifer/WeightIt WeightIt@noreply.github.com Cc: Alexandra C. Hinton AHinton@mmc.org; Author author@noreply.github.com Subject: Re: [ngreifer/WeightIt] Can no longer choose between pairwise and multinomial logistic regression for 3 level outcomes (#10)

This message originated outside of MaineHealth. Use caution when opening attachments, clicking links or responding to requests for information.

Thank for letting me know about this bug. I'll fix it shortly. You can always request pairwise logistic regressions by setting use.mlogit = FALSE, but I agree that there should be a better error message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ngreifer_WeightIt_issues_10-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DALXEKD7CZYMUT7Z2USNCJ33Q35UGTA5CNFSM4KCPMLGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIBR4AQ-23issuecomment-2D570629634&d=DwMCaQ&c=ST5Jxgx_zZ9nYuPWkSm01Luus8kzn0TCuX9tmQgnWms&r=__BxrAQqu05nqQiE9hB_rg&m=WzDXAZcM-vOyGJboZDEyrHfp9GEkqGJeklbVUU7MfBQ&s=Vxmb3_jPJN6eB7pdOS_0vZxEItFARWLnXinb4QxL6eU&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ALXEKDYWOB5YGAUHN3EXUYTQ35UGTANCNFSM4KCPMLGA&d=DwMCaQ&c=ST5Jxgx_zZ9nYuPWkSm01Luus8kzn0TCuX9tmQgnWms&r=__BxrAQqu05nqQiE9hB_rg&m=WzDXAZcM-vOyGJboZDEyrHfp9GEkqGJeklbVUU7MfBQ&s=Q82FsbHZmmkVnwXTvFc9kqlV3iLZdGMzDZepXBWUTZU&e=.

CONFIDENTIALITY NOTICE: This email message, including any attachments, is for the use of the intended recipient(s) only and may contain information that is privileged, confidential, and prohibited from unauthorized disclosure under applicable law. If you are not the intended recipient of this message, any dissemination, distribution, or copying of this message is strictly prohibited. If you received this message in error, please notify the sender by reply email and destroy all copies of the original message and attachments.