I am using a regression model for some data whose explanatory variables can only be 1,2,3,4 and 5. There are 5 explanatory variables and a dependent variable. For example,
set.seed(2)
x1 <- sample(rep(1:5,2))
x2 <- sample(rep(1:5,2))
x3 <- sample(rep(1:5,2))
x4 <- sample(rep(1:5,2))
x5 <- sample(rep(1:5,2))
y <- runif(10,-1,1)
model <- lm(y~x1 + x2 + x3 + x4 + x5)
I want to create a box plot showing the relationship between these dependent variables and the dependent variable. How can I do that in R?
I have managed to create a box plot using the code provided by @Ben. However, there are some points in the plot that I do not understand. Any idea what they are for? Here is the plot
If you want a boxplot, you’ll have to explain in much more detail what you want it to be based on. (That is, this is a programming site; you would need to say how you wanted the results of the regression to be translated into the parameters of a boxplot (central line, fences, whiskers, etc.).)
That said, you can use the
coefplotfunction in thearmpackage to draw a graphical summaryOr, on second thought, maybe the model is a red herring: maybe you just want to plot the data.