Skip to content

Commit

Permalink
permute typed
Browse files Browse the repository at this point in the history
  • Loading branch information
yjunechoe committed Jul 24, 2023
1 parent 7e964be commit a6733d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions inst/julia/05-permute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function guess_and_shuffle_as!(
df::DataFrame,
predictor_cols::Union{String, Vector{String}},
participant_col::String,
trial_col::Union{Missing, Integer},
trial_col::Union{Missing, Integer, String},
)
shuffle_type = guess_shuffle_as(df, predictor_cols, participant_col, trial_col)
shuffle_as!(df, predictor_cols, participant_col, trial_col, shuffle_type)
Expand All @@ -12,7 +12,7 @@ function guess_shuffle_as(
df::DataFrame,
predictor_cols::Union{String, Vector{String}},
participant_col::String,
trial_col::Union{Missing, Integer},
trial_col::Union{Missing, Integer, String},
)
subj_pred_pair = unique(df[!, vcat(participant_col, predictor_cols)])
unique_combinations = length(unique(df[!, participant_col])) == nrow(subj_pred_pair)
Expand All @@ -32,7 +32,7 @@ function shuffle_as!(
shuffle_type::String,
predictor_cols::Union{String, Vector{String}},
participant_col::String,
trial_col::Union{Missing, Integer},
trial_col::Union{Missing, Integer, String},
)
if shuffle_type == "between_participant"
subj_pred_pair = unique(df[!, vcat(participant_col, predictor_cols)])
Expand All @@ -53,9 +53,9 @@ end
function permute_by_predictor(
df::DataFrame,
shuffle_type::String,
predictor_cols::String,
predictor_cols::Union{String, Vector{String}},
participant_col::String,
trial_col::String,
trial_col::Union{Missing, Integer, String},
n::Integer,
)
_df = copy(df)
Expand Down
30 changes: 15 additions & 15 deletions inst/julia/06-permute_timewise_statistics.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
function permute_timewise_statistics(
formula,
data,
time,
family,
contrasts,
nsim,
participant_col,
trial_col,
term_groups,
predictors_subset,
statistic,
is_mem;
formula::FormulaTerm,
data::DataFrame,
time::String,
family::Distribution,
contrasts::Union{Nothing, Tuple},
nsim::Integer,
participant_col::String,
trial_col::Union{Missing, String},
term_groups::Tuple,
predictors_subset::Union{Nothing, Tuple},
statistic::String,
is_mem::Bool;
opts...,
)

Expand All @@ -19,11 +19,11 @@ function permute_timewise_statistics(
n_times = length(times)

predictors_exclude = ["(Intercept)"]
if length(predictors_subset) > 0
if isnothing(predictors_subset)
term_groups_est = filter(grp -> !all(in(predictors_exclude), grp.p), term_groups)
else
term_groups_est =
filter(grp -> any(in(predictors_subset), vcat(grp.p, grp.P)), term_groups)
else
term_groups_est = filter(grp -> !all(in(predictors_exclude), grp.p), term_groups)
end

nsims = nsim * length(term_groups_est)
Expand Down

0 comments on commit a6733d0

Please sign in to comment.