0

I would get a coefplot only with part of independent variables. My regression equation is a fixed effects regression as follows:

aa1 <-glm(Eighty_Twenty ~ Market_Share_H+Market_Share_L+Purchase_Frequency_H+Purchase_Frequency_L+factor(product_group))
coefplot(aa1)

However, I do NOT want to plot coefficients of factor(product_group) variables since there are product groups. Instead, I would get a coefplot with only the coefficients of other variables. How can I do this?

Lkopo
  • 4,798
  • 8
  • 35
  • 60
user3768644
  • 35
  • 1
  • 5
  • 2
    It is good practice to give a working example - please see [this link](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) - so that the question and solution is useful for future users – user20650 Sep 13 '14 at 20:02

1 Answers1

1

From the help pages (see ?coefplot.default) you can select what predictors or coefficients that you want in your plot.

# some example data
df <- data.frame(Eighty_Twenty = rbinom(100,1,0.5),
                 Market_Share_H = runif(100),
                 Market_Share_L = runif(100),
                 Purchase_Frequency_H = rpois(100, 40),
                 Purchase_Frequency_L = rpois(100, 40),
                 product_group = sample(letters[1:3], 100, TRUE))

# model
aa1 <- glm(Eighty_Twenty ~ Market_Share_H+Market_Share_L +
                           Purchase_Frequency_H + Purchase_Frequency_L + 
                           factor(product_group), df, family="binomial")


library(coefplot)

# coefficient plot with the intercept
coefplot(aa1, coefficients=c("(Intercept)","Market_Share_H","Market_Share_L",  
                              "Purchase_Frequency_H","Purchase_Frequency_L"))

# coefficient plot specifying predictors (no intercept)
coefplot(aa1, predictors=c("Market_Share_H","Market_Share_L"  ,      
                             "Purchase_Frequency_H","Purchase_Frequency_L"))
user20650
  • 24,654
  • 5
  • 56
  • 91