Skip to content
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

return plot-object as well for sjp.(g)lm when type = "vif" #38

Closed
ringprince opened this issue May 27, 2015 · 5 comments
Closed

return plot-object as well for sjp.(g)lm when type = "vif" #38

ringprince opened this issue May 27, 2015 · 5 comments

Comments

@ringprince
Copy link

According to the documentation, the return value of sjp.glm is a 'structure' with the ggplot object in the plot 'element'.

This is not true when the type is set to 'vif'. But the resulting ggplot object should be returned here as well.

@sjPlot sjPlot closed this as completed in 4d5f0cd May 28, 2015
@sjPlot
Copy link
Collaborator

sjPlot commented May 28, 2015

I have updated the documentation. Currently, model assumption functions should not return any plot, only the updated model with removed outliers. Perhaps this may be an option for future releases.

@ringprince
Copy link
Author

I am not sure I understand this comment. Removed outliers?

sjp.glm produces a plot -- even if type="vif". The plot just is not returned. I can confirm that the documentation is consistent with the behaviour now. But I'd much prefer to have the ggplot object returned to be able to further tweak it to my needs.

@sjPlot
Copy link
Collaborator

sjPlot commented May 29, 2015

If you refer to the very last plot of model-assumptions, this is the same one as sjp.glm(fit). type = "ma" first checks the model for outliers, and if there are any, they are being removed and an updated model w/o outliers is re-fitted. This updated glm-object is returned. Set showOriginalModelOnly to FALSE to see plots for both models, original and updated.

@ringprince
Copy link
Author

This is an example what should be possible, I'd say. And easy to achieve. Sorry, should have posted code right in the beginning:

 # prepare dichotomous dependent variable
y <- ifelse(swiss$Fertility < median(swiss$Fertility), 0, 1)

 # fit model
 fitOR <- glm(y ~ swiss$Education + swiss$Examination + swiss$Infant.Mortality + swiss$Catholic,
              family = binomial(link = "logit"))

 sjp.glm(fitOR, type="vif")$plot + theme_bw()

@sjPlot
Copy link
Collaborator

sjPlot commented May 29, 2015

Sorry for confusion, I was talking about type = "ma", not type = "vif" - my fault... Currently, you can get access to the plot only via last_plot() function from ggplot. I re-open this issue and may add the plot as return value as well to that function.

@sjPlot sjPlot reopened this May 29, 2015
@sjPlot sjPlot changed the title return value of sjp.glm when type = "vif" return plot-object as well for sjp.(g)lm when type = "vif" May 29, 2015
@sjPlot sjPlot closed this as completed in c4b4fcc Jun 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants