This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ForceData=autorec(duration, strikeThreshold, rewardThreshold) | |
%% DISCRIPTION | |
% This program automatically records foce data by detecting rising phase of | |
% the voltage change and it produce digital output whether the peak of the | |
% voltage above a threshold. The condition of output can be customized. | |
%% HOW TO USE | |
% The termination of this program is tricky. Please press "Ctrl - c" to | |
% quit the program and after that, command "daqreset" in the MATLAB prompt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatted_data = format2txt() | |
%% | |
if ismac == 1 | |
file_names = ls(); | |
elseif ispc == 1 | |
file_names = char(mat2str(ls())); | |
end | |
data_dir = regexp(file_names, '[0-9]*-[0-9]*\.[0-9]*', 'match'); | |
data_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## functions for statistical analysis and data visualizations in the paper, | |
## The paper's title: Motor control of ultrafast, ballistic movements (by K. Kagaya and S. N. Patek) | |
## This script is written by Katsushi Kagaya (k.kagaya@me.com) | |
## Gist URL: https://gist.github.com/kagaya/cbafe0a332e6d6766168 | |
## to load libraries | |
library(ggplot2) # for plotting data and model prediction | |
library(mgcv) # for generalized addive modeling (GAM fitting) | |
library(plyr) # for data manipulation | |
library(nlme) # for linear mixed effects modeling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## functions for 'mdf' files which stores digitized kinematic data from MTrackJ | |
## The paper's title: Motor control of ultrafast, ballistic movements (by K. Kagaya and S. N. Patek) | |
## This script is written by Katsushi Kagaya (k.kagaya@me.com) | |
## Gist URL: https://gist.github.com/kagaya/540596f6d1191c157cb7 | |
library(ggplot2) | |
library(plyr) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## functions for physiological data analyses in the paper, | |
## The paper's title: Motor control of ultrafast, ballistic movements (by K. Kagaya and S. N. Patek) | |
## written by Katsushi Kagaya (k.kagaya@me.com) | |
## Gist URL: https://gist.github.com/kagaya/36145a370a1da0f4ba0d | |
## to load libraries necessary for the current script | |
library(ggplot2) | |
library(plyr) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(forcats) | |
library(rstan) | |
library(shinystan) | |
waic <- function(log_likelihood) { | |
# from https://gist.github.com/MatsuuraKentaro/3f6ae5863e700f5039c19e36a9bdf646 | |
training_error <- - mean(log(colMeans(exp(log_likelihood)))) | |
functional_variance_div_N <- mean(colMeans(log_likelihood^2) - colMeans(log_likelihood)^2) | |
waic <- training_error + functional_variance_div_N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(ggrepel) | |
library(rstan) | |
rstan::expose_stan_functions("my_stan_functions.stan") # https://gist.github.com/kagaya/c726f16d82b80026bb1924b408a72b5c | |
source("utility.R") | |
###### choice ##### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
header-includes: | |
- \usepackage{setspace} | |
- \doublespacing | |
- \usepackage{lineno} | |
- \linenumbers | |
output: | |
pdf_document: default | |
html_document: | |
df_print: paged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Supplementary information for the paper 'Individual behavioral type captured by a Bayesian model comparison in cap making by sponge crab' | |
--- | |
This document is the supplementary information for the paper 'Individual behavioral type captured by a Bayesian framework in cap making by sponge crab' by Harada, Hayashi and Kagaya. | |
The basic conceptural framework for data analysis in the paper is a Bayesian framework based on the mathematical theory founded by Dr. Akaike and Dr. Watanabe (Watanabe, 'Mathematical Theory of Bayesian Statistics', 2018). The author of this document wrote an example of model selection by Widely Applicable Information Criterion (WAIC) using the data of 'artificial case' (http://rpubs.com/katzkagaya/460937). It may be of help for clarifying what the analysis of this document is doing, by using numerically generated 'artificial' data and several relatively simple hierarchical models. | |
In this study, we deal with the behavioral data of a 'natural case'. Therefore, we do not know |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rstan) | |
library(tidyverse) | |
library(shinystan) | |
rstan_options(auto_write = TRUE) | |
options(mc.cores = parallel::detectCores()) | |
# preprocessing | |
d <- read_csv(file='Dromiidae.csv') # https://gist.github.com/kagaya/0d309397300b7e8294fe53c44b6fc525 | |
d <- d %>% |
OlderNewer