Giter VIP home page Giter VIP logo

interplot's People

Contributors

brentonk avatar fsolt avatar sammo3182 avatar syfyufei avatar xinyigua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

interplot's Issues

set.seed() in interplot() functions

In several places the package sets a seed in the interplot()function, e.g. here:

set.seed(324)

This is bad practice because you interfere with the user-set seed. Example:

set.seed(42)

data(mtcars)
m_cyl <- lm(mpg ~ wt * cyl, data = mtcars)
interplot(m = m_cyl, var1 = 'cyl', var2 = 'wt')

rnorm(1)

gives the same random number as

set.seed(43)

data(mtcars)
m_cyl <- lm(mpg ~ wt * cyl, data = mtcars)
interplot(m = m_cyl, var1 = 'cyl', var2 = 'wt')

rnorm(1)

which shouldn't be the case.

interplotting a glm object throws warnings

glm generates objects that have two classes: “glm” and “lm”. So R is complaining that we’re asking it to compare two things (on the left of the equation) with one thing (on the right of the equation)

Order of output columns

From Prof. Matthias Gehrke

the column names in the dataframe returned by interplot should be exchanged. First column should be name of var1, second column values_in_var2. Now it is name of var2 and values_in_var1.

`prePro` issue

From Guan Wang by email

I ran the example based on the mtcars dataset
provided in the R file (https://cran.r-project.org/web/packages/interplot/vignettes/interplot-vignette.html). The two variables in the interaction term are "wt (continuous)" and "vs (binary)". Below is the code:

library(interplot)

data(mtcars)

class(mtcars$vs);table(mtcars$vs)

m_cyl <- glm(am ~ wt * vs, data = mtcars,family = binomial(link = "logit"))
summary(m_cyl)

windows()
plot_1 <- interplot(m_cyl, var1 = "wt",var2 = "vs",
                       predPro = TRUE,
                       var2_vals = c(0,1))
plot_1

windows()
plot_2 <- interplot(m_cyl, var1 = "vs",var2 = "wt",
                    predPro = TRUE,
                    var2_vals = c(min(mtcars$wt),max(mtcars$wt)))
plot_2### 

Unknown error by package checking

@fsolt The package passed the check once, but producing the following errors in the recheck.
The file "'interplot-Ex.R" including the 'hello' function was created by the checking process.
No idea what happens here.

* checking examples ... ERROR
Running examples in 'interplot-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: hello
> ### Title: Hello, World!
> ### Aliases: hello
> 
> ### ** Examples
> 
> hello()
Error: could not find function "hello"
Execution halted
* DONE
Status: 1 ERROR, 2 WARNINGs

See
  'E:/MEGAsync/Dropbox/01_Instruction/Research/R packages/interplot.Rcheck/00check.log'
for details.

checking examples ... ERROR
Running examples in 'interplot-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: hello
> ### Title: Hello, World!
> ### Aliases: hello
> 
> ### ** Examples
> 
> hello()
Error: could not find function "hello"
Execution halted

checking for code/documentation mismatches ... WARNING
Functions or methods with usage in documentation object 'hello' but not in code:
  hello

CI printing suggestion and question

Dear @sammo3182,

Thanks for responding to my earlier question about the confidence interval of the difference between the conditions that is printed below the plot. I want to suggest to save this confidence interval as a numeric value in the interplot output. I needed these numbers for a large set of models, and i ended up extracting it from the string in interplot.model$label$caption, which is a bit clunky. Maybe there was a better way?

I also have a number of models using categorical variables. Currently, you don't print the ci's of the differences between the categories (well, there is a ci, but it's not correct). Currently in interplot_default.R lines 249-257 are commented out. I wonder about the problem here: is this way of calculating CI's of the difference wrong or is there another problem - like with plotting these CI's.

Best, Gijs

Error in data.matrix(fake_data) %*% t(data.matrix(m.sims@coef)) : non-conformable arguments

Really like this package! However, despite my attempts I cannot get the "var2_vals" to function as expected and continue to get the error:

Error in data.matrix(fake_data) %*% t(data.matrix(m.sims@coef)) :
non-conformable arguments

the code I am using is

p1 <- interplot(m = glm.int.red, var1 = "rts", var2 = "age", predPro = TRUE,
var2_vals = seq(10, 60, by=10) , sims=5000, ci=0.95)

p1

the glm with the interaction executes as desired...

glm.int.red <- glm(formula = cbind(surv, 1 - surv) ~ as + ds + es + fs + hs +
iss + rts + age + bp + as:es + as:hs + as:rts + as:bp + ds:fs +
ds:age + ds:bp + es:hs + es:rts + fs:iss + fs:age + hs:age +
iss:bp + age:rts, family = binomial(link = "logit"), data = trauma)

Please help as I would really like to plot these interactions...

plm support

This is really a great package! However, linear panel models from the plm package are up until now not supported, right? Is there a workaround to use the data of plm objects in interplot? Thank you for your efforts!

Plots included in the manuscript do not include any axes labels

In vignettes/interplot-vignette.Rmd, plots included in the manuscript do not include any axes labels raising concerns about the user friendliness of the implementation.

Here are the sample codes that need to add axes labels:
interplot(m = m_cyl, var1 = "cyl", var2 = "wt")
interplot(m = m_cyl, var1 = "wt", var2 = "cyl")
interplot(m = m_cyl, var1 = "wt", var2 = "cyl", ci = .9, point = T)

funs() was deprecated in dplyr 0.8.0.

Encountered an issue:
interplot(model1, var1 = "var1",
var2 = "var2",
predPro = TRUE,
var2_vals = c(0,1))

Warning message:
funs() was deprecated in dplyr 0.8.0.

Please use a list of either functions or lambdas:

Simple named list: list(mean = mean, median = median)

Auto named with tibble::lst(): tibble::lst(mean, median)

Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
The deprecated feature was likely used in the interplot package.

Custom variance-covariance matrix for coefficients?

First off, thanks for the great package! It's really useful, especially after including histograms to evaluate the data distribution of the interacting variable.

One quick thought: would it be possible to provide a custom variance-covariance matrix for the regression coefficients? This would be useful in implementing robust standard errors, for instance with the sandwich package or Frank Harrell's rmspackage. (I know, robust SEs have issues, but sometimes reviewers demand them...).

Anton Strezhnev's excellent interaction_plot_continuous() function provides, for instance, a varcov = option, which allows one to provide custom variance-covariance matrices.

Installation of github version fails in R 3.4.1 on Ubuntu

Attempting to install the github version of interplot I got the following error:

Downloading github repo twitter/BreakoutDetection@master
Error in system(full, intern = quiet, ignore.stderr = quiet, ...) : 
  error in running command

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS
...

Searching for this error, I found a workaround on RevolutionAnalytics/RRO#37:

To work around this issue, set options(unzip = 'internal') before calling install_github. (See #37 and r-lib/devtools#406 )

After running the following, the github installation works as expected.

options(unzip = 'internal')
devtools::install_github("sammo3182/inrerplot")

geeglm support

Thanks for the great tool! I'm planning to use this tool along with GEE model but it seems there is no support for that the moment. That would be a great feature to have!

The S3 methods defined are unclear

The methods defined are unclear given the code and its comments which has:

method for class 'data.frame' :

interplot.plot <- function(...)

method for class 'lm' and 'glm' :

interplot.default <- function(...)

The generic function method is also confusing and seems error prone / not compatible with the different classes and methods systems in R as well as class inheritance.

consider splitting factor code into its own function

I haven't studied it enough to be sure, but a quick glance looks like the code was repeated across all the subfunctions. Having the factor code in a separate function would both make it easier to further revise as well as keep the main code more legible.

Complex Survey Support

Hello,

I am running some glm models with a complex survey design data using the "survey" package. The resulting object is labeled a "svyglm" and the interplot function doesn't seem to be liking the object type. I'm curious if these models are not supported on purpose or if you plan on supporting them. Here is the error I receive when I try to plot the interaction

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘sim’ for signature ‘"svyglm"’
Thanks,
Daniel

Conditional effects over categories

Thank Dr. Rachel Bernhard to bring this issue to us. The idea is basically presenting conditional effects based on the same conditioning variables at different categories. It can be more user-friendly if there's a special argument for that.

conflict with dplyr

In addition: Warning message: replacing previous import ‘dplyr::combine’ by ‘gridExtra::combine’ when loading ‘dotwhisker’

`predPro` for S4 class

Issue about S4 class for predPro

library(lme4)
m1 <- glmer(vs ~ mpg * wt + (1 | cyl), mtcars, family=binomial(link="logit"))

library(interplot)

interplot(m1, var1 = "mpg",var2 = "wt", predPro = TRUE, var2_vals = c(1.513, 5.424))

Output:

Error: $ operator not defined for this S4 class

Extend to ivreg objects

Would it be possible to extend interplot to ivreg objects? I get an error when I try to run this due to the fact that arm::sim does not work with ivreg models. Extracting the second regression from the 2SLS and running the plot on that alone "works", but standard errors are misleading here. I can patch something together for my particular application but I think there might be more general interest in this functionality.

Question regarding conditioning marginal effects on values of other variables

In your vignette, you state that interplot "plots the changes in the coefficient of one variable in a two-way interaction term conditional on the value of the other included variable." In each example provided, only two variables are included as independent variables (or a single variable with a quadratic). How does your package accommodate multiple regression with more variables than those involved in the interaction(s) of interest? Particularly, at what values does the package condition 'controls' in computing marginal effects? Lastly, do the methods for nonlinear models account for the inherent interdependence among variables?

fitting interaction with factors

Interaction with factors will be automatically converted to interactions with binaries, but with different var2 name.

A potential solution: using caret::dummyVars to break the factor into dummies ahead and plot each dummy interaction in a facet.

documentation: revisions needed re multiple imputation

per Levi Littvay (via Twitter DM):

the interplot manual could use a bit of tweaking. mitools is not even mentioned until interplot.mlmmi. No word under interplot.lmmi. Then I was a shocked to find out that these are not even functions, all just part of the mitools command. And an example under each section (impute, run the model, draw) would really make everything more user friendly.

Loading the package gives

In vignettes/interplot-vignette.Rmd, if one could avoid loading all these packages ( ggplot2/abind/arm/MASS/Matrix/lme4) by moving some dependencies to imports.

custom color not possible with hist=T

Hi.
Thanks for the very useful package. I just tried to adjust the color. Without hist=T everything works fine.

m_cyl <- lm(mpg ~ wt * cyl, data = mtcars)

interplot(m = m_cyl, var1 = "cyl", var2 = "wt", color="green")

When adding histograms, coloring seems to be impossible...

interplot(m = m_cyl, var1 = "cyl", var2 = "wt", color="green", hist=T)

How can I color the line and still add histograms?
Thanks

How to remove printed max-min CI bottom-right corner?

Since recently the interplot function prints a confidence interval (numerically) in the bottom right corner of the interaction plot, e.g. CI(Max-Min): [number,number]. How do I remove this? Looking into the code the ci_diff value regulates this, but I don't know what value to give it to stop printing this CI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.