Skip to content

Instantly share code, notes, and snippets.

View cyrilobolonsky's full-sized avatar

Cyril Obolonsky cyrilobolonsky

View GitHub Profile
@cyrilobolonsky
cyrilobolonsky / R Tutorials | Non-parametric Tests in R | #rstatistics
Created March 7, 2016 18:34
A #glfintech R turorial on statistics discussing hypothesis tests - parametric tests (z-test, t-test and ANOVA) and non-parametric tests (Mann-Whitney Test, Wilcoxon Rank-sum test, Wilcoxon Signed-rank Test, Kruskal Wallis Test).
#non-parametric tests in R
dengue.fewer <-c(3000,3200,3500,5068,5679,6200,6300,7020)
scrub.typhus<-c(4400,4500,5900,6839,7561,9047,12300,14000)
wilcox.test(dengue.fewer,scrub.typhus)
t.test(dengue.fewer,scrub.typhus,var.equal=T)
ttest.wilcox.examples <- function(x,y,z,k)
{
@cyrilobolonsky
cyrilobolonsky / R Tutorials | t-tests in R | #rstatistics
Created March 7, 2016 18:26
A #glfintech R turorial on statistics discussing hypothesis tests - parametric tests (z-test, t-test and ANOVA) and non-parametric tests (Mann-Whitney Test, Wilcoxon Rank-sum test, Wilcoxon Signed-rank Test, Kruskal Wallis Test).
#Conducting t-tests in R.
t.test(death_rt)
t.test(lifeexpf, lifeexpm)
t.test(lifeexpf, lifeexpm, var.equal=T)
t.test(lifeexpf, lifeexpm, paired=T)
#A function for creating random examples of t-tests
ttest.for.examination <- function(x,y,z,k)
{
subjects <- x
@cyrilobolonsky
cyrilobolonsky / R Tutorials | Visualising Hypothesis Tests in R | #rstatistics
Created March 7, 2016 18:15
A #glfintech R turorial on statistics discussing hypothesis tests - parametric tests (z-test, t-test and ANOVA) and non-parametric tests (Mann-Whitney Test, Wilcoxon Rank-sum test, Wilcoxon Signed-rank Test, Kruskal Wallis Test).
#Visualising Hypothesis Tests in R
#The red distribution is what you can expect to see if you plot repeated samples when the null hypothesis is true.
#You can recognize the Ho because it sounds like: "there was no difference", for instance: "The intervention did not affect the tumor marker."
#one tailed test
#rare in health sciences, more common in industrial process control
x=seq(50,140,length=200)
y1=dnorm(x,80, 10)
plot(x,y1,type='l',lwd=2,col='red')
y2=dnorm(x,110, 10)
@cyrilobolonsky
cyrilobolonsky / R Tutorials | Shapiro and Chi-squared Tests in R | #rstatistics
Last active March 7, 2016 18:13
A #glfintech R turorial on statistics discussing hypothesis tests - parametric tests (z-test, t-test and ANOVA) and non-parametric tests (Mann-Whitney Test, Wilcoxon Rank-sum test, Wilcoxon Signed-rank Test, Kruskal Wallis Test).
#Shapiro test shows whether the variables have a normal distribution
shapiro.test(lifeexpf)
shapiro.test(lifeexpm)
shapiro.test(birth_rt)
shapiro.test(death_rt)
shapiro.test(world[,2])
shapiro.test(world[,3])
shapiro.test(world[,5])
#We are alomst 100% sure that NONE of the variables follows a normal distribution.
@cyrilobolonsky
cyrilobolonsky / gist:c7b4473c05b430f53688
Created February 16, 2016 16:52
R Tutorials | Probability Distributions in R
#Probability Distributions in R
#BINOMINAL DISTRIBUTION
?dbinom
x <- 0:30
#binominal - density
plot(x, dbinom(x, 30, 0.5), type = "h")
#binominal - cumulative distribution function
plot(x, pbinom(x, 30, 0.5), type = "h")
@cyrilobolonsky
cyrilobolonsky / Principal Component Analysis (PCA) with R | FactoMineR
Created December 26, 2015 18:17
Global Fintech | Principal Component Analysis (PCA) with R | global-fintech.blogspot.com
#Principal Component Analysis with R using the library FacoMineR
#1)preliminaries
#adding the file to R
auto<-read.table("auto2004.csv", header=TRUE, sep=",")
#viewing the structure of the file
str(auto)
#attaching the file to the R memory
attach(auto)
#installing the library FactoMineR
library(FactoMineR)