Data Management
dtaHW1 <- read.table("C:/Users/ASUS/Desktop/data/freeRecall.asc.txt", h=T)
head(dtaHW1)
## grp trial ncr
## 1 C 1 7.9
## 2 C 2 10.9
## 3 C 3 11.9
## 4 C 4 13.0
## 5 C 5 14.2
## 6 C 6 14.2
NLS model
dta1_init <- c(a = 5, b = log(10/5))
summary(m0 <- nls(ncr~ a*exp(b*sqrt(trial)), data = dtaHW1,start = dta1_init))
##
## Formula: ncr ~ a * exp(b * sqrt(trial))
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## a 8.92939 0.50253 17.769 7.34e-13 ***
## b 0.17714 0.02269 7.806 3.47e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.864 on 18 degrees of freedom
##
## Number of iterations to convergence: 6
## Achieved convergence tolerance: 4.602e-07
plot
library(ggplot2)
ggplot(dtaHW1, aes(trial, ncr, color = grp)) +
stat_smooth(method = "nls", formula = y ~ a*exp(b*sqrt(x)),
method.args = list(start = dta1_init),
se = F,
size = rel(.5)) +
geom_point(pch = 1, size = rel(2)) +
scale_x_continuous(limits = c(0, 10), breaks = seq(0, 10, by = 2)) +
scale_y_continuous(limits = c(5, 20), breaks = seq(5, 20, by = 5)) +
labs(x = "Trial on list B",
y = "Mean number of correct responses")

Residual
plot(m0)
