-
Notifications
You must be signed in to change notification settings - Fork 3
/
PalmerAndGough_and_Lucas.R
109 lines (80 loc) · 2.98 KB
/
PalmerAndGough_and_Lucas.R
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
# Tutorials:
#Link to R-tutorials for GORIC and GORICA:
# https://github.com/rebeccakuiper/Tutorials
#Links to R scripts for GORICA on several type of statistical models:
# - Structural equation modeling
# https://github.com/rebeccakuiper/GORICA_in_SEM
# This is material that belongs to the article on
# https://www.tandfonline.com/doi/full/10.1080/10705511.2020.1836967
# - cross-lagged panel model (CLPM)
# https://github.com/rebeccakuiper/GORICA_in_CLPM
# - meta-analysis
# https://github.com/rebeccakuiper/GORICA_on_MetaAn
# - CTmeta-analysis (meta-analysis for lagged effects models)
# https://github.com/rebeccakuiper/GORICA_on_CTmeta
##############################
# Install and load packages
## First, install the packages, if you have not done this already:
if (!require("restriktor")) install.packages("restriktor")
## Then, load the packages:
library(restriktor) # for the goric function
# If you want to use restriktor from github:
#if (!require("devtools")) install.packages("devtools")
#library(devtools)
#install_github("LeonardV/restriktor")
#library(restriktor) # for goric function
########################
# Example Palmer & Gough
# Data
PandG_data <- read.table("data/Data_PalmerAndGough.txt", header=TRUE)
PandG_data$group <- factor(PandG_data$group)
# NHST: pairwise testing
pairwise.t.test(PandG_data$Importance, PandG_data$group, p.adj = 'bonferroni')
# Fit object, also NHST
fit.PandG <- lm(Importance ~ group - 1, data = PandG_data)
#summary(fit.PandG) # NHST
# (Informative) hypotheses
H0 <- 'group1 = group2 = group3'
H1 <- 'group1 > group2 > group3'
# GORIC
set.seed(123) # Set seed value
goric.PandG <- goric(fit.PandG, hypotheses = list(H0 = H0, H1 = H1))
#goric.PandG$result[,1] <- c("H0","H1","Hu")
goric.PandG
#goric.PandG$result
#summary(goric.PandG)
goric.PandG$ratio.gw
#
# Most probably, H0 is not of interest, then do:
set.seed(123) # Set seed value
goric.PandG <- goric(fit.PandG, hypotheses = list(H1))
goric.PandG
#goric.PandG$result
#summary(goric.PandG)
# Example Lucas
# Data
Lucas_data <- read.table("data/Data_Lucas.txt", header=TRUE)
Lucas_data$group <- factor(Lucas_data$group)
# NHST: pairwise testing
pairwise.t.test(Lucas_data$Influence, Lucas_data$group,
p.adj = 'bonferroni')
# Fit object, also NHST
fit.Lucas <- lm(Influence ~ group - 1, data = Lucas_data)
#summary(fit.Lucas) # NHST
# (Informative) hypotheses
H1 <- 'group5 = group3 > group1 > group2, group3 > group4 > group2'
# GORIC
set.seed(123) # Set seed value
goric.Lucas <- goric(fit.Lucas,
hypotheses = list(H1), comparison = 'complement')
goric.Lucas
#goric.Lucas$result
#summary(goric.Lucas)
# GORICA
set.seed(123) # Set seed value
gorica.Lucas <- goric(fit.Lucas,
hypotheses = list(H1), comparison = 'complement',
type = 'gorica')
gorica.Lucas
#gorica.Lucas$result
#summary(gorica.Lucas)