modelCriteriaMSE | R Documentation |
This function is part of a set of functions to fit and evaluate the two-rate model of motor learning.
modelCriteriaMSE(MSE, k, N, n = NA, MSEmean)
MSE |
numeric: The mean squared error between the model and data. This can be a vector if multiple models are to be evaluated. If this vector has named entries, they will be used as row names in the returned data frame. |
k |
numeric: The number of parameters in the model. If MSE is a vector k needs to be a vector of the same length. |
N |
numeric: the number of independent observations (see the function: 'seriesEffectiveSampleSize' for some options. (Not a vector.) |
n |
numeric: the number of observation. For a two-rate model this would be the number of trials in the sequence. Necessary for calculating AICc, but can be left NA to skip AICc. |
This function allows estimating model criteria based on the RMSE. This is useful for models where no method exists to extract the log-likelihood. When log-likelihood can be used, see 'AIC', 'logLik' and 'nobs' from stats.
If possible fit models by maximizing their likelihood.
The function calculates two model evaluation criteria:
"AIC": Akaike's Information Criterion
"AICc": The AIC, but with a correction for small sample sizes.
If there are 2 or more models evaluated, the relative likelihoods of the models, based on each criterion are also returned.
data frame with values for several model evaluation criteria
# get example data: data("tworatedata") # first we baseline it, and get a median for every trial: baseline <- function(reachvector,blidx) reachvector - mean(reachvector[blidx], na.rm=TRUE) tworatedata[,4:ncol(tworatedata)] <- apply(tworatedata[,4:ncol(tworatedata)], FUN=baseline, MARGIN=c(2), blidx=c(17:32)) reaches <- apply(tworatedata[4:ncol(tworatedata)], FUN=median, MARGIN=c(1), na.rm=TRUE) # and we extract the schedule: schedule <- tworatedata$schedule # now we can fit the model to the reaches, given the schedule: par <- twoRateFit(schedule, reaches) MSE2 <- twoRateMSE(par, schedule, reaches) # we do the same for the one-rate model: par <- oneRateFit(schedule, reaches) MSE1 <- oneRateMSE(par, schedule, reaches) MSEmean <- mean((schedule-mean(reaches))^2) # effective N was calculated with "seriesEffectiveSampleSize" as: 6.833 modelCriteriaMSE(MSE=c('one-rate'=MSE1, 'two-rate'=MSE2), k=c(2,4), N=6.833, n=164, MSEmean=MSEmean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.