library(akima)
library(compute.es)
library(doBy)
library(ez)
library(Hmisc)
library(knitr)
library(languageR)
library(lattice)
library(lme4)
library(multcomp)
library(nlme)
library(pastecs)
library(plyr)
library(psych)
library(Rcpp)
library(stringdist)
theme_set(theme_bw())
This function can be found on the website “Cookbook for R”.
http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/#Helper functions
It summarizes data, giving count, mean, standard deviation, standard error of the mean, and confidence intervals (default 95%).
data: a data frame.
measurevar: the name of a column that contains the variable to be summariezed
groupvars: a vector containing names of columns that contain grouping variables
na.rm: a boolean that indicates whether to ignore NA’s
conf.interval: the percent range of the confidence interval (default is 95%)
summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
conf.interval=.95, .drop=TRUE) {
require(plyr)
# New version of length which can handle NA's: if na.rm==T, don't count them
length2 <- function (x, na.rm=FALSE) {
if (na.rm) sum(!is.na(x))
else length(x)
}
# This does the summary. For each group's data frame, return a vector with
# N, mean, and sd
datac <- ddply(data, groupvars, .drop=.drop,
.fun = function(xx, col) {
c(N = length2(xx[[col]], na.rm=na.rm),
mean = mean (xx[[col]], na.rm=na.rm),
sd = sd (xx[[col]], na.rm=na.rm)
)
},
measurevar
)
# Rename the "mean" column
datac <- rename(datac, c("mean" = measurevar))
datac$se <- datac$sd / sqrt(datac$N) # Calculate standard error of the mean
# Confidence interval multiplier for standard error
# Calculate t-statistic for confidence interval:
# e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1
ciMult <- qt(conf.interval/2 + .5, datac$N-1)
datac$ci <- datac$se * ciMult
return(datac)
}
This function can be found on the website “Cookbook for R”.
http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/#Helper functions
It summarizes data, handling within-subjects variables by removing inter-subject variability. It will still work if there are no within-S variables. It gives count, un-normed mean, normed mean (with same between-group mean), standard deviation, standard error of the mean, and confidence intervals. If there are within-subject variables, calculate adjusted values using method from Morey (2008).
data: a data frame.
measurevar: the name of a column that contains the variable to be summarized
betweenvars: a vector containing names of columns that are between-subjects variables
withinvars: a vector containing names of columns that are within-subjects variables
idvar: the name of a column that identifies each subject (or matched subjects)
na.rm: a boolean that indicates whether to ignore NA’s
conf.interval: the percent range of the confidence interval (default is 95%)
summarySEwithin <- function(data=NULL, measurevar, betweenvars=NULL, withinvars=NULL,
idvar=NULL, na.rm=FALSE, conf.interval=.95, .drop=TRUE) {
# Ensure that the betweenvars and withinvars are factors
factorvars <- vapply(data[, c(betweenvars, withinvars), drop=FALSE],
FUN=is.factor, FUN.VALUE=logical(1))
if (!all(factorvars)) {
nonfactorvars <- names(factorvars)[!factorvars]
message("Automatically converting the following non-factors to factors: ",
paste(nonfactorvars, collapse = ", "))
data[nonfactorvars] <- lapply(data[nonfactorvars], factor)
}
# Get the means from the un-normed data
datac <- summarySE(data, measurevar, groupvars=c(betweenvars, withinvars),
na.rm=na.rm, conf.interval=conf.interval, .drop=.drop)
# Drop all the unused columns (these will be calculated with normed data)
datac$sd <- NULL
datac$se <- NULL
datac$ci <- NULL
# Norm each subject's data
ndata <- normDataWithin(data, idvar, measurevar, betweenvars, na.rm, .drop=.drop)
# This is the name of the new column
measurevar_n <- paste(measurevar, "_norm", sep="")
# Collapse the normed data - now we can treat between and within vars the same
ndatac <- summarySE(ndata, measurevar_n, groupvars=c(betweenvars, withinvars),
na.rm=na.rm, conf.interval=conf.interval, .drop=.drop)
# Apply correction from Morey (2008) to the standard error and confidence interval
# Get the product of the number of conditions of within-S variables
nWithinGroups <- prod(vapply(ndatac[,withinvars, drop=FALSE], FUN=nlevels,
FUN.VALUE=numeric(1)))
correctionFactor <- sqrt( nWithinGroups / (nWithinGroups-1) )
# Apply the correction factor
ndatac$sd <- ndatac$sd * correctionFactor
ndatac$se <- ndatac$se * correctionFactor
ndatac$ci <- ndatac$ci * correctionFactor
# Combine the un-normed means with the normed results
merge(datac, ndatac)
}
Norms the data within specified groups in a data frame; it normalizes each subject (identified by idvar) so that they have the same mean, within each group specified by betweenvars.
data: a data frame
idvar: the name of a column that identifies each subject (or matched subjects)
measurevar: the name of a column that contains the variable to be summariezed
betweenvars: a vector containing names of columns that are between-subjects variables
na.rm: a boolean that indicates whether to ignore NA’s
normDataWithin <- function(data=NULL, idvar, measurevar, betweenvars=NULL,
na.rm=FALSE, .drop=TRUE) {
require(plyr)
# Measure var on left, idvar + between vars on right of formula.
data.subjMean <- ddply(data, c(idvar, betweenvars), .drop=.drop,
.fun = function(xx, col, na.rm) {
c(subjMean = mean(xx[,col], na.rm=na.rm))
},
measurevar,
na.rm
)
# Put the subject means with original data
data <- merge(data, data.subjMean)
# Get the normalized data in a new column
measureNormedVar <- paste(measurevar, "_norm", sep="")
data[,measureNormedVar] <- data[,measurevar] - data[,"subjMean"] +
mean(data[,measurevar], na.rm=na.rm)
# Remove this subject mean column
data$subjMean <- NULL
return(data)
}
This function outputs the centered values of an variable, which can be a numeric variable, a factor, or a data frame. It was taken from Florian Jaegers blog https://hlplab.wordpress.com/2009/04/27/centering-several-variables/.
From his blog:
-If the input is a numeric variable, the output is the centered variable.
-If the input is a factor, the output is a numeric variable with centered factor level values. That is, the factor’s levels are converted into numerical values in their inherent order (if not specified otherwise, R defaults to alphanumerical order). More specifically, this centers any binary factor so that the value below 0 will be the 1st level of the original factor, and the value above 0 will be the 2nd level.
-If the input is a data frame or matrix, the output is a new matrix of the same dimension and with the centered values and column names that correspond to the colnames() of the input preceded by “c” (e.g. “Variable1” will be “cVariable1”).
myCenter= function(x) {
if (is.numeric(x)) { return(x - mean(x, na.rm=T)) }
if (is.factor(x)) {
x= as.numeric(x)
return(x - mean(x, na.rm=T))
}
if (is.data.frame(x) || is.matrix(x)) {
m= matrix(nrow=nrow(x), ncol=ncol(x))
colnames(m)= paste("c", colnames(x), sep="")
for (i in 1:ncol(x)) {
m[,i]= myCenter(x[,i])
}
return(as.data.frame(m))
}
}
This function provides a wrapper around myCenter allowing you to center a specific list of variables from a dataframe. The input is a dataframe (x) and a list of the names of the variables which you wish to center (listfname). The output is a copy of the dataframe with a column (numeric) added for each of the centered variables with each one labelled with it’s previous name with “.ct” appended. For example, if x is a dataframe with columns “a” and “b” lizCenter(x, list(“a”, “b”)) will return a dataframe with two additional columns, a.ct and b.ct, which are numeric, centered codings of the corresponding variables.
lizCenter= function(x, listfname)
{
for (i in 1:length(listfname))
{
fname = as.character(listfname[i])
x[paste(fname,".ct", sep="")] = myCenter(x[fname])
}
return(x)
}
This function allows us to inspect particular coefficients from the output of an lme model by putting them in table.
x: the output returned when running lmer or glmer (i.e. an object of type lmerMod or glmerMod)
list: a list of the names of the coefficients to be extracted (e.g. c(“variable1”, “variable1:variable2”))
get_coeffs <- function(x,list){(as.data.frame(summary(x)$coefficients)[list,])}
This function is equivalent to the Dienes (2008) calculator which can be found here: http://www.lifesci.sussex.ac.uk/home/Zoltan_Dienes/inference/Bayes.htm.
The code was provided by Baguely and Kayne (2010) and can be found here: http://www.academia.edu/427288/Review_of_Understanding_psychology_as_a_science_An_introduction_to_scientific_and_statistical_inference
Bf<-function(sd, obtained, uniform, lower=0, upper=1, meanoftheory=0,sdtheory=1, tail=1){
area <- 0
if(identical(uniform, 1)){
theta <- lower
range <- upper - lower
incr <- range / 2000
for (A in -1000:1000){
theta <- theta + incr
dist_theta <- 1 / range
height <- dist_theta * dnorm(obtained, theta, sd)
area <- area + height * incr
}
}else
{theta <- meanoftheory - 5 * sdtheory
incr <- sdtheory / 200
for (A in -1000:1000){
theta <- theta + incr
dist_theta <- dnorm(theta, meanoftheory, sdtheory)
if(identical(tail, 1)){
if (theta <= 0){
dist_theta <- 0
} else {
dist_theta <- dist_theta * 2
}
}
height <- dist_theta * dnorm(obtained, theta, sd)
area <- area + height * incr
}
}
LikelihoodTheory <- area
Likelihoodnull <- dnorm(obtained, 0, sd)
BayesFactor <- LikelihoodTheory / Likelihoodnull
ret <- list("LikelihoodTheory" = LikelihoodTheory,"Likelihoodnull" = Likelihoodnull, "BayesFactor" = BayesFactor)
ret
}
This works with the Bf function above. It requires the same values as that function (i.e. the obtained mean and SE for the current sample, a value for the predicted mean, which is set to be sdtheory (with meanoftheory=0), and the current number of participants N). However, rather than returning a BF for the current sample, it works out what the BF would be for a range of different subject numbers (assuming that the SE scales with sqrt(N)).
Bf_powercalc<-function(sd, obtained, uniform, lower=0, upper=1, meanoftheory=0, sdtheory=1, tail=2, N, min, max)
{
x = c(0)
y = c(0)
# note: working out what the difference between N and df is (for the contrast between two groups, this is 2; for constraints where there is 4 groups this will be 3, etc.)
for(newN in min : max)
{
B = as.numeric(Bf(sd = sd*sqrt(N/newN), obtained, uniform, lower, upper, meanoftheory, sdtheory, tail)[3])
x= append(x,newN)
y= append(y,B)
output = cbind(x,y)
}
output = output[-1,]
return(output)
}
This works with the Bf function above. It requires the obtained mean and SE for the current sample and works out what the BF would be for a range of predicted means (which are set to be sdtheoryrange (with meanoftheory=0)).
Bf_range<-function(sd, obtained, meanoftheory=0, sdtheoryrange, tail=1)
{
x = c(0)
y = c(0)
for(sdi in sdtheoryrange)
{
B = as.numeric(Bf(sd, obtained, meanoftheory=0, uniform = 0, sdtheory=sdi, tail)[3])
x= append(x,sdi)
y= append(y,B)
output = cbind(x,y)
}
output = output[-1,]
colnames(output) = c("sdtheory", "BF")
return(output)
}
The dataframe english.test.data contains the data from English-speaking children’s test performance (exp.1).
english.test.data <- read.csv("English_test_data_final.csv", header=TRUE)
#recode response column such that q responses = 1 (i.e., item endorsed as legal), p = 0 (i.e., item not endorsed as legal)
english.test.data$resp = revalue(english.test.data$response, c("q"= "1", "p"= "0"))
english.test.data$resp = as.numeric(as.character(english.test.data$resp))
The dataframe turkish.test.data contains the data from Turkish-speaking children’s test performance (exp.2).
turkish.test.data <- read.csv("Turkish_test_data.csv", header=TRUE)
#Recode response column such that q responses = 1 (i.e., item endorsed as legal), p = 0 (i.e., item not endorsed as legal)
turkish.test.data$resp = revalue(turkish.test.data$response, c("q"= "1", "p"= "0"))
turkish.test.data$resp = as.numeric(as.character(turkish.test.data$resp))
The dataframe AppendixA.data contains the data reported in Appendix A
appendixA.data = read.csv("Appendix_data.csv")
The dataframe Both.data contains the combined “English_test_data” and “Turkish_test_data” datasets (analysis reported in Appendix B)
Both.data = read.csv("Both_test_FINAL.csv")
#recode response column such that q responses = 1 (i.e., item endorsed as legal), p = 0 (i.e., item not endorsed as legal)
Both.data$resp = revalue(Both.data$response, c("q"= "1", "p"= "0"))
Both.data$resp = as.numeric(as.character(Both.data$resp))
The dataframe robustness.df contains the range of all possible betas (in log-odds space) that would correspond to a main effect of legality (legal > illegal endorsements). These are calculated for performance above 50% (chance).
robustness.df <- read.csv("robustness_region_final.csv", header=TRUE)
d= aggregate(cbind(TOWRE,WRAT_R,WRAT_S,accuracy)~pt_code,data=english.test.data,mean,na.action = na.pass)
#calculate average reading scores
mean(d$TOWRE, na.rm=TRUE)
## [1] 118.7895
sd(d$TOWRE, na.rm=TRUE)
## [1] 11.03038
mean(d$WRAT_R, na.rm=TRUE)
## [1] 118
sd(d$WRAT_R, na.rm=TRUE)
## [1] 9.785944
#calculate correlation matrix between literacy scores and %correct task performance
d= d[, c(2,3,4,5)]
rcorr(as.matrix(d))
## TOWRE WRAT_R WRAT_S accuracy
## TOWRE 1.00 0.84 0.85 0.11
## WRAT_R 0.84 1.00 0.72 -0.28
## WRAT_S 0.85 0.72 1.00 -0.15
## accuracy 0.11 -0.28 -0.15 1.00
##
## n
## TOWRE WRAT_R WRAT_S accuracy
## TOWRE 57 18 18 57
## WRAT_R 18 18 18 18
## WRAT_S 18 18 18 18
## accuracy 57 18 18 78
##
## P
## TOWRE WRAT_R WRAT_S accuracy
## TOWRE 0.0000 0.0000 0.4195
## WRAT_R 0.0000 0.0008 0.2553
## WRAT_S 0.0000 0.0008 0.5455
## accuracy 0.4195 0.2553 0.5455
#Aggregate data
aggregated.df = aggregate(resp ~ pt_code + language + legality + condition, Both.data, FUN=mean)
aggregated.df$legality =factor(aggregated.df$legality,levels(aggregated.df$legality)[c(2,1)])
#Calculate means: Proportion of endorsements for legal/illegal items across conditions, shown separately for English-speaking and Turkish-speaking children.
summarySEwithin(aggregated.df, measurevar="resp", betweenvars= "language", withinvars= "legality", idvar="pt_code", na.rm=FALSE, conf.interval=.95)
## language legality N resp resp_norm sd se ci
## 1 english illegal 78 0.5160256 0.4952620 0.1732838 0.01962052 0.03906945
## 2 english legal 78 0.5961538 0.5753902 0.1732838 0.01962052 0.03906945
## 3 turkish illegal 37 0.4391892 0.4829612 0.1538193 0.02528774 0.05128591
## 4 turkish legal 37 0.5439189 0.5876910 0.1538193 0.02528774 0.05128591
#Calculate means: Proportion of endorsements for legal/illegal items in the word-initial and word-final condition, shown separately for English-speaking and Turkish-speaking children.
summarySEwithin(aggregated.df, measurevar="resp", betweenvars=c("condition", "language"), withinvars= "legality", idvar="pt_code", na.rm=FALSE, conf.interval=.95)
## condition language legality N resp resp_norm sd
## 1 word-final english illegal 33 0.4924242 0.4917655 0.1932514
## 2 word-final english legal 33 0.5795455 0.5788867 0.1932514
## 3 word-final turkish illegal 18 0.5416667 0.4797705 0.1712006
## 4 word-final turkish legal 18 0.6527778 0.5908816 0.1712006
## 5 word-initial english illegal 45 0.5333333 0.4978261 0.1592329
## 6 word-initial english legal 45 0.6083333 0.5728261 0.1592329
## 7 word-initial turkish illegal 19 0.3421053 0.4859840 0.1399992
## 8 word-initial turkish legal 19 0.4407895 0.5846682 0.1399992
## se ci
## 1 0.03364076 0.06852398
## 2 0.03364076 0.06852398
## 3 0.04035237 0.08513605
## 4 0.04035237 0.08513605
## 5 0.02373704 0.04783886
## 6 0.02373704 0.04783886
## 7 0.03211802 0.06747746
## 8 0.03211802 0.06747746
#Subset dataframe to select children data only
d_kids = subset(appendixA.data, AgeGroup == "child")
#Center variables of interest using the lizCenter function
d_kids = lizCenter(d_kids, list("resp","Legality"))
#Run the lme model
lme1 <- glmer(resp ~ 1 + Legality.ct
+ (Legality.ct |Subject)
,data = d_kids, family=binomial)
kable(summary(lme1)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -0.265 | 0.086 | -3.092 | 0.002 |
| Legality.ct | 0.191 | 0.097 | 1.971 | 0.049 |
d = english.test.data
#Center variables of interest using the lizCenter function
d = lizCenter(d, list("resp","legality","condition"))
#Run the lme model: We inspect fixed-effect model coefficients for the following main effects/interactions: (i) main effect of legality across conditions (to assess if children discriminate between legal and illegal items across conditions), (ii) legality by condition interaction (to assess if learning from word-final context would be greater than learning from word-initial context) children would discriminate between legal and illegal items in each condition (main effect of legality in each condition)
lme1 <- glmer(resp ~ 1 +
+ (legality.ct * condition.ct)
+ (legality.ct |pt_code)
,data = d, family=binomial)
kable(summary(lme1)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.289 | 0.154 | 1.883 | 0.060 |
| legality.ct | 0.419 | 0.139 | 3.013 | 0.003 |
| condition.ct | 0.157 | 0.311 | 0.504 | 0.614 |
| legality.ct:condition.ct | -0.068 | 0.280 | -0.241 | 0.809 |
#Run the lme model with separate intercepts for the word-initial and word-final condition. We inspect fixed-effect model coefficients for the main effects of legality in each condition (to assess if children discriminate between legal and illegal items in each condition)
lme1b <- glmer(resp ~ 1 +
+ condition : legality.ct
+ condition.ct
+ (legality.ct |pt_code)
,data = d, family=binomial, control=glmerControl(optimizer = "bobyqa"))
kable(summary(lme1b)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.289 | 0.154 | 1.883 | 0.060 |
| condition.ct | 0.157 | 0.311 | 0.504 | 0.614 |
| conditionword-final:legality.ct | 0.458 | 0.214 | 2.133 | 0.033 |
| conditionword-initial:legality.ct | 0.390 | 0.181 | 2.151 | 0.031 |
meanBF = summary(lme1)$coefficients["legality.ct", "Estimate"]
seBF = summary(lme1)$coefficients["legality.ct", "Std. Error"]
h1mean = 0.19031 #(from Samara & Caravolas, 2014)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.693845
##
## $Likelihoodnull
## [1] 0.0307042
##
## $BayesFactor
## [1] 22.59773
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 3.646057
## [2,] 0.06899287 3.997559
## [3,] 0.07410797 4.447057
## [4,] 0.08004271 5.015461
## [5,] 0.08701138 5.754965
## [6,] 0.09531018 6.733360
## [7,] 0.10536052 8.066571
## [8,] 0.11778304 9.916615
## [9,] 0.13353139 12.512093
## [10,] 0.13353139 12.512093
## [11,] 0.14310084 14.183635
## [12,] 0.15415068 16.169731
## [13,] 0.15415068 16.169731
## [14,] 0.16705408 18.507244
## [15,] 0.18232156 21.221777
## [16,] 0.18232156 21.221777
## [17,] 0.20067070 24.307459
## [18,] 0.20763936 25.401672
## [19,] 0.22314355 27.674992
## [20,] 0.22314355 27.674992
## [21,] 0.22314355 27.674992
## [22,] 0.24116206 30.000148
## [23,] 0.25131443 31.146454
## [24,] 0.26236426 32.274089
## [25,] 0.28768207 34.366081
## [26,] 0.28768207 34.366081
## [27,] 0.28768207 34.366081
## [28,] 0.28768207 34.366081
## [29,] 0.31015493 35.709823
## [30,] 0.31845373 36.097377
## [31,] 0.33647224 36.759865
## [32,] 0.33647224 36.759865
## [33,] 0.35667494 37.245804
## [34,] 0.36772478 37.408266
## [35,] 0.37469345 37.485196
## [36,] 0.40546511 37.554275
## [37,] 0.40546511 37.554275
## [38,] 0.40546511 37.554275
## [39,] 0.40546511 37.554275
## [40,] 0.40546511 37.554275
## [41,] 0.44183275 37.218372
## [42,] 0.45198512 37.069856
## [43,] 0.47000363 36.749512
## [44,] 0.47000363 36.749512
## [45,] 0.48550782 36.431427
## [46,] 0.51082562 35.846779
## [47,] 0.51082562 35.846779
## [48,] 0.51082562 35.846779
## [49,] 0.53899650 35.123693
## [50,] 0.55961579 34.570786
## [51,] 0.55961579 34.570786
## [52,] 0.57536414 34.134022
## [53,] 0.58778666 33.780778
## [54,] 0.60613580 33.264146
## [55,] 0.61903921 32.892312
## [56,] 0.62860866 32.623283
## [57,] 0.69314718 30.798322
## [58,] 0.69314718 30.798322
## [59,] 0.69314718 30.798322
## [60,] 0.69314718 30.798322
## [61,] 0.69314718 30.798322
## [62,] 0.69314718 30.798322
## [63,] 0.69314718 30.798322
## [64,] 0.69314718 30.798322
## [65,] 0.76214005 28.941943
## [66,] 0.77318989 28.660270
## [67,] 0.78845736 28.271329
## [68,] 0.81093022 27.711248
## [69,] 0.82667857 27.327706
## [70,] 0.84729786 26.836769
## [71,] 0.84729786 26.836769
## [72,] 0.87546874 26.182624
## [73,] 0.91629073 25.286162
## [74,] 0.91629073 25.286162
## [75,] 0.91629073 25.286162
## [76,] 0.95551144 24.466263
## [77,] 0.98082925 23.955737
## [78,] 0.98082925 23.955737
## [79,] 1.01160091 23.367176
## [80,] 1.02961942 23.031594
## [81,] 1.09861229 21.816175
## [82,] 1.09861229 21.816175
## [83,] 1.09861229 21.816175
## [84,] 1.09861229 21.816175
## [85,] 1.09861229 21.816175
## [86,] 1.16315081 20.784653
## [87,] 1.17865500 20.548880
## [88,] 1.20397280 20.170091
## [89,] 1.25276297 19.481805
## [90,] 1.25276297 19.481805
## [91,] 1.29928298 18.864530
## [92,] 1.32175584 18.579101
## [93,] 1.38629436 17.806302
## [94,] 1.38629436 17.806302
## [95,] 1.38629436 17.806302
## [96,] 1.38629436 17.806302
## [97,] 1.46633707 16.923613
## [98,] 1.50407740 16.535470
## [99,] 1.54044504 16.173095
## [100,] 1.60943791 15.536303
## [101,] 1.60943791 15.536303
## [102,] 1.60943791 15.536303
## [103,] 1.67397643 14.979335
## [104,] 1.70474809 14.727046
## [105,] 1.79175947 14.052000
## [106,] 1.79175947 14.052000
## [107,] 1.87180218 13.488827
## [108,] 1.94591015 12.997899
## [109,] 1.94591015 12.997899
## [110,] 2.01490302 12.574310
## [111,] 2.07944154 12.201701
## [112,] 2.07944154 12.201701
## [113,] 2.19722458 11.578451
## [114,] 2.30258509 11.068533
## [115,] 2.39789527 10.643777
## [116,] 2.48490665 10.279049
## [117,] 2.56494936 9.971799
## [118,] 2.63905733 9.695742
## [119,] 2.70805020 9.459273
## [120,] 2.77258872 9.244746
meanBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Std. Error"]
h1mean = 0.19031 #(from Samara & Caravolas, 2014)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.9499128
##
## $Likelihoodnull
## [1] 0.2177427
##
## $BayesFactor
## [1] 4.362548
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas, tail=1)
## sdtheory BF
## [1,] 0.06453852 1.870577
## [2,] 0.06899287 1.945986
## [3,] 0.07410797 2.043897
## [4,] 0.08004271 2.156300
## [5,] 0.08701138 2.292540
## [6,] 0.09531018 2.455932
## [7,] 0.10536052 2.664449
## [8,] 0.11778304 2.931596
## [9,] 0.13353139 3.266875
## [10,] 0.13353139 3.266875
## [11,] 0.14310084 3.463829
## [12,] 0.15415068 3.690119
## [13,] 0.15415068 3.690119
## [14,] 0.16705408 3.943180
## [15,] 0.18232156 4.222494
## [16,] 0.18232156 4.222494
## [17,] 0.20067070 4.527759
## [18,] 0.20763936 4.627444
## [19,] 0.22314355 4.836014
## [20,] 0.22314355 4.836014
## [21,] 0.22314355 4.836014
## [22,] 0.24116206 5.043996
## [23,] 0.25131443 5.137186
## [24,] 0.26236426 5.233004
## [25,] 0.28768207 5.392488
## [26,] 0.28768207 5.392488
## [27,] 0.28768207 5.392488
## [28,] 0.28768207 5.392488
## [29,] 0.31015493 5.481246
## [30,] 0.31845373 5.503036
## [31,] 0.33647224 5.532458
## [32,] 0.33647224 5.532458
## [33,] 0.35667494 5.540000
## [34,] 0.36772478 5.530385
## [35,] 0.37469345 5.527706
## [36,] 0.40546511 5.473857
## [37,] 0.40546511 5.473857
## [38,] 0.40546511 5.473857
## [39,] 0.40546511 5.473857
## [40,] 0.40546511 5.473857
## [41,] 0.44183275 5.367076
## [42,] 0.45198512 5.336861
## [43,] 0.47000363 5.271732
## [44,] 0.47000363 5.271732
## [45,] 0.48550782 5.212022
## [46,] 0.51082562 5.109176
## [47,] 0.51082562 5.109176
## [48,] 0.51082562 5.109176
## [49,] 0.53899650 4.985659
## [50,] 0.55961579 4.900301
## [51,] 0.55961579 4.900301
## [52,] 0.57536414 4.831601
## [53,] 0.58778666 4.773363
## [54,] 0.60613580 4.697417
## [55,] 0.61903921 4.637516
## [56,] 0.62860866 4.600268
## [57,] 0.69314718 4.325603
## [58,] 0.69314718 4.325603
## [59,] 0.69314718 4.325603
## [60,] 0.69314718 4.325603
## [61,] 0.69314718 4.325603
## [62,] 0.69314718 4.325603
## [63,] 0.69314718 4.325603
## [64,] 0.69314718 4.325603
## [65,] 0.76214005 4.055078
## [66,] 0.77318989 4.017782
## [67,] 0.78845736 3.961691
## [68,] 0.81093022 3.881144
## [69,] 0.82667857 3.826125
## [70,] 0.84729786 3.755852
## [71,] 0.84729786 3.755852
## [72,] 0.87546874 3.659035
## [73,] 0.91629073 3.534853
## [74,] 0.91629073 3.534853
## [75,] 0.91629073 3.534853
## [76,] 0.95551144 3.418494
## [77,] 0.98082925 3.342762
## [78,] 0.98082925 3.342762
## [79,] 1.01160091 3.262954
## [80,] 1.02961942 3.215552
## [81,] 1.09861229 3.040747
## [82,] 1.09861229 3.040747
## [83,] 1.09861229 3.040747
## [84,] 1.09861229 3.040747
## [85,] 1.09861229 3.040747
## [86,] 1.16315081 2.899055
## [87,] 1.17865500 2.865923
## [88,] 1.20397280 2.809290
## [89,] 1.25276297 2.712695
## [90,] 1.25276297 2.712695
## [91,] 1.29928298 2.626146
## [92,] 1.32175584 2.586149
## [93,] 1.38629436 2.481360
## [94,] 1.38629436 2.481360
## [95,] 1.38629436 2.481360
## [96,] 1.38629436 2.481360
## [97,] 1.46633707 2.357866
## [98,] 1.50407740 2.303598
## [99,] 1.54044504 2.249519
## [100,] 1.60943791 2.163988
## [101,] 1.60943791 2.163988
## [102,] 1.60943791 2.163988
## [103,] 1.67397643 2.086217
## [104,] 1.70474809 2.051000
## [105,] 1.79175947 1.953369
## [106,] 1.79175947 1.953369
## [107,] 1.87180218 1.878248
## [108,] 1.94591015 1.806361
## [109,] 1.94591015 1.806361
## [110,] 2.01490302 1.747313
## [111,] 2.07944154 1.695382
## [112,] 2.07944154 1.695382
## [113,] 2.19722458 1.611976
## [114,] 2.30258509 1.540947
## [115,] 2.39789527 1.481794
## [116,] 2.48490665 1.427574
## [117,] 2.56494936 1.388232
## [118,] 2.63905733 1.346368
## [119,] 2.70805020 1.316887
## [120,] 2.77258872 1.287029
# word-final condition
meanBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Std. Error"]
h1mean = 0.19031 #(from Samara & Caravolas, 2014)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.7183456
##
## $Likelihoodnull
## [1] 0.1911292
##
## $BayesFactor
## [1] 3.75843
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 1.692236
## [2,] 0.06899287 1.749558
## [3,] 0.07410797 1.826023
## [4,] 0.08004271 1.912784
## [5,] 0.08701138 2.018126
## [6,] 0.09531018 2.144086
## [7,] 0.10536052 2.307217
## [8,] 0.11778304 2.519867
## [9,] 0.13353139 2.791798
## [10,] 0.13353139 2.791798
## [11,] 0.14310084 2.954922
## [12,] 0.15415068 3.147644
## [13,] 0.15415068 3.147644
## [14,] 0.16705408 3.369920
## [15,] 0.18232156 3.625365
## [16,] 0.18232156 3.625365
## [17,] 0.20067070 3.920064
## [18,] 0.20763936 4.020688
## [19,] 0.22314355 4.240266
## [20,] 0.22314355 4.240266
## [21,] 0.22314355 4.240266
## [22,] 0.24116206 4.474572
## [23,] 0.25131443 4.587914
## [24,] 0.26236426 4.709206
## [25,] 0.28768207 4.937326
## [26,] 0.28768207 4.937326
## [27,] 0.28768207 4.937326
## [28,] 0.28768207 4.937326
## [29,] 0.31015493 5.094227
## [30,] 0.31845373 5.141981
## [31,] 0.33647224 5.228080
## [32,] 0.33647224 5.228080
## [33,] 0.35667494 5.298254
## [34,] 0.36772478 5.321964
## [35,] 0.37469345 5.339851
## [36,] 0.40546511 5.371764
## [37,] 0.40546511 5.371764
## [38,] 0.40546511 5.371764
## [39,] 0.40546511 5.371764
## [40,] 0.40546511 5.371764
## [41,] 0.44183275 5.354152
## [42,] 0.45198512 5.346347
## [43,] 0.47000363 5.318349
## [44,] 0.47000363 5.318349
## [45,] 0.48550782 5.287953
## [46,] 0.51082562 5.227994
## [47,] 0.51082562 5.227994
## [48,] 0.51082562 5.227994
## [49,] 0.53899650 5.145471
## [50,] 0.55961579 5.086047
## [51,] 0.55961579 5.086047
## [52,] 0.57536414 5.035048
## [53,] 0.58778666 4.989580
## [54,] 0.60613580 4.930714
## [55,] 0.61903921 4.881640
## [56,] 0.62860866 4.851835
## [57,] 0.69314718 4.616130
## [58,] 0.69314718 4.616130
## [59,] 0.69314718 4.616130
## [60,] 0.69314718 4.616130
## [61,] 0.69314718 4.616130
## [62,] 0.69314718 4.616130
## [63,] 0.69314718 4.616130
## [64,] 0.69314718 4.616130
## [65,] 0.76214005 4.370517
## [66,] 0.77318989 4.335996
## [67,] 0.78845736 4.283281
## [68,] 0.81093022 4.206825
## [69,] 0.82667857 4.154111
## [70,] 0.84729786 4.086231
## [71,] 0.84729786 4.086231
## [72,] 0.87546874 3.991678
## [73,] 0.91629073 3.869046
## [74,] 0.91629073 3.869046
## [75,] 0.91629073 3.869046
## [76,] 0.95551144 3.752623
## [77,] 0.98082925 3.676199
## [78,] 0.98082925 3.676199
## [79,] 1.01160091 3.594985
## [80,] 1.02961942 3.546515
## [81,] 1.09861229 3.366316
## [82,] 1.09861229 3.366316
## [83,] 1.09861229 3.366316
## [84,] 1.09861229 3.366316
## [85,] 1.09861229 3.366316
## [86,] 1.16315081 3.218243
## [87,] 1.17865500 3.183445
## [88,] 1.20397280 3.124010
## [89,] 1.25276297 3.021792
## [90,] 1.25276297 3.021792
## [91,] 1.29928298 2.929699
## [92,] 1.32175584 2.886986
## [93,] 1.38629436 2.774333
## [94,] 1.38629436 2.774333
## [95,] 1.38629436 2.774333
## [96,] 1.38629436 2.774333
## [97,] 1.46633707 2.641113
## [98,] 1.50407740 2.582317
## [99,] 1.54044504 2.523926
## [100,] 1.60943791 2.430388
## [101,] 1.60943791 2.430388
## [102,] 1.60943791 2.430388
## [103,] 1.67397643 2.345357
## [104,] 1.70474809 2.306764
## [105,] 1.79175947 2.199898
## [106,] 1.79175947 2.199898
## [107,] 1.87180218 2.116696
## [108,] 1.94591015 2.037678
## [109,] 1.94591015 2.037678
## [110,] 2.01490302 1.972289
## [111,] 2.07944154 1.914679
## [112,] 2.07944154 1.914679
## [113,] 2.19722458 1.821506
## [114,] 2.30258509 1.742357
## [115,] 2.39789527 1.676321
## [116,] 2.48490665 1.616176
## [117,] 2.56494936 1.571665
## [118,] 2.63905733 1.525241
## [119,] 2.70805020 1.491698
## [120,] 2.77258872 1.458192
meanBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Estimate"]
meanBF = abs(meanBF)
seBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Std. Error"]
h1mean = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
h1mean = h1mean/2
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 1.213263
##
## $Likelihoodnull
## [1] 1.384273
##
## $BayesFactor
## [1] 0.8764628
d2 = turkish.test.data
#Center variables of interest using the lizCenter function
d2 = lizCenter(d2, list("resp","legality","condition"))
#Run the lme model: We inspect fixed-effect model coefficients for the following main effects/interactions: (i) main effect of legality across conditions (to assess if children discriminate between legal and illegal items across conditions), (ii) legality by condition interaction (to assess if learning from word-final context would be greater than learning from word-initial context) children would discriminate between legal and illegal items in each condition (main effect of legality in each condition)
lme1 <- glmer(resp ~ 1 +
+ (legality.ct * condition.ct)
+ (legality.ct |pt_code)
,data = d2, family=binomial)
kable(summary(lme1)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -0.015 | 0.214 | -0.070 | 0.945 |
| legality.ct | 0.546 | 0.189 | 2.886 | 0.004 |
| condition.ct | -1.087 | 0.430 | -2.528 | 0.011 |
| legality.ct:condition.ct | -0.042 | 0.389 | -0.109 | 0.913 |
#Run the lme model with separate intercepts for the word-initial and word-final condition. We inspect fixed-effect model coefficients for the main effects of legality in each condition (to assess if children discriminate between legal and illegal items in each condition)
lme1b <- glmer(resp ~ 1 +
+ condition : legality.ct
+ condition.ct
+ (legality.ct |pt_code)
,data = d2, family=binomial, control=glmerControl(optimizer = "bobyqa"))
kable(summary(lme1b)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -0.015 | 0.214 | -0.070 | 0.945 |
| condition.ct | -1.087 | 0.430 | -2.528 | 0.011 |
| conditionword-final:legality.ct | 0.568 | 0.278 | 2.044 | 0.041 |
| conditionword-initial:legality.ct | 0.525 | 0.265 | 1.980 | 0.048 |
meanBF = summary(lme1)$coefficients["legality.ct", "Estimate"]
seBF = summary(lme1)$coefficients["legality.ct", "Std. Error"]
h1mean = 0.41858 #(from experiment with English-speaking children)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.8534754
##
## $Likelihoodnull
## [1] 0.03278918
##
## $BayesFactor
## [1] 26.02918
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 2.409933
## [2,] 0.06899287 2.566506
## [3,] 0.07410797 2.768018
## [4,] 0.08004271 3.015526
## [5,] 0.08701138 3.332318
## [6,] 0.09531018 3.743819
## [7,] 0.10536052 4.304205
## [8,] 0.11778304 5.088217
## [9,] 0.13353139 6.211886
## [10,] 0.13353139 6.211886
## [11,] 0.14310084 6.959018
## [12,] 0.15415068 7.883116
## [13,] 0.15415068 7.883116
## [14,] 0.16705408 9.027108
## [15,] 0.18232156 10.448048
## [16,] 0.18232156 10.448048
## [17,] 0.20067070 12.214173
## [18,] 0.20763936 12.884364
## [19,] 0.22314355 14.374164
## [20,] 0.22314355 14.374164
## [21,] 0.22314355 14.374164
## [22,] 0.24116206 16.061573
## [23,] 0.25131443 16.970013
## [24,] 0.26236426 17.929585
## [25,] 0.28768207 19.944931
## [26,] 0.28768207 19.944931
## [27,] 0.28768207 19.944931
## [28,] 0.28768207 19.944931
## [29,] 0.31015493 21.506181
## [30,] 0.31845373 22.025885
## [31,] 0.33647224 23.048457
## [32,] 0.33647224 23.048457
## [33,] 0.35667494 24.026624
## [34,] 0.36772478 24.485477
## [35,] 0.37469345 24.756262
## [36,] 0.40546511 25.717921
## [37,] 0.40546511 25.717921
## [38,] 0.40546511 25.717921
## [39,] 0.40546511 25.717921
## [40,] 0.40546511 25.717921
## [41,] 0.44183275 26.449349
## [42,] 0.45198512 26.592017
## [43,] 0.47000363 26.775984
## [44,] 0.47000363 26.775984
## [45,] 0.48550782 26.876746
## [46,] 0.51082562 26.942067
## [47,] 0.51082562 26.942067
## [48,] 0.51082562 26.942067
## [49,] 0.53899650 26.889342
## [50,] 0.55961579 26.791267
## [51,] 0.55961579 26.791267
## [52,] 0.57536414 26.681841
## [53,] 0.58778666 26.574880
## [54,] 0.60613580 26.403428
## [55,] 0.61903921 26.261530
## [56,] 0.62860866 26.156457
## [57,] 0.69314718 25.304007
## [58,] 0.69314718 25.304007
## [59,] 0.69314718 25.304007
## [60,] 0.69314718 25.304007
## [61,] 0.69314718 25.304007
## [62,] 0.69314718 25.304007
## [63,] 0.69314718 25.304007
## [64,] 0.69314718 25.304007
## [65,] 0.76214005 24.270121
## [66,] 0.77318989 24.102869
## [67,] 0.78845736 23.865097
## [68,] 0.81093022 23.513823
## [69,] 0.82667857 23.267545
## [70,] 0.84729786 22.945888
## [71,] 0.84729786 22.945888
## [72,] 0.87546874 22.505441
## [73,] 0.91629073 21.886602
## [74,] 0.91629073 21.886602
## [75,] 0.91629073 21.886602
## [76,] 0.95551144 21.302392
## [77,] 0.98082925 20.929901
## [78,] 0.98082925 20.929901
## [79,] 1.01160091 20.495903
## [80,] 1.02961942 20.244690
## [81,] 1.09861229 19.315967
## [82,] 1.09861229 19.315967
## [83,] 1.09861229 19.315967
## [84,] 1.09861229 19.315967
## [85,] 1.09861229 19.315967
## [86,] 1.16315081 18.508908
## [87,] 1.17865500 18.321770
## [88,] 1.20397280 18.018491
## [89,] 1.25276297 17.463315
## [90,] 1.25276297 17.463315
## [91,] 1.29928298 16.959571
## [92,] 1.32175584 16.724849
## [93,] 1.38629436 16.084576
## [94,] 1.38629436 16.084576
## [95,] 1.38629436 16.084576
## [96,] 1.38629436 16.084576
## [97,] 1.46633707 15.343268
## [98,] 1.50407740 15.014363
## [99,] 1.54044504 14.705165
## [100,] 1.60943791 14.159951
## [101,] 1.60943791 14.159951
## [102,] 1.60943791 14.159951
## [103,] 1.67397643 13.679096
## [104,] 1.70474809 13.460259
## [105,] 1.79175947 12.871212
## [106,] 1.79175947 12.871212
## [107,] 1.87180218 12.377493
## [108,] 1.94591015 11.943954
## [109,] 1.94591015 11.943954
## [110,] 2.01490302 11.568676
## [111,] 2.07944154 11.237374
## [112,] 2.07944154 11.237374
## [113,] 2.19722458 10.681256
## [114,] 2.30258509 10.223798
## [115,] 2.39789527 9.841367
## [116,] 2.48490665 9.511649
## [117,] 2.56494936 9.233939
## [118,] 2.63905733 8.983218
## [119,] 2.70805020 8.768775
## [120,] 2.77258872 8.573615
# word-initial condition
meanBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Std. Error"]
h1mean = 0.41858 #(from experiment with English-speaking children)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.874912
##
## $Likelihoodnull
## [1] 0.2117677
##
## $BayesFactor
## [1] 4.131471
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 1.476478
## [2,] 0.06899287 1.511885
## [3,] 0.07410797 1.562101
## [4,] 0.08004271 1.617011
## [5,] 0.08701138 1.683158
## [6,] 0.09531018 1.760139
## [7,] 0.10536052 1.861086
## [8,] 0.11778304 1.993565
## [9,] 0.13353139 2.160898
## [10,] 0.13353139 2.160898
## [11,] 0.14310084 2.260153
## [12,] 0.15415068 2.380020
## [13,] 0.15415068 2.380020
## [14,] 0.16705408 2.519831
## [15,] 0.18232156 2.683353
## [16,] 0.18232156 2.683353
## [17,] 0.20067070 2.878446
## [18,] 0.20763936 2.944867
## [19,] 0.22314355 3.096171
## [20,] 0.22314355 3.096171
## [21,] 0.22314355 3.096171
## [22,] 0.24116206 3.265197
## [23,] 0.25131443 3.348446
## [24,] 0.26236426 3.442324
## [25,] 0.28768207 3.627350
## [26,] 0.28768207 3.627350
## [27,] 0.28768207 3.627350
## [28,] 0.28768207 3.627350
## [29,] 0.31015493 3.766488
## [30,] 0.31845373 3.811910
## [31,] 0.33647224 3.899709
## [32,] 0.33647224 3.899709
## [33,] 0.35667494 3.981170
## [34,] 0.36772478 4.014519
## [35,] 0.37469345 4.039553
## [36,] 0.40546511 4.110907
## [37,] 0.40546511 4.110907
## [38,] 0.40546511 4.110907
## [39,] 0.40546511 4.110907
## [40,] 0.40546511 4.110907
## [41,] 0.44183275 4.151127
## [42,] 0.45198512 4.160752
## [43,] 0.47000363 4.164455
## [44,] 0.47000363 4.164455
## [45,] 0.48550782 4.161786
## [46,] 0.51082562 4.147275
## [47,] 0.51082562 4.147275
## [48,] 0.51082562 4.147275
## [49,] 0.53899650 4.114646
## [50,] 0.55961579 4.090812
## [51,] 0.55961579 4.090812
## [52,] 0.57536414 4.066303
## [53,] 0.58778666 4.041258
## [54,] 0.60613580 4.011734
## [55,] 0.61903921 3.982682
## [56,] 0.62860866 3.967390
## [57,] 0.69314718 3.822013
## [58,] 0.69314718 3.822013
## [59,] 0.69314718 3.822013
## [60,] 0.69314718 3.822013
## [61,] 0.69314718 3.822013
## [62,] 0.69314718 3.822013
## [63,] 0.69314718 3.822013
## [64,] 0.69314718 3.822013
## [65,] 0.76214005 3.658970
## [66,] 0.77318989 3.636432
## [67,] 0.78845736 3.599751
## [68,] 0.81093022 3.545829
## [69,] 0.82667857 3.508184
## [70,] 0.84729786 3.459179
## [71,] 0.84729786 3.459179
## [72,] 0.87546874 3.388936
## [73,] 0.91629073 3.298747
## [74,] 0.91629073 3.298747
## [75,] 0.91629073 3.298747
## [76,] 0.95551144 3.210693
## [77,] 0.98082925 3.151265
## [78,] 0.98082925 3.151265
## [79,] 1.01160091 3.089440
## [80,] 1.02961942 3.051722
## [81,] 1.09861229 2.909024
## [82,] 1.09861229 2.909024
## [83,] 1.09861229 2.909024
## [84,] 1.09861229 2.909024
## [85,] 1.09861229 2.909024
## [86,] 1.16315081 2.791459
## [87,] 1.17865500 2.763418
## [88,] 1.20397280 2.714585
## [89,] 1.25276297 2.631401
## [90,] 1.25276297 2.631401
## [91,] 1.29928298 2.555915
## [92,] 1.32175584 2.520738
## [93,] 1.38629436 2.428152
## [94,] 1.38629436 2.428152
## [95,] 1.38629436 2.428152
## [96,] 1.38629436 2.428152
## [97,] 1.46633707 2.316981
## [98,] 1.50407740 2.267637
## [99,] 1.54044504 2.217848
## [100,] 1.60943791 2.139394
## [101,] 1.60943791 2.139394
## [102,] 1.60943791 2.139394
## [103,] 1.67397643 2.067178
## [104,] 1.70474809 2.034302
## [105,] 1.79175947 1.942388
## [106,] 1.79175947 1.942388
## [107,] 1.87180218 1.871542
## [108,] 1.94591015 1.802937
## [109,] 1.94591015 1.802937
## [110,] 2.01490302 1.746464
## [111,] 2.07944154 1.696593
## [112,] 2.07944154 1.696593
## [113,] 2.19722458 1.616234
## [114,] 2.30258509 1.547312
## [115,] 2.39789527 1.489673
## [116,] 2.48490665 1.436575
## [117,] 2.56494936 1.398083
## [118,] 2.63905733 1.356878
## [119,] 2.70805020 1.327913
## [120,] 2.77258872 1.298465
# word-final condition
meanBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Std. Error"]
h1mean = 0.41858 #(from experiment with English-speaking children)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.8019208
##
## $Likelihoodnull
## [1] 0.1777403
##
## $BayesFactor
## [1] 4.511754
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 1.472597
## [2,] 0.06899287 1.508022
## [3,] 0.07410797 1.558347
## [4,] 0.08004271 1.613521
## [5,] 0.08701138 1.680185
## [6,] 0.09531018 1.758117
## [7,] 0.10536052 1.860778
## [8,] 0.11778304 1.996354
## [9,] 0.13353139 2.169401
## [10,] 0.13353139 2.169401
## [11,] 0.14310084 2.273216
## [12,] 0.15415068 2.399445
## [13,] 0.15415068 2.399445
## [14,] 0.16705408 2.548237
## [15,] 0.18232156 2.724585
## [16,] 0.18232156 2.724585
## [17,] 0.20067070 2.938189
## [18,] 0.20763936 3.012485
## [19,] 0.22314355 3.182840
## [20,] 0.22314355 3.182840
## [21,] 0.22314355 3.182840
## [22,] 0.24116206 3.376359
## [23,] 0.25131443 3.474342
## [24,] 0.26236426 3.584876
## [25,] 0.28768207 3.809799
## [26,] 0.28768207 3.809799
## [27,] 0.28768207 3.809799
## [28,] 0.28768207 3.809799
## [29,] 0.31015493 3.985362
## [30,] 0.31845373 4.044258
## [31,] 0.33647224 4.161050
## [32,] 0.33647224 4.161050
## [33,] 0.35667494 4.274177
## [34,] 0.36772478 4.324302
## [35,] 0.37469345 4.359681
## [36,] 0.40546511 4.474186
## [37,] 0.40546511 4.474186
## [38,] 0.40546511 4.474186
## [39,] 0.40546511 4.474186
## [40,] 0.40546511 4.474186
## [41,] 0.44183275 4.559359
## [42,] 0.45198512 4.580282
## [43,] 0.47000363 4.602676
## [44,] 0.47000363 4.602676
## [45,] 0.48550782 4.614707
## [46,] 0.51082562 4.621523
## [47,] 0.51082562 4.621523
## [48,] 0.51082562 4.621523
## [49,] 0.53899650 4.608911
## [50,] 0.55961579 4.597417
## [51,] 0.55961579 4.597417
## [52,] 0.57536414 4.581110
## [53,] 0.58778666 4.561830
## [54,] 0.60613580 4.539759
## [55,] 0.61903921 4.515232
## [56,] 0.62860866 4.502937
## [57,] 0.69314718 4.370800
## [58,] 0.69314718 4.370800
## [59,] 0.69314718 4.370800
## [60,] 0.69314718 4.370800
## [61,] 0.69314718 4.370800
## [62,] 0.69314718 4.370800
## [63,] 0.69314718 4.370800
## [64,] 0.69314718 4.370800
## [65,] 0.76214005 4.211321
## [66,] 0.77318989 4.188577
## [67,] 0.78845736 4.151316
## [68,] 0.81093022 4.095981
## [69,] 0.82667857 4.056988
## [70,] 0.84729786 4.005825
## [71,] 0.84729786 4.005825
## [72,] 0.87546874 3.932004
## [73,] 0.91629073 3.835570
## [74,] 0.91629073 3.835570
## [75,] 0.91629073 3.835570
## [76,] 0.95551144 3.740596
## [77,] 0.98082925 3.676335
## [78,] 0.98082925 3.676335
## [79,] 1.01160091 3.608337
## [80,] 1.02961942 3.566882
## [81,] 1.09861229 3.409304
## [82,] 1.09861229 3.409304
## [83,] 1.09861229 3.409304
## [84,] 1.09861229 3.409304
## [85,] 1.09861229 3.409304
## [86,] 1.16315081 3.277383
## [87,] 1.17865500 3.245873
## [88,] 1.20397280 3.191377
## [89,] 1.25276297 3.097333
## [90,] 1.25276297 3.097333
## [91,] 1.29928298 3.011616
## [92,] 1.32175584 2.971555
## [93,] 1.38629436 2.865209
## [94,] 1.38629436 2.865209
## [95,] 1.38629436 2.865209
## [96,] 1.38629436 2.865209
## [97,] 1.46633707 2.737601
## [98,] 1.50407740 2.680771
## [99,] 1.54044504 2.623934
## [100,] 1.60943791 2.532564
## [101,] 1.60943791 2.532564
## [102,] 1.60943791 2.532564
## [103,] 1.67397643 2.448805
## [104,] 1.70474809 2.410608
## [105,] 1.79175947 2.304264
## [106,] 1.79175947 2.304264
## [107,] 1.87180218 2.220922
## [108,] 1.94591015 2.141381
## [109,] 1.94591015 2.141381
## [110,] 2.01490302 2.075242
## [111,] 2.07944154 2.016756
## [112,] 2.07944154 2.016756
## [113,] 2.19722458 1.921666
## [114,] 2.30258509 1.840566
## [115,] 2.39789527 1.772650
## [116,] 2.48490665 1.710734
## [117,] 2.56494936 1.664569
## [118,] 2.63905733 1.616608
## [119,] 2.70805020 1.581638
## [120,] 2.77258872 1.546804
meanBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Estimate"]
meanBF = abs(meanBF)
seBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Std. Error"]
h1mean = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
h1mean = h1mean/2
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.86478
##
## $Likelihoodnull
## [1] 1.018473
##
## $BayesFactor
## [1] 0.8490947
#Calculate means: Proportion of endorsements for legal/illegal items across conditions, across exp1. and 2.
summarySEwithin(aggregated.df, measurevar="resp", withinvars= "legality", idvar="pt_code", na.rm=FALSE, conf.interval=.95)
## legality N resp resp_norm sd se ci
## 1 illegal 115 0.4913043 0.4913043 0.166793 0.01555352 0.03081141
## 2 legal 115 0.5793478 0.5793478 0.166793 0.01555352 0.03081141
#Calculate means: Proportion of endorsements for legal/illegal items in the word-initial and word-final condition, across exp.1 and 2
summarySEwithin(aggregated.df, measurevar="resp", betweenvars=c("condition"), withinvars= "legality", idvar="pt_code", na.rm=FALSE, conf.interval=.95)
## condition legality N resp resp_norm sd se
## 1 word-final illegal 51 0.5098039 0.4875320 0.1842114 0.02579475
## 2 word-final legal 51 0.6053922 0.5831202 0.1842114 0.02579475
## 3 word-initial illegal 64 0.4765625 0.4943105 0.1528651 0.01910814
## 4 word-initial legal 64 0.5585938 0.5763417 0.1528651 0.01910814
## ci
## 1 0.05181028
## 2 0.05181028
## 3 0.03818457
## 4 0.03818457
d3 = Both.data
#Center variables of interest using the lizCenter function
d3 = lizCenter(d3, list("resp","legality","condition"))
#Run the lme model: We inspect fixed-effect model coefficients for the following main effects/interactions: (i) main effect of legality across conditions (to assess if children discriminate between legal and illegal items across conditions), (ii) legality by condition interaction (to assess if learning from word-final context would be greater than learning from word-initial context) children would discriminate between legal and illegal items in each condition (main effect of legality in each condition)
lme1 <- glmer(resp ~ 1 +
+ (legality.ct * condition.ct)
+ (legality.ct |pt_code)
,data = d3, family=binomial)
kable(summary(lme1)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.193 | 0.129 | 1.498 | 0.134 |
| legality.ct | 0.458 | 0.110 | 4.153 | 0.000 |
| condition.ct | -0.238 | 0.259 | -0.917 | 0.359 |
| legality.ct:condition.ct | -0.080 | 0.222 | -0.362 | 0.717 |
#Run the lme model with separate intercepts for the word-initial and word-final condition. We inspect fixed-effect model coefficients for the main effects of legality in each condition (to assess if children discriminate between legal and illegal items in each condition)
lme1b <- glmer(resp ~ 1 +
+ condition : legality.ct
+ condition.ct
+ (legality.ct |pt_code)
,data = d3, family=binomial, control=glmerControl(optimizer = "bobyqa"))
kable(summary(lme1b)$coefficients,digits = 3)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.193 | 0.129 | 1.498 | 0.134 |
| condition.ct | -0.238 | 0.259 | -0.918 | 0.359 |
| conditionword-final:legality.ct | 0.503 | 0.167 | 3.004 | 0.003 |
| conditionword-initial:legality.ct | 0.423 | 0.146 | 2.892 | 0.004 |
meanBF = summary(lme1)$coefficients["legality.ct", "Estimate"]
seBF = summary(lme1)$coefficients["legality.ct", "Std. Error"]
h1mean = 0.19031 #(from Samara & Caravolas, 2014)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.4138601
##
## $Likelihoodnull
## [1] 0.0006501583
##
## $BayesFactor
## [1] 636.5529
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 15.25840
## [2,] 0.06899287 18.85670
## [3,] 0.07410797 23.95809
## [4,] 0.08004271 31.39135
## [5,] 0.08701138 42.58679
## [6,] 0.09531018 60.02234
## [7,] 0.10536052 88.11074
## [8,] 0.11778304 134.73002
## [9,] 0.13353139 213.74483
## [10,] 0.13353139 213.74483
## [11,] 0.14310084 272.15856
## [12,] 0.15415068 348.11228
## [13,] 0.15415068 348.11228
## [14,] 0.16705408 445.95097
## [15,] 0.18232156 569.94325
## [16,] 0.18232156 569.94325
## [17,] 0.20067070 723.08674
## [18,] 0.20763936 780.69272
## [19,] 0.22314355 904.98798
## [20,] 0.22314355 904.98798
## [21,] 0.22314355 904.98798
## [22,] 0.24116206 1039.22286
## [23,] 0.25131443 1108.76806
## [24,] 0.26236426 1178.95313
## [25,] 0.28768207 1317.20589
## [26,] 0.28768207 1317.20589
## [27,] 0.28768207 1317.20589
## [28,] 0.28768207 1317.20589
## [29,] 0.31015493 1414.11409
## [30,] 0.31845373 1444.13692
## [31,] 0.33647224 1499.48992
## [32,] 0.33647224 1499.48992
## [33,] 0.35667494 1547.04912
## [34,] 0.36772478 1567.29791
## [35,] 0.37469345 1578.18117
## [36,] 0.40546511 1610.93311
## [37,] 0.40546511 1610.93311
## [38,] 0.40546511 1610.93311
## [39,] 0.40546511 1610.93311
## [40,] 0.40546511 1610.93311
## [41,] 0.44183275 1623.81278
## [42,] 0.45198512 1623.52630
## [43,] 0.47000363 1619.66236
## [44,] 0.47000363 1619.66236
## [45,] 0.48550782 1613.39570
## [46,] 0.51082562 1598.43683
## [47,] 0.51082562 1598.43683
## [48,] 0.51082562 1598.43683
## [49,] 0.53899650 1576.48345
## [50,] 0.55961579 1557.80589
## [51,] 0.55961579 1557.80589
## [52,] 0.57536414 1542.41912
## [53,] 0.58778666 1529.73665
## [54,] 0.60613580 1510.32599
## [55,] 0.61903921 1496.28596
## [56,] 0.62860866 1485.72308
## [57,] 0.69314718 1412.67428
## [58,] 0.69314718 1412.67428
## [59,] 0.69314718 1412.67428
## [60,] 0.69314718 1412.67428
## [61,] 0.69314718 1412.67428
## [62,] 0.69314718 1412.67428
## [63,] 0.69314718 1412.67428
## [64,] 0.69314718 1412.67428
## [65,] 0.76214005 1334.87915
## [66,] 0.77318989 1322.68984
## [67,] 0.78845736 1306.00734
## [68,] 0.81093022 1281.83185
## [69,] 0.82667857 1265.18024
## [70,] 0.84729786 1243.76032
## [71,] 0.84729786 1243.76032
## [72,] 0.87546874 1215.22075
## [73,] 0.91629073 1175.41615
## [74,] 0.91629073 1175.41615
## [75,] 0.91629073 1175.41615
## [76,] 0.95551144 1138.90909
## [77,] 0.98082925 1116.23901
## [78,] 0.98082925 1116.23901
## [79,] 1.01160091 1089.62835
## [80,] 1.02961942 1074.51059
## [81,] 1.09861229 1019.68475
## [82,] 1.09861229 1019.68475
## [83,] 1.09861229 1019.68475
## [84,] 1.09861229 1019.68475
## [85,] 1.09861229 1019.68475
## [86,] 1.16315081 972.54982
## [87,] 1.17865500 961.78434
## [88,] 1.20397280 944.64348
## [89,] 1.25276297 913.10205
## [90,] 1.25276297 913.10205
## [91,] 1.29928298 884.74106
## [92,] 1.32175584 871.60460
## [93,] 1.38629436 835.79097
## [94,] 1.38629436 835.79097
## [95,] 1.38629436 835.79097
## [96,] 1.38629436 835.79097
## [97,] 1.46633707 794.97894
## [98,] 1.50407740 776.99788
## [99,] 1.54044504 760.37352
## [100,] 1.60943791 730.62007
## [101,] 1.60943791 730.62007
## [102,] 1.60943791 730.62007
## [103,] 1.67397643 704.71471
## [104,] 1.70474809 692.96870
## [105,] 1.79175947 661.68811
## [106,] 1.79175947 661.68811
## [107,] 1.87180218 635.22160
## [108,] 1.94591015 612.46645
## [109,] 1.94591015 612.46645
## [110,] 2.01490302 592.65741
## [111,] 2.07944154 575.21942
## [112,] 2.07944154 575.21942
## [113,] 2.19722458 545.84273
## [114,] 2.30258509 521.93472
## [115,] 2.39789527 502.00496
## [116,] 2.48490665 485.06498
## [117,] 2.56494936 470.44981
## [118,] 2.63905733 457.66148
## [119,] 2.70805020 446.36258
## [120,] 2.77258872 436.27564
# word-initial condition
meanBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-initial:legality.ct", "Std. Error"]
h1mean = 0.19031 #(from Samara & Caravolas, 2014)
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.6970695
##
## $Likelihoodnull
## [1] 0.04171845
##
## $BayesFactor
## [1] 16.7089
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 3.181020
## [2,] 0.06899287 3.450985
## [3,] 0.07410797 3.794859
## [4,] 0.08004271 4.223806
## [5,] 0.08701138 4.775394
## [6,] 0.09531018 5.495172
## [7,] 0.10536052 6.464995
## [8,] 0.11778304 7.795058
## [9,] 0.13353139 9.637930
## [10,] 0.13353139 9.637930
## [11,] 0.14310084 10.815058
## [12,] 0.15415068 12.209697
## [13,] 0.15415068 12.209697
## [14,] 0.16705408 13.846655
## [15,] 0.18232156 15.745241
## [16,] 0.18232156 15.745241
## [17,] 0.20067070 17.905721
## [18,] 0.20763936 18.671298
## [19,] 0.22314355 20.267287
## [20,] 0.22314355 20.267287
## [21,] 0.22314355 20.267287
## [22,] 0.24116206 21.906516
## [23,] 0.25131443 22.715710
## [24,] 0.26236426 23.516315
## [25,] 0.28768207 25.007317
## [26,] 0.28768207 25.007317
## [27,] 0.28768207 25.007317
## [28,] 0.28768207 25.007317
## [29,] 0.31015493 25.973044
## [30,] 0.31845373 26.253442
## [31,] 0.33647224 26.736037
## [32,] 0.33647224 26.736037
## [33,] 0.35667494 27.095130
## [34,] 0.36772478 27.216804
## [35,] 0.37469345 27.277142
## [36,] 0.40546511 27.344235
## [37,] 0.40546511 27.344235
## [38,] 0.40546511 27.344235
## [39,] 0.40546511 27.344235
## [40,] 0.40546511 27.344235
## [41,] 0.44183275 27.120457
## [42,] 0.45198512 27.019464
## [43,] 0.47000363 26.796672
## [44,] 0.47000363 26.796672
## [45,] 0.48550782 26.573659
## [46,] 0.51082562 26.161003
## [47,] 0.51082562 26.161003
## [48,] 0.51082562 26.161003
## [49,] 0.53899650 25.646349
## [50,] 0.55961579 25.253231
## [51,] 0.55961579 25.253231
## [52,] 0.57536414 24.941015
## [53,] 0.58778666 24.686948
## [54,] 0.60613580 24.317554
## [55,] 0.61903921 24.049362
## [56,] 0.62860866 23.857067
## [57,] 0.69314718 22.540408
## [58,] 0.69314718 22.540408
## [59,] 0.69314718 22.540408
## [60,] 0.69314718 22.540408
## [61,] 0.69314718 22.540408
## [62,] 0.69314718 22.540408
## [63,] 0.69314718 22.540408
## [64,] 0.69314718 22.540408
## [65,] 0.76214005 21.197188
## [66,] 0.77318989 20.994111
## [67,] 0.78845736 20.712040
## [68,] 0.81093022 20.305578
## [69,] 0.82667857 20.027057
## [70,] 0.84729786 19.670346
## [71,] 0.84729786 19.670346
## [72,] 0.87546874 19.193632
## [73,] 0.91629073 18.542332
## [74,] 0.91629073 18.542332
## [75,] 0.91629073 18.542332
## [76,] 0.95551144 17.945124
## [77,] 0.98082925 17.571936
## [78,] 0.98082925 17.571936
## [79,] 1.01160091 17.143817
## [80,] 1.02961942 16.898997
## [81,] 1.09861229 16.010656
## [82,] 1.09861229 16.010656
## [83,] 1.09861229 16.010656
## [84,] 1.09861229 16.010656
## [85,] 1.09861229 16.010656
## [86,] 1.16315081 15.258059
## [87,] 1.17865500 15.085714
## [88,] 1.20397280 14.807697
## [89,] 1.25276297 14.304292
## [90,] 1.25276297 14.304292
## [91,] 1.29928298 13.852637
## [92,] 1.32175584 13.643733
## [93,] 1.38629436 13.079022
## [94,] 1.38629436 13.079022
## [95,] 1.38629436 13.079022
## [96,] 1.38629436 13.079022
## [97,] 1.46633707 12.432493
## [98,] 1.50407740 12.148103
## [99,] 1.54044504 11.881477
## [100,] 1.60943791 11.415769
## [101,] 1.60943791 11.415769
## [102,] 1.60943791 11.415769
## [103,] 1.67397643 11.007396
## [104,] 1.70474809 10.822383
## [105,] 1.79175947 10.326187
## [106,] 1.79175947 10.326187
## [107,] 1.87180218 9.914070
## [108,] 1.94591015 9.552760
## [109,] 1.94591015 9.552760
## [110,] 2.01490302 9.241874
## [111,] 2.07944154 8.968366
## [112,] 2.07944154 8.968366
## [113,] 2.19722458 8.511862
## [114,] 2.30258509 8.137434
## [115,] 2.39789527 7.825495
## [116,] 2.48490665 7.556551
## [117,] 2.56494936 7.331920
## [118,] 2.63905733 7.128069
## [119,] 2.70805020 6.955405
## [120,] 2.77258872 6.797793
# word-final condition
meanBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
seBF = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Std. Error"]
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 0.4341038
##
## $Likelihoodnull
## [1] 0.0261637
##
## $BayesFactor
## [1] 16.59184
#robustness region for BF
Bf_range(seBF, meanBF, meanoftheory=0, sdtheory = robustness.df$betas)
## sdtheory BF
## [1,] 0.06453852 2.877711
## [2,] 0.06899287 3.106822
## [3,] 0.07410797 3.401017
## [4,] 0.08004271 3.769350
## [5,] 0.08701138 4.247204
## [6,] 0.09531018 4.878717
## [7,] 0.10536052 5.747596
## [8,] 0.11778304 6.975761
## [9,] 0.13353139 8.754147
## [10,] 0.13353139 8.754147
## [11,] 0.14310084 9.941365
## [12,] 0.15415068 11.403820
## [13,] 0.15415068 11.403820
## [14,] 0.16705408 13.203570
## [15,] 0.18232156 15.414616
## [16,] 0.18232156 15.414616
## [17,] 0.20067070 18.112841
## [18,] 0.20763936 19.123747
## [19,] 0.22314355 21.332256
## [20,] 0.22314355 21.332256
## [21,] 0.22314355 21.332256
## [22,] 0.24116206 23.770831
## [23,] 0.25131443 25.057355
## [24,] 0.26236426 26.389501
## [25,] 0.28768207 29.105106
## [26,] 0.28768207 29.105106
## [27,] 0.28768207 29.105106
## [28,] 0.28768207 29.105106
## [29,] 0.31015493 31.118025
## [30,] 0.31845373 31.767578
## [31,] 0.33647224 33.010430
## [32,] 0.33647224 33.010430
## [33,] 0.35667494 34.146598
## [34,] 0.36772478 34.657423
## [35,] 0.37469345 34.949906
## [36,] 0.40546511 35.920566
## [37,] 0.40546511 35.920566
## [38,] 0.40546511 35.920566
## [39,] 0.40546511 35.920566
## [40,] 0.40546511 35.920566
## [41,] 0.44183275 36.523449
## [42,] 0.45198512 36.610705
## [43,] 0.47000363 36.680688
## [44,] 0.47000363 36.680688
## [45,] 0.48550782 36.670400
## [46,] 0.51082562 36.535411
## [47,] 0.51082562 36.535411
## [48,] 0.51082562 36.535411
## [49,] 0.53899650 36.241399
## [50,] 0.55961579 35.959596
## [51,] 0.55961579 35.959596
## [52,] 0.57536414 35.707756
## [53,] 0.58778666 35.487895
## [54,] 0.60613580 35.149673
## [55,] 0.61903921 34.890986
## [56,] 0.62860866 34.699766
## [57,] 0.69314718 33.283523
## [58,] 0.69314718 33.283523
## [59,] 0.69314718 33.283523
## [60,] 0.69314718 33.283523
## [61,] 0.69314718 33.283523
## [62,] 0.69314718 33.283523
## [63,] 0.69314718 33.283523
## [64,] 0.69314718 33.283523
## [65,] 0.76214005 31.692302
## [66,] 0.77318989 31.440711
## [67,] 0.78845736 31.088686
## [68,] 0.81093022 30.574031
## [69,] 0.82667857 30.216630
## [70,] 0.84729786 29.753610
## [71,] 0.84729786 29.753610
## [72,] 0.87546874 29.127428
## [73,] 0.91629073 28.254020
## [74,] 0.91629073 28.254020
## [75,] 0.91629073 28.254020
## [76,] 0.95551144 27.440599
## [77,] 0.98082925 26.927683
## [78,] 0.98082925 26.927683
## [79,] 1.01160091 26.330522
## [80,] 1.02961942 25.987420
## [81,] 1.09861229 24.729972
## [82,] 1.09861229 24.729972
## [83,] 1.09861229 24.729972
## [84,] 1.09861229 24.729972
## [85,] 1.09861229 24.729972
## [86,] 1.16315081 23.645463
## [87,] 1.17865500 23.395589
## [88,] 1.20397280 22.992903
## [89,] 1.25276297 22.256180
## [90,] 1.25276297 22.256180
## [91,] 1.29928298 21.590691
## [92,] 1.32175584 21.281509
## [93,] 1.38629436 20.439628
## [94,] 1.38629436 20.439628
## [95,] 1.38629436 20.439628
## [96,] 1.38629436 20.439628
## [97,] 1.46633707 19.470980
## [98,] 1.50407740 19.042673
## [99,] 1.54044504 18.641991
## [100,] 1.60943791 17.933894
## [101,] 1.60943791 17.933894
## [102,] 1.60943791 17.933894
## [103,] 1.67397643 17.312153
## [104,] 1.70474809 17.029704
## [105,] 1.79175947 16.272056
## [106,] 1.79175947 16.272056
## [107,] 1.87180218 15.636495
## [108,] 1.94591015 15.081635
## [109,] 1.94591015 15.081635
## [110,] 2.01490302 14.601151
## [111,] 2.07944154 14.177551
## [112,] 2.07944154 14.177551
## [113,] 2.19722458 13.466560
## [114,] 2.30258509 12.883640
## [115,] 2.39789527 12.396990
## [116,] 2.48490665 11.978958
## [117,] 2.56494936 11.625193
## [118,] 2.63905733 11.308092
## [119,] 2.70805020 11.035059
## [120,] 2.77258872 10.787689
meanBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Estimate"]
meanBF = abs(meanBF)
seBF = summary(lme1)$coefficients["legality.ct:condition.ct", "Std. Error"]
h1mean = summary(lme1b)$coefficients["conditionword-final:legality.ct", "Estimate"]
h1mean = h1mean/2
Bf(seBF, meanBF, uniform = 0, meanoftheory = 0, sdtheory = h1mean, tail = 1)
## $LikelihoodTheory
## [1] 1.399795
##
## $Likelihoodnull
## [1] 1.683821
##
## $BayesFactor
## [1] 0.8313204
Bf_powercalc(sd = 0.27994, obtained = 0, uniform = 0, meanoftheory=0, sdtheory=0.22875, tail=1, N = 60, min = 100, max = 200)
## x y
## [1,] 100 0.6859674
## [2,] 101 0.6841627
## [3,] 102 0.6823722
## [4,] 103 0.6805956
## [5,] 104 0.6788328
## [6,] 105 0.6770836
## [7,] 106 0.6753478
## [8,] 107 0.6736252
## [9,] 108 0.6719157
## [10,] 109 0.6702191
## [11,] 110 0.6685353
## [12,] 111 0.6668640
## [13,] 112 0.6652052
## [14,] 113 0.6635587
## [15,] 114 0.6619243
## [16,] 115 0.6603019
## [17,] 116 0.6586913
## [18,] 117 0.6570924
## [19,] 118 0.6555051
## [20,] 119 0.6539292
## [21,] 120 0.6523645
## [22,] 121 0.6508110
## [23,] 122 0.6492685
## [24,] 123 0.6477369
## [25,] 124 0.6462161
## [26,] 125 0.6447059
## [27,] 126 0.6432062
## [28,] 127 0.6417168
## [29,] 128 0.6402378
## [30,] 129 0.6387689
## [31,] 130 0.6373100
## [32,] 131 0.6358610
## [33,] 132 0.6344219
## [34,] 133 0.6329924
## [35,] 134 0.6315725
## [36,] 135 0.6301622
## [37,] 136 0.6287612
## [38,] 137 0.6273694
## [39,] 138 0.6259869
## [40,] 139 0.6246134
## [41,] 140 0.6232489
## [42,] 141 0.6218932
## [43,] 142 0.6205464
## [44,] 143 0.6192082
## [45,] 144 0.6178786
## [46,] 145 0.6165575
## [47,] 146 0.6152448
## [48,] 147 0.6139405
## [49,] 148 0.6126444
## [50,] 149 0.6113564
## [51,] 150 0.6100765
## [52,] 151 0.6088046
## [53,] 152 0.6075406
## [54,] 153 0.6062843
## [55,] 154 0.6050359
## [56,] 155 0.6037950
## [57,] 156 0.6025618
## [58,] 157 0.6013361
## [59,] 158 0.6001177
## [60,] 159 0.5989068
## [61,] 160 0.5977031
## [62,] 161 0.5965066
## [63,] 162 0.5953172
## [64,] 163 0.5941350
## [65,] 164 0.5929597
## [66,] 165 0.5917913
## [67,] 166 0.5906298
## [68,] 167 0.5894750
## [69,] 168 0.5883270
## [70,] 169 0.5871857
## [71,] 170 0.5860510
## [72,] 171 0.5849227
## [73,] 172 0.5838010
## [74,] 173 0.5826856
## [75,] 174 0.5815766
## [76,] 175 0.5804739
## [77,] 176 0.5793775
## [78,] 177 0.5782871
## [79,] 178 0.5772029
## [80,] 179 0.5761248
## [81,] 180 0.5750527
## [82,] 181 0.5739865
## [83,] 182 0.5729261
## [84,] 183 0.5718717
## [85,] 184 0.5708230
## [86,] 185 0.5697800
## [87,] 186 0.5687427
## [88,] 187 0.5677110
## [89,] 188 0.5666849
## [90,] 189 0.5656643
## [91,] 190 0.5646492
## [92,] 191 0.5636396
## [93,] 192 0.5626353
## [94,] 193 0.5616363
## [95,] 194 0.5606426
## [96,] 195 0.5596542
## [97,] 196 0.5586709
## [98,] 197 0.5576928
## [99,] 198 0.5567198
## [100,] 199 0.5557519
## [101,] 200 0.5547890
Bf_powercalc(sd = 0.38940, obtained = 0, uniform = 0, meanoftheory=0, sdtheory=0.28387, tail=1, N = 60, min = 100, max = 200)
## x y
## [1,] 100 0.7262235
## [2,] 101 0.7245193
## [3,] 102 0.7228270
## [4,] 103 0.7211465
## [5,] 104 0.7194776
## [6,] 105 0.7178202
## [7,] 106 0.7161741
## [8,] 107 0.7145393
## [9,] 108 0.7129157
## [10,] 109 0.7113030
## [11,] 110 0.7097012
## [12,] 111 0.7081101
## [13,] 112 0.7065296
## [14,] 113 0.7049597
## [15,] 114 0.7034001
## [16,] 115 0.7018509
## [17,] 116 0.7003117
## [18,] 117 0.6987827
## [19,] 118 0.6972636
## [20,] 119 0.6957543
## [21,] 120 0.6942547
## [22,] 121 0.6927648
## [23,] 122 0.6912844
## [24,] 123 0.6898134
## [25,] 124 0.6883518
## [26,] 125 0.6868993
## [27,] 126 0.6854560
## [28,] 127 0.6840218
## [29,] 128 0.6825964
## [30,] 129 0.6811800
## [31,] 130 0.6797722
## [32,] 131 0.6783732
## [33,] 132 0.6769827
## [34,] 133 0.6756007
## [35,] 134 0.6742271
## [36,] 135 0.6728619
## [37,] 136 0.6715048
## [38,] 137 0.6701560
## [39,] 138 0.6688152
## [40,] 139 0.6674824
## [41,] 140 0.6661575
## [42,] 141 0.6648404
## [43,] 142 0.6635311
## [44,] 143 0.6622295
## [45,] 144 0.6609355
## [46,] 145 0.6596490
## [47,] 146 0.6583699
## [48,] 147 0.6570983
## [49,] 148 0.6558340
## [50,] 149 0.6545769
## [51,] 150 0.6533270
## [52,] 151 0.6520843
## [53,] 152 0.6508485
## [54,] 153 0.6496198
## [55,] 154 0.6483979
## [56,] 155 0.6471829
## [57,] 156 0.6459747
## [58,] 157 0.6447732
## [59,] 158 0.6435784
## [60,] 159 0.6423902
## [61,] 160 0.6412085
## [62,] 161 0.6400333
## [63,] 162 0.6388645
## [64,] 163 0.6377020
## [65,] 164 0.6365459
## [66,] 165 0.6353960
## [67,] 166 0.6342523
## [68,] 167 0.6331147
## [69,] 168 0.6319832
## [70,] 169 0.6308578
## [71,] 170 0.6297383
## [72,] 171 0.6286247
## [73,] 172 0.6275170
## [74,] 173 0.6264151
## [75,] 174 0.6253190
## [76,] 175 0.6242286
## [77,] 176 0.6231439
## [78,] 177 0.6220648
## [79,] 178 0.6209912
## [80,] 179 0.6199232
## [81,] 180 0.6188606
## [82,] 181 0.6178035
## [83,] 182 0.6167518
## [84,] 183 0.6157054
## [85,] 184 0.6146642
## [86,] 185 0.6136284
## [87,] 186 0.6125977
## [88,] 187 0.6115722
## [89,] 188 0.6105518
## [90,] 189 0.6095365
## [91,] 190 0.6085262
## [92,] 191 0.6075209
## [93,] 192 0.6065205
## [94,] 193 0.6055251
## [95,] 194 0.6045345
## [96,] 195 0.6035488
## [97,] 196 0.6025679
## [98,] 197 0.6015917
## [99,] 198 0.6006202
## [100,] 199 0.5996534
## [101,] 200 0.5986912