-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSummative-template.Rmd
More file actions
111 lines (88 loc) · 4.2 KB
/
Copy pathSummative-template.Rmd
File metadata and controls
111 lines (88 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
title: "Interpreting Quantitative Findings Report"
author: '[Your student number here]'
date: "`r format(Sys.time(), '%d/%m/%y')`"
output: html_document
---
<!-- This is a suggested template to write the summative assignments. Feel free to make changes as appropriate according to the guidance. -->
```{r setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE, warning = FALSE, echo = FALSE)
source("R/01_setup.R", local = knitr::knit_global())
```
```{r preamble, include=FALSE}
# Load packages
library(tidyverse)
library(modelsummary)
library(broom)
# Read data
nilt <- readRDS("data/fullnilt_2012.rds")
# Subset with variables used in regression model
nilt_subset <- nilt |>
select(persinc2, rsex, religcat, orient, uninatid, tunionsa, rsuper, rage)
```
Word count: `r wordcountaddin::word_count("Summative-template.Rmd") - 14`.
<!-- Update the "- 14" in the line above to also take into account your bibliography. For example, if your bibliography is 184 characters then update the above to "- 198". -->
## Introduction
<!-- Word count: approx. 350 -->
<!-- Look at the model in 'Results and discussion' below. Based on this state a research question and a hypothesis. Remember a hypothesis needs at least two variables. -->
## Data and method
<!-- Word count: approx. 600 -->
<!-- In this section your goal is to demonstrate that you can describe data and that you understand research design and data collection. -->
## Results and discussion
<!-- Word count: approx. 1200 -->
<!-- In this section your goal is to demonstrate that you can interpret quantitative results. Additional credit is available if you are able to relate these findings to social science theories or if you can put the findings in context. -->
```{r regression model}
# This chunk will run the linear regression and create a table for the regression results.
# Run model
model <- lm(persinc2 ~ ., data = nilt_subset)
# Use broom for model fit statistics
options(modelsummary_get = "broom")
# Create function for formatting numeric values
f <- function(x) formatC(x, digits = 3, big.mark = ",", format = "f")
# Create formatter for F statistic
pF <- glance(model)$p.value[[1]]
starsF <- if (is.na(pF)) "" else if (pF < 0.001) "***" else if (pF < 0.01) "**" else if (pF < 0.05) "*" else ""
f_star_fmt <- function(x) sprintf("%.3f%s", x, starsF)
# Set names for coefficients
coef_names <- c(
"rsexFemale" = "Sex: Female (ref.: Male)",
"religcatProtestant" = "Religion: Protestant (ref.: Catholic)",
"religcatNo religion" = "Religion: No religion",
"orientI am gay or lesbian (homosexual)" = "Sexual Orientation: Homosexual (ref.: Heterosexual)",
"orientI am bi-sexual" = "Sexual Orientation: Bi-sexual",
"orientOther" = "Sexual Orientation: Other",
"uninatidNationalist" = "Constitutional View: Nationalist (ref.: Unionist)",
"uninatidNeither" = "Constitutional view: Neither",
"tunionsaNo" = "Trade union membership: No (ref.: Yes)",
"rsuperNo" = "Supervisor: No (ref.: Yes)",
"rage" = "Age"
)
# Set names and formatting for model fit statistics to use
gof_use <- list(
list("raw" = "nobs", "clean" = "Observations", "fmt" = 0),
list("raw" = "r.squared", "clean" = "R<sup>2</sup>", "fmt" = f),
list("raw" = "adj.r.squared", "clean" = "Adjusted R<sup>2</sup>", "fmt" = f),
list("raw" = "sigma", "clean" = "Residual Std. Error", "fmt" = f),
list("raw" = "statistic", "clean" = "F Statistic", "fmt" = f_star_fmt)
)
# Show regression results table
modelsummary(
list("Annual Personal Income (GBP)" = model),
title = "Regression results",
estimate = "{estimate}{stars}<br>({std.error})",
statistic = NULL,
stars = c("*" = 0.05, "**" = 0.01, "***" = 0.001),
fmt = f,
coef_rename = coef_names,
gof_map = gof_use,
notes = "* p < 0.05, ** p < 0.01, *** p < 0.001"
)
```
## Conclusion
<!-- Word count: approx. 350 -->
<!-- Clearly state your findings. Do the findings raise any questions for future research? -->
# Reflective Course Summary
<!-- Word count: approx. 500 -->
<!-- Critically reflect on the issues that were most relevant and pertinent to the process of your own learning in the labs. -->
# Bibliography
<!-- Include bibliography entries for both the Interpretive Quantitative Findings Report and Reflective Course Summary here. -->