tuomaseerola / metaMER

meta-analysis of MER
MIT License
2 stars 0 forks source link

Parsing issue in parse_model_output #1

Closed cmndrsn closed 10 minutes ago

cmndrsn commented 2 weeks ago

Problems with parse_model_output:

(1) Fix name and value mismatch

# Issue -----------------------------------------------------------------

model_x <- 1:10
model_y <- 11:20

names(model_x) <- names(model_y) <- letters[1:10]

# Issue: converting to array acts on columns before rows
tmp <- rbind(model_x, model_y)
print(as.numeric(tmp))

(2) Ensure model_attributes value recycled properly. Needs to repeat attributes (library_id, model_id, feature_id, data_id, experiment_id) as many times as there are values in their matching array.

# Issue: increments model_id for each value.  -----------------------------

# example code:

results <- rbind(model_a = c('valence_mean' = .5, 'arousal_mean' = .8),
            model_b = c(.55, .82),
            model_c = c(.4, .6))

results_value <- as.numeric(t(results))

results_info <- data.frame(do.call('rbind', 
                   stringr::str_split(colnames(results), '_')))

colnames(results_info) <- c('dim', 'stat')

model_info <- rownames(results)

data.frame(model_id = model_info, 
           results_info, 
           value = results_value)
cmndrsn commented 2 weeks ago

Solution for Issue (1): Transpose array to avoid recycling issue.

# Initial solution: Transpose before conversion

model_x <- 1:10
model_y <- 11:20

names(model_x) <- names(model_y) <- letters[1:10]
tmp <- rbind(model_x, model_y)
# Example fix
print(as.numeric(t(tmp)))

Solution for Issue (2): Repeat model_id for each observation in array to avoid mismatch between model and summary

## Must repeat model id for as many values in arrays called within rbind (or bind_field)

results <- rbind(model_a = c('valence_mean' = .5, 'arousal_mean' = .8),
            model_b = c(.55, .82),
            model_c = c(.4, .6))

results_value <- as.numeric(t(results))

results_info <- data.frame(do.call('rbind', 
                   stringr::str_split(colnames(results), '_')))

colnames(results_info) <- c('dim', 'stat')

model_info <- rep(rownames(results), each = ncol(results))

data.frame(model_id = model_info, 
           results_info, 
           value = results_value)

Will need to check if this solution presents any additional issues

tuomaseerola commented 2 weeks ago

Looks good.