Learn R Programming

ndl (version 0.2.18)

ndlCrossvalidate: Crossvalidation of a Naive Discriminative Learning model.

Description

ndlCrossvalidate undertakes a crossvalidation of a Naive Discriminative Learning model fitted using ndlClassify.

Usage

ndlCrossvalidate(formula, data, frequency=NA, k=10, folds=NULL, …)

Arguments

formula

An object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. If alternatively set to =NA, the data argument is expected to be in the ndl internal format as generated by ndlCuesOutcomes, and ndlCrossvalidate will check that this is the case.

data

A data frame (as in ndlClassify) containing the variables in the formula specifying the model.

frequency

A numeric vector (or the name of a column in the input data frame) with the frequencies of the exemplars. If absent, each exemplar is assigned a frequency equal to 1.

k

The number of folds, by default equal to 10.

folds

A list of user-defined folds, each item on the list representing a vector of indices indicating lines in the data frame to be used for testing a model fitted with the rest of the data. By default NULL, so that the folds are determined with random selection by the function ndlCrossvalidate.

Control arguments to be passed along to auxiliary functions, in specific estimateWeights and/or estimateActivations.

Value

A list of the class "ndlCrossvalidate" with the following components:

call

The call matched by ndlCrossvalidate

formula

The formula specified for ndlCrossvalidate

fits

A list of individual fits resulting from ndlCrossvalidate

k

The number of folds, by default equal to 10

n.total

The sum frequency of data points

n.train

The size of the training set

n.test

The size of of the testing set

folds

A list with the folds used in the crossvalidation; either selected at random by ndlCrossvalidate or provided by the user.

Details

Crossvalidation of a Naive Discriminative Learning model.

References

Baayen, R. H. and Milin, P. and Filipovic Durdevic, D. and Hendrix, P. and Marelli, M., An amorphous model for morphological processing in visual comprehension based on naive discriminative learning. Psychological Review, 118, 438-482.

Arppe, A. and Baayen, R. H. (in prep.). Statistical modeling and the principles of human learning.

See Also

summary.ndlCrossvalidate, ndlStatistics, ndlCuesOutcomes, cueCoding, estimateWeights, estimateActivations

Examples

Run this code
# NOT RUN {
data(think)
set.seed(314)
think <- think[sample(1:nrow(think),500),]
think.cv5 <- ndlCrossvalidate(Lexeme ~ Agent + Patient, data=think, k=5)
summary(think.cv5)
rm(think)

# }
# NOT RUN {
data(think)
think.cv10 <- ndlCrossvalidate(Lexeme ~ Person + Number + Agent + Patient + Register,
   data=think, k=10)
summary(think.cv10)
# }
# NOT RUN {
library(languageR)
data(finalDevoicing)
finDev.cv10 <- ndlCrossvalidate(Voice ~ Onset1Type + Onset2Type + VowelType *
   ConsonantType * Obstruent + Nsyll + Stress, data=finalDevoicing, k=10)
summary(finDev.cv10)

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab