Andrew Kemp
2013-Sep-25 14:29 UTC
[R] error when using ps() function on categorical variables - re propensity score matching
Dear List, I am having difficulty running the ps() function when variables are stored as factors and was hoping someone could provide some advice on how to proceed. I am running propensity score matching as outlined in: Greg Ridgeway, Dan McCarey, Andrew Morral, Lane Burgette and Beth Ann Grin (May 3, 2013) Toolkit for Weighting and Analysis of Nonequivalent Groups: A tutorial for the twang package and have a question about using unordered categorical variables as a covariates. The tutorial indicates that: "There is no need to ? create indicator, or dummy coded, variables to represent categorical covariates, provided the categorical variables are stored as a factor or as ordered? " However, when I run the ps() function after converting categorical variables to factors using the factor() function, I return the following warning: "Warning in model.matrix(glm.object) * resid(glm.object, "working") : longer object length is not a multiple of shorter object length" and followed by an error: "Error in x$fpc$sampsize[i, , drop = FALSE] : (subscript) logical subscript too long" Interestingly, the code runs without warning or error when variables are not converted to factors. Thanks in advance! ANDREW H. KEMP, PhD Invited International Visiting Professor, University of S?o Paulo Associate Professor, University of Sydney
Apparently Analagous Threads
- twang - Toolkit for Weighting and Analysis of Nonequivalent Groups
- Propensity score modeling using machine learning methods. WAS: RE: LARS for generalized linear models
- selection bias adjustment via propensity score
- propensity score adjustment using R
- Propensity score and three treatments