After running a few regression analyses in the previous exercises, we will now explore some options for reporting their results.
If necessary, load the data first….
library(dplyr)
library(haven)
allbus_2021_cda_3 <-
read_spss("./data/allbus_2021/ZA5280_v1-0-0.sav") %>%
mutate(
trust_parliament = as.numeric(pt03),
party = pv01,
political_orientation = as.numeric(pa01),
satisfaction_democracy = ifelse(as.numeric(ps03) <= 2, 1, 0)
)
## Converting atomic to factors. Please wait...
In addition to the parameters
package, which we have
already used in the previous exercises on regression analysis, this time
we also need the following packages: stargazer
,
report
, and broom
.
if (!require(stargazer)) install.packages("stargazer")
if (!require(report)) install.packages("report")
if (!require(broom)) install.packages("broom")
Before we can report anything, we, of course, first need to run a regression analysis (again)…
trust_parliament
) as the outcome and age
(age
), sex (sex
), German region
(eastwest
), and political orientation
(political_orientation
) as predictors. We are also
interested in an interaction effect of German region and political
orientation.
R
using *
. If you want to, you can have a look
at the results via summary()
.
base R
, print only the coefficients from the model.
base R
for
accessing variables in a dataframe to select the element we want from
the lm
object.
parameters
package for
printing model parameters here.
stargazer
package. We want the
output to be in plain text format.
stargazer
function.
broom
package for that.
R
can also help us out here as well.
Let’s use a function that produces some model language describing the
results of our regression model.
report
.