This file contains hidden or 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(brms) | |
library(tidybayes) | |
n <- 1000 | |
lambda <- 2 | |
p <- 0.50 | |
x <- rpois(n, lambda) | |
y <- rbinom(n, x, p) |
This file contains hidden or 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
murdock_D <- function(x, pc = T) { | |
n <- length(x) | |
mr <- matrix(x, nrow = n, ncol = n) | |
mc <- matrix(x, nrow = n, ncol = n, byrow = T) | |
md <- abs(mr - mc) | |
td <- rowSums(md) | |
dpc <- td / sum(td) | |
if (pc) { | |
# percentages or D% | |
return(dpc) |
This file contains hidden or 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
# adapted from https://usethis.r-lib.org/ | |
library(usethis) | |
# Create a new package ------------------------------------------------- | |
path <- file.path(getwd(), "jatosR") | |
create_package(path) | |
# only needed since this session isn't interactive | |
proj_activate(path) | |
use_mit_license("Jiri Lukavsky") |
This file contains hidden or 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(motrack) | |
f1 <- function(time, moment) { | |
# base speed = 3, acceleration (increasing by) 1 deg/s^2 | |
3 + time | |
} | |
position <- tibble(object = 1:4, x = c(-7, 5, 7, -5), y = c(5, 7, -5, -7)) |
This file contains hidden or 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
# make the grid file | |
grid_size <- 900 | |
n_square <- 6 | |
ss <- 900 / n_square # square size | |
d <- array(0, c(grid_size, grid_size, 4)) | |
fillcolor <- c(235, 220, 36, 128) | |
for (i in 1:n_square) { |
This file contains hidden or 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
# When we calculate variance (SD) from single observation (one group), | |
# how good/bad estimate this can be of the underlying SD? | |
B <- 100 | |
n <- 6 | |
m <- 50 | |
s <- 15 | |
estim_sd <- numeric(B) | |
set.seed(1010) | |
for (i in 1:B) { |
This file contains hidden or 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: "Sample estimation for correlation coefficients" | |
author: "Jiri Lukavsky" | |
date: "12/20/2019" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) |
This file contains hidden or 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
# example of fitting psychophysic curve to data are from one subject | |
# data from Muller-Lyer illusion, subjects are supposed to compare stimulus to | |
# standard (length = 100) | |
# columns: | |
# - length - length of stimulus line | |
# - pp - proportion of saying "longer" | |
# - id | |
# - N - is 10 for each value of length | |
# - k - count of saying "longer" (k = pp * N) |
This file contains hidden or 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
# --------- RStudio ------------------- | |
# knit from CLI | |
rmarkdown::render("test.Rmd", "html_document") | |
# --------- data manipulation --------- | |
# wide-to-long = gather, long-to-wide = spread | |
wide %>% | |
gather(key = column_name_of_column_names, | |
value = column_name_of_column_data, | |
-allvariables, -whichwewant, -ineachrow) |
This file contains hidden or 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
# How to report effect size in Wilcoxon signed-rank test | |
# links | |
# [1] https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test | |
# [2] https://stats.stackexchange.com/questions/229760/wilcoxon-signed-rank-test-in-r/229761 | |
# [3] https://stats.stackexchange.com/questions/41620/output-of-one-tailed-wilcoxon-sign-rank-test-in-r | |
# [4] https://stats.stackexchange.com/questions/133077/effect-size-to-wilcoxon-signed-rank-test | |
# [5] Acion, L., Peterson, J. J., Temple, S., & Arndt, S. (2006). Probabilistic index: an intuitive non-parametric approach to measuring the size of treatment effects. Statistics in Medicine, 25(4), 591–602. https://doi.org/10.1002/sim.2256 | |
# How Wilcoxon signed-rank test works + what it reports |
NewerOlder