stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
388 stars 133 forks source link

Invalid $family member with stan_polr #183

Open rvlenth opened 7 years ago

rvlenth commented 7 years ago

In the documentation for stanreg objects, object$family is supposed to be of class "family"; however, the object returned by stan_polr puts a character string there.

Example

example(stan_polr)
# --- (output not shown, produces an object named 'fit') ---
fit$family
## [1] "probit"

I suggest that instead this should be binomial(link = "probit"). I realize that "binomial" isn't quite right, but it is in a sense right with regard to each ordinal cut point, and the classes of objects should be as documented.

Operating System:

First part of sessionInfo():

R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rstanarm_2.15.2  Rcpp_0.12.10     lsmeans_2.25-10  estimability_1.2 pscl_1.4.9      
[6] lattice_0.20-35  MASS_7.3-47 
rvlenth commented 7 years ago

Maybe even better to just leave it NULL

jgabry commented 7 years ago

@rvlenth Thanks for opening the issue. I agree that this is unfortunate and I think NULL is probably the best way to go. At this point it would be a bit of a pain to change it since we use the family element of a stanreg object internally in many places, but I think it's worth doing the next time we do some refactoring.