nlsList(OD ~ preparation + SSlogis(concentration, Asym, xmid, scal) | plate, data=data)
?nlme
data
ddply(data, .(concentration), summarise, M=mean(OD))
library(plyr)
ddply(data, .(concentration), summarise, M=mean(OD))
ddply(data, .(preparation, concentration), summarise, M=mean(OD))
fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1,
start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
summary(fm1)
fm2 <- update(fm1, random = pdDiag(Asym + lrc ~ 1))
summary(fm2)
setwd("~/documents/projects/MPIB/Baltes_Kliegl.DevPsych92")
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
?rowMean
?rowMeans
names(bk92)
bk92$SFREC1 <- mean(bk92[,57:61])
bk92$SFREC2 <- mean(bk92[,69:73])
bk92$SADTR1 <- mean(bk92[,81:85])
bk92$SADTR2 <- mean(bk92[,87:91])
bk92$SADTR3 <- mean(bk92[,93:97])
bk92$SADTR4 <- mean(bk92[,99:103])
bk92$SFREC3 <- mean(bk92[,493:497])
bk92$SF1 <- mean(bk92[,499:508])
bk92$SF2 <- mean(bk92[,511:520])
bk92$SF2 <- mean(bk92[,523:532])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
?rowMeans
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:508])
bk92$SF2 <- rowMeans(bk92[,511:520])
bk92$SF2 <- rowMeans(bk92[,523:532])
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:508])
bk92$SF2 <- rowMeans(bk92[,511:520])
bk92$SF2 <- rowMeans(bk92[,523:532])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:508])
bk92$SF2 <- rowMeans(bk92[,511:520])
bk92$SF2 <- rowMeans(bk92[,523:532])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
bk92$SF1 <- rowMeans(bk92[,499:506])
bk92$SF2 <- rowMeans(bk92[,511:518])
bk92$SF2 <- rowMeans(bk92[,523:530])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:506])
bk92$SF2 <- rowMeans(bk92[,511:518])
bk92$SF2 <- rowMeans(bk92[,523:530])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:506])
bk92$SF2 <- rowMeans(bk92[,511:518])
bk92$SF3 <- rowMeans(bk92[,523:530])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
bk92.2 <- read.spss("rec88.sys", to.data.frame=TRUE)
bk92[,c("SFREC3.2", "SF1.2", "SF2.2", "SF3.2")] <- bk92.2[bk92.2$ID <= 54, c("SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:506])
bk92$SF2 <- rowMeans(bk92[,511:518])
bk92$SF3 <- rowMeans(bk92[,523:530])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_edu=round(mean(EDUC), 1), sd_edu=round(sd(EDUC), 1),
m_hlth=round(mean(BQ4), 1), sd_hlth=round(sd(BQ4), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
qplot(data=test, x=AgeGroup, y=SF3, geom="point", position=position.dodge(1))
qplot(data=test, x=AgeGroup, y=SF3, geom="point", position=position_dodge(1))
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(1))
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(3))
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(3)) + theme_bw()
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(0.5)) + theme_bw()
bk92$SF3
bk92[, c("AgeGroup", "SF3")]
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_edu=round(mean(EDUC), 1), sd_edu=round(sd(EDUC), 1),
m_hlth=round(mean(BQ4), 1), sd_hlth=round(sd(BQ4), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
# Take out scores for fast (~ 1 s) presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
bk92$SF1 <- rowMeans(bk92[,499:502,504:506])
bk92$SF2 <- rowMeans(bk92[,511:514,516:518])
bk92$SF3 <- rowMeans(bk92[,523:526, 528:530])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26.5, 31.5, 36.5))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1a:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point"), position = position_dodge(0.4)) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), position = position_dodge(0.4), width=0.1) + theme_bw()
# Figure 1b:
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(0.5)) + theme_bw()
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point")) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), width=0.1)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26, 31, 36))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point")) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), width=0.2) + theme_bw()
bk92$SF1.2 <- rowMeans(bk92[,c("sf101", "sf102", "sf103", "sf104", "sf106", "sf107", "sf108")])
bk92$SF2.2 <- rowMeans(bk92[,c("sf201", "sf202", "sf203", "sf204", "sf206", "sf207", "sf208")])
bk92$SF3.2 <- rowMeans(bk92[,c("sf301", "sf302", "sf303", "sf304", "sf306", "sf307", "sf308")])
bk92$SF1.2 <- rowMeans(bk92[,c("SF101", "SF102", "SF103", "SF104", "SF106", "SF107", "SF108")])
bk92$SF2.2 <- rowMeans(bk92[,c("SF201", "SF202", "SF203", "SF204", "SF206", "SF207", "SF208")])
bk92$SF3.2 <- rowMeans(bk92[,c("SF301", "SF302", "SF303", "SF304", "SF306", "SF307", "SF308")])
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_edu=round(mean(EDUC), 1), sd_edu=round(sd(EDUC), 1),
m_hlth=round(mean(BQ4), 1), sd_hlth=round(sd(BQ4), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
# Take out scores for fast  1-s presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
# ... take out 6.3 s and 4 fast times
#bk92$SF1 <- rowMeans(bk92[,499:502,504:506])
#bk92$SF2 <- rowMeans(bk92[,511:514,516:518])
#bk92$SF3 <- rowMeans(bk92[,523:526,528:530])
bk92$SF1.2 <- rowMeans(bk92[,c("SF101", "SF102", "SF103", "SF104", "SF106", "SF107", "SF108")])
bk92$SF2.2 <- rowMeans(bk92[,c("SF201", "SF202", "SF203", "SF204", "SF206", "SF207", "SF208")])
bk92$SF3.2 <- rowMeans(bk92[,c("SF301", "SF302", "SF303", "SF304", "SF306", "SF307", "SF308")])
names(bk92)
head(bk90[, c("SF1", "SF1.2", "SF2", "SF2.2", "SF3", "SF3.2" )])
head(bk92[, c("SF1", "SF1.2", "SF2", "SF2.2", "SF3", "SF3.2" )])
head(bk92[,499:502,504:506])
bk92$SF1 <- rowMeans(bk92[,c(499:502,504:506)])
bk92$SF2 <- rowMeans(bk92[,c(511:514,516:518)])
bk92$SF3 <- rowMeans(bk92[,c(523:526,528:530)])
head(bk92[,499:502,504:506])
head(bk92[,c(499:502,504:506)])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26, 31, 36))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1a:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point")) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), width=0.2) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("Herbst97.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_edu=round(mean(EDUC), 1), sd_edu=round(sd(EDUC), 1),
m_hlth=round(mean(BQ4), 1), sd_hlth=round(sd(BQ4), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
# Take out scores for fast  1-s presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
# ... take out 6.3 s and 4 fast times
bk92$SF1 <- rowMeans(bk92[,c(499:502,504:506)])
bk92$SF2 <- rowMeans(bk92[,c(511:514,516:518)])
bk92$SF3 <- rowMeans(bk92[,c(523:526,528:530)])
bk92$SF1.2 <- rowMeans(bk92[,c("SF101", "SF102", "SF103", "SF104", "SF106", "SF107", "SF108")])
bk92$SF2.2 <- rowMeans(bk92[,c("SF201", "SF202", "SF203", "SF204", "SF206", "SF207", "SF208")])
bk92$SF3.2 <- rowMeans(bk92[,c("SF301", "SF302", "SF303", "SF304", "SF306", "SF307", "SF308")])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26, 31, 36))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1a:  Session x Age
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point")) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), width=0.2) + theme_bw()
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(0.5)) + theme_bw()
# Baltes & Kliegl (1992, Developmental Psychology, Figure 1)
# R. Kliegl, 2014-02-24
library(foreign)
library(plyr)
library(ggplot2)
library(reshape2)
rm(list=ls())
# Set up
bk92 <- read.spss("bk.DevPsych.1992.sys", to.data.frame=TRUE)
bk92$AgeGroup <- factor(bk92$GROUP, levels=c("young", "old"))
bk92$subj <- factor(bk92$ID)
bk92$gender <- factor(bk92$SEX, levels=c("2", "1"), labels=c("female", "male"))
names(bk92)
table(bk92$gender, bk92$AgeGroup)
ddply(bk92, .(AgeGroup), summarize, N=length(AGE),
m_age=round(mean(AGE), 1), sd_age=round(sd(AGE), 1),
m_edu=round(mean(EDUC), 1), sd_edu=round(sd(EDUC), 1),
m_hlth=round(mean(BQ4), 1), sd_hlth=round(sd(BQ4), 1),
m_IQ=round(mean(IQ), 1), sd_IQ=round(sd(IQ), 1),
m_vrb=round(mean(VERBAL), 1), sd_vrb=round(sd(VERBAL), 1),
m_prf=round(mean(PERFORM), 1), sd_prf=round(sd(PERFORM), 1))
# Take out scores for fast  1-s presentation times
bk92$SFREC1 <- rowMeans(bk92[,57:61])
bk92$SFREC2 <- rowMeans(bk92[,69:73])
bk92$SADTR1 <- rowMeans(bk92[,81:85])
bk92$SADTR2 <- rowMeans(bk92[,87:91])
bk92$SADTR3 <- rowMeans(bk92[,93:97])
bk92$SADTR4 <- rowMeans(bk92[,99:103])
bk92$SFREC3 <- rowMeans(bk92[,493:497])
# ... take out 6.3 s (different from description in paper) and 4 fast times
bk92$SF1 <- rowMeans(bk92[,c(499:502,504:506)])
bk92$SF2 <- rowMeans(bk92[,c(511:514,516:518)])
bk92$SF3 <- rowMeans(bk92[,c(523:526,528:530)])
bk92$SF1.2 <- rowMeans(bk92[,c("SF101", "SF102", "SF103", "SF104", "SF106", "SF107", "SF108")])
bk92$SF2.2 <- rowMeans(bk92[,c("SF201", "SF202", "SF203", "SF204", "SF206", "SF207", "SF208")])
bk92$SF3.2 <- rowMeans(bk92[,c("SF301", "SF302", "SF303", "SF304", "SF306", "SF307", "SF308")])
bk92 <- bk92[, c("AgeGroup", "subj", "gender", "AGE", "BQ4", "EDUC", "IQ", "VERBAL", "PERFORM",
"SFREC1",  "SADTR1", "SADTR2", "SADTR3", "SADTR4", "SFREC2", "SFREC3", "SF1", "SF2", "SF3")]
test <- arrange(melt(bk92, id.vars=c("AgeGroup", "subj"), measure.vars=10:19), subj, variable)
test$SessionCont <- rep(c(2, 7, 10, 13, 16, 17, 25, 26, 31, 36))
test$Session <- factor(rep(c("2", "7", "10", "13", "16", "17", "25", "26/27", "31/32", "36/37")))
# Figure 1a:  Session x Age (slight discrepancy from paper, not sure why)
M_Fig1 <- ddply(test, .(AgeGroup, SessionCont), summarize, M=mean(value), SD=sd(value))
qplot(data=M_Fig1, x=SessionCont, y=M, group=AgeGroup, shape=AgeGroup, geom=c("line", "point")) +
scale_x_continuous("Session", limits=c(0, 38), breaks=c(0, 2, 7, 10, 13, 16, 17, 25, 26, 31, 36) ) +
geom_point(size=3) +
scale_y_continuous("N of Words Recalled (Max=30)", limits= c(0,30), breaks=seq(0,30,5)) +
geom_errorbar(aes(ymax=M+SD, ymin=M-SD), width=0.2) + theme_bw()
# Figure 1b:
qplot(data=bk92, x=AgeGroup, y=SF3, geom="point", position=position_dodge(0.5)) + theme_bw()
