-
Notifications
You must be signed in to change notification settings - Fork 0
/
match3_with_projection_plot.R
executable file
·40 lines (34 loc) · 1.34 KB
/
match3_with_projection_plot.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
#!/usr/bin/env Rscript
# Kyle Gorman <[email protected]>
#
# Matching experiment with heuristic4.
source("elp.R")
doMC::registerDoMC(max(1, parallel::detectCores() - 1))
d <- get_elp()
# Settings
halting_test = t_halt
method <- "heuristic3"
# Small set of covariates, for testing.
condition <- d$regularity
# covariates <- as.matrix(with(d, sbtlx.freq))
# Medium set of covariates.
covariates <- with(d, cbind(sbtlx.freq, sbtlx.basefreq, sbtlx.pformbase))
# Big set of covariates, what I really want to match on.
#covariates <- with(d, cbind(sbtlx.freq, sbtlx.basefreq, sbtlx.pformbase,
# OLD, length.squared, n.syll))
# Matches on whatever method works, favoring preserving irregulars (of which
# there are many fewer).
is.in <- match_groups(
condition,
covariates,
halting_test,
method = method,
print_info = TRUE,
lookahead = 1,
max_removed_per_cond = c(irregular = 30),
max_removed_per_step = 100)
lda_projection <- ldamatch:::.create_projection_using_LDA(condition, covariates, exclude_center)
print(ggplot(lda_projection$d, aes(x = condition, y = projection, fill = is.in, color = is.in)) + geom_violin())
if (exclude_center)
print(calc_p_value(condition[lda_projection$d$center], covariates[lda_projection$d$center, , drop = FALSE], halting_test))
write.csv(d[is.in, ], paste0(method, ".csv"))