https://gitlab.inria.fr/lyao/visinmotion
Tip revision: dd99681039060e6dcec83a378405faa3bc4527d3 authored by lyao on 09 December 2023, 20:43:19 UTC
readme updated
readme updated
Tip revision: dd99681
4-Abs-and-True-error-by-percent.R
library(plyr)
library(dplyr)
library(MPDiR)
library(quickpsy)
library(fitdistrplus)
library(ggplot2)
library(tidyverse)
source("1-read-and-calculate_errors_time.R") # to read global values
source("CI-Functions-Bonferroni.R")
# set directory where script is
sourceDir <- dirname (rstudioapi::getActiveDocumentContext()$path)
defaultpath <- sourceDir
#remove(list = ls())
print(defaultpath)
setwd(defaultpath)
filename <- "results/aggregated_per_percentage.csv"
dataFile <- read.csv(filename)
aggregatedstable <-dataFile
if (exists ("all_percentage_CIs")) { rm(all_percentage_CIs) }
# calculate CIs for each percentage and vis speed
# tmp_data <- aggregatedstable [ which ((aggregatedstable$correct_answer == '18') &
# (aggregatedstable$speed_duration == '0-static')),]
#
# tmp_abs_error <- bootstrapMeanCI(tmp_data[,"mean_abs_error"])
# tmp = data.frame (correct_answer = '18', speed_duration = '0-static',
# mean_abs_error = tmp_abs_error[1],
# lowci_abs_error = tmp_abs_error[2],
# upci_abs_error = tmp_abs_error[3])
#
# if ( !exists("all_percentage_CIs") ){
# all_percentage_CIs <- tmp
# }else{
# all_percentage_CIs <- rbind(all_percentage_CIs,tmp)
# }
correct_answer_interest <- c(18,32,43,58,72,83)
for(per in correct_answer_interest)
for (vis in speed_duration_ms)
{
tmp_data <- aggregatedstable [ which ((aggregatedstable$correct_answer == per) &
(aggregatedstable$speed_duration == vis)),]
tmp_abs_error <- bootstrapMeanCI(tmp_data[,"mean_abs_error"])
tmp_true_error <- bootstrapMeanCI(tmp_data[,"mean_true_error"])
tmp = data.frame (correct_answer = per, speed_duration = vis,
mean_abs_error = tmp_abs_error[1],
lowci_abs_error = tmp_abs_error[2],
upci_abs_error = tmp_abs_error[3],
mean_true_error = tmp_true_error[1],
lowci_true_error = tmp_true_error[2],
upci_true_error = tmp_true_error[3])
if ( !exists("all_percentage_CIs") ){
all_percentage_CIs <- tmp
}else{
all_percentage_CIs <- rbind(all_percentage_CIs,tmp)
}
}
ggplot(all_percentage_CIs, aes(correct_answer, mean_abs_error, colour=speed_duration)) +
theme_bw()+
geom_line() +
geom_point() +
xlab('True percentage')+ ylab('Absolute Error')+
geom_linerange (aes(ymin=lowci_abs_error,ymax=upci_abs_error))
# geom_ribbon (aes(ymin=lowci_abs_error,ymax=upci_abs_error, fill = speed_duration),alpha = 0.3)
ggsave("plots/abs-errors-per-percentage.pdf",device = pdf, width=5, height=2)
ggplot(all_percentage_CIs, aes(correct_answer, mean_true_error, colour=speed_duration)) +
theme_bw()+
geom_line() +
geom_point() +
xlab('True percentage')+ ylab('Error')+
geom_linerange (aes(ymin=lowci_true_error,ymax=upci_true_error))
# geom_ribbon (aes(ymin=lowci_true_error,ymax=upci_true_error, fill = speed_duration),alpha = 0.3)
ggsave("plots/true-errors-per-percentage.pdf",device = pdf, width=5, height=2)
