diff --git a/ccn2019.rev2.Rmd b/ccn2019.rev2.Rmd index eb989f4..e6051d9 100644 --- a/ccn2019.rev2.Rmd +++ b/ccn2019.rev2.Rmd @@ -143,16 +143,21 @@ # instead of adding a new column for each. NB2 <- NB %>% group_by(participant, condition, block) %>% - nest() %>% unnest(data) %>% mutate(n = ifelse(condition=='2-back',2,3)) %>% mutate(stimulus_type = with_lures(stimulus, stimulus_type, n)) %>% mutate(history = with_history(stimulus, window_size)) %>% - mutate(x_sl = with_skewness(history)) %>% - mutate(x_ul = with_lumpiness(history)) %>% - mutate(x_t = with_targets_ratio(stimulus_type, window_size)) %>% - mutate(x_l = with_lures_ratio(stimulus_type, window_size)) %>% - ungroup() + group_nest(.key='design_matrix') + +#FIXME update the following functions to accept and also generate tidy list-columns +#FIXME use map() and map_*() from purrr +NB2 <- NB2 %>% + mutate(x_sl = map(design_matrix, ~with_skewness(.x$history))) %>% + mutate(x_ul = map(design_matrix, ~with_lumpiness(.x$history))) %>% + mutate(x_t = map(design_matrix, ~with_targets_ratio(.x$stimulus_type, window_size))) %>% + mutate(x_l = map(design_matrix, ~with_lures_ratio(.x$stimulus_type, window_size))) + #%>% ungroup() %>% unnest() +#FIXME perform modelings within tidy list-columns and put result in "model.pca" column pca <- prcomp(~x_sl+x_ul+x_t+x_l, NB2, center = TRUE,scale. = TRUE, na.action=na.exclude) NB2 <- NB2 %>% mutate(pc1=pca$x[,'PC1'], pc2=pca$x[,'PC2']) diff --git a/ccn2019.rev2.Rmd b/ccn2019.rev2.Rmd index eb989f4..e6051d9 100644 --- a/ccn2019.rev2.Rmd +++ b/ccn2019.rev2.Rmd @@ -143,16 +143,21 @@ # instead of adding a new column for each. NB2 <- NB %>% group_by(participant, condition, block) %>% - nest() %>% unnest(data) %>% mutate(n = ifelse(condition=='2-back',2,3)) %>% mutate(stimulus_type = with_lures(stimulus, stimulus_type, n)) %>% mutate(history = with_history(stimulus, window_size)) %>% - mutate(x_sl = with_skewness(history)) %>% - mutate(x_ul = with_lumpiness(history)) %>% - mutate(x_t = with_targets_ratio(stimulus_type, window_size)) %>% - mutate(x_l = with_lures_ratio(stimulus_type, window_size)) %>% - ungroup() + group_nest(.key='design_matrix') + +#FIXME update the following functions to accept and also generate tidy list-columns +#FIXME use map() and map_*() from purrr +NB2 <- NB2 %>% + mutate(x_sl = map(design_matrix, ~with_skewness(.x$history))) %>% + mutate(x_ul = map(design_matrix, ~with_lumpiness(.x$history))) %>% + mutate(x_t = map(design_matrix, ~with_targets_ratio(.x$stimulus_type, window_size))) %>% + mutate(x_l = map(design_matrix, ~with_lures_ratio(.x$stimulus_type, window_size))) + #%>% ungroup() %>% unnest() +#FIXME perform modelings within tidy list-columns and put result in "model.pca" column pca <- prcomp(~x_sl+x_ul+x_t+x_l, NB2, center = TRUE,scale. = TRUE, na.action=na.exclude) NB2 <- NB2 %>% mutate(pc1=pca$x[,'PC1'], pc2=pca$x[,'PC2']) diff --git a/pls_playground.Rmd b/pls_playground.Rmd index c35feac..d4da99c 100644 --- a/pls_playground.Rmd +++ b/pls_playground.Rmd @@ -1,6 +1,8 @@ --- title: "PLS Training" output: html_notebook +editor_options: + chunk_output_type: console --- PLS: @@ -83,7 +85,7 @@ ``` -```{r plsrglm} +``` rm(list = ls()) library(plsRglm)