Description Usage Arguments Value Examples
Calculates the sum of the log-likelihoods for the nROUSE
model given a set of data. This function can be used in
an optimization routine, like optim
to obtain
estimates of the nROUSE model parameters.
1 | nROUSE_logLik(par, dat, mapping = c(2, 6, 8), predict = F, estimate = T)
|
par |
a vector of log-transformed estimates for the subset of nROUSE parameters. |
dat |
a matrix (or data frame) with a set of named columns:
|
mapping |
an index for which parameters of the nROUSE model to estimate.
|
predict |
a logical value. If true, returns the predicted proportion correct per condition. |
estimate |
a logical value. If true, returns the sum of the log-likelihoods. If false, returns a vector of log-likelihoods. |
If predict
= TRUE
, returns the
predicted proportion correct per condition. Otherwise,
if estimate
= TRUE
, returns the sum of
the log-likelihoods. If neither variable is set to
TRUE
, returns the vector of log-likelihoods.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Load in example data set
data('priming_ex')
# Select a single subject
d = priming_ex[ priming_ex$Subject == 1, ]
# Specify a set of log-transformed starting values
sv = log( c( N = .0302, I = .9844, Ta = 1 ) )
# Estimate the parameters using maximum likelihood
mle = optim( sv, nROUSE_logLik, dat = d,
control = list( fnscale = -1, maxit = 10000 ) )
# Print the parameter estimates
round( exp( mle$par ), 3 )
# Compare to default values:
# N = 0.030
# I = 0.9844
# Ta = 1.0
# Generate predicted accuracy from the estimates
pred = nROUSE_logLik( mle$par, d, predict = T )
# Compare predicted against observed
print( round( pred - d$P, 3 ) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.