# Loading a required package for Bayesian analysis
require(BayesMed)
## Loading required package: BayesMed
## Loading required package: R2jags
## Loading required package: rjags
## Loading required package: coda
## Linked to JAGS 4.1.0
## Loaded modules: basemod,bugs
##
## Attaching package: 'R2jags'
## The following object is masked from 'package:coda':
##
## traceplot
## Loading required package: QRM
## Warning: package 'QRM' was built under R version 3.2.4
## Loading required package: gsl
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 3.2.5
## Loading required package: mvtnorm
## Loading required package: numDeriv
## Warning: package 'numDeriv' was built under R version 3.2.5
## Loading required package: timeSeries
## Loading required package: timeDate
##
## Attaching package: 'QRM'
## The following object is masked from 'package:base':
##
## lbeta
## Loading required package: polspline
## Loading required package: MCMCpack
## Warning: package 'MCMCpack' was built under R version 3.2.5
## Loading required package: MASS
## ##
## ## Markov Chain Monte Carlo Package (MCMCpack)
## ## Copyright (C) 2003-2016 Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park
## ##
## ## Support provided by the U.S. National Science Foundation
## ## (Grants SES-0350646 and SES-0350613)
## ##
# Setting the working directory and loading the .csv data
setwd("/Users/ivanropovik/OneDrive/Statistics/Lakens Coursera/Replication Documentation/Processing and Analysis/Importable Data/")
data <- read.csv(file = "Data.csv", header = TRUE, sep = ";")
# Correlation test
with(na.omit(data), cor.test(year, rating, alternative = "greater"))
##
## Pearson's product-moment correlation
##
## data: year and rating
## t = 1.3637, df = 30, p-value = 0.09141
## alternative hypothesis: true correlation is greater than 0
## 95 percent confidence interval:
## -0.05890589 1.00000000
## sample estimates:
## cor
## 0.2415952
# Calculates BF01
1/with(na.omit(data),
jzs_cor(year, rating, alternative = "greater", n.iter = 3e5, n.burnin = 1.5e3))$BayesFactor
## module glm loaded
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 32
## Unobserved stochastic nodes: 4
## Total graph size: 130
##
## Initializing model
## [1] 1.668745