| trainModel | R Documentation | 
Training and projecting a regression model using politeness features.
trainModel(
  df_polite_train,
  covar = NULL,
  df_polite_test = NULL,
  classifier = c("glmnet", "mnir"),
  cv_folds = NULL,
  ...
)
| df_polite_train | a data.frame with politeness features as outputed by  | 
| covar | a vector of politeness labels, or other covariate. | 
| df_polite_test | optional data.frame with politeness features as outputed by  | 
| classifier | name of classification algorithm. Defaults to "glmnet" (see  | 
| cv_folds | Number of outer folds for projection of training data. Default is NULL (i.e. no nested cross-validation). However, positive values are highly recommended (e.g. 10) for in-sample accuracy estimation. | 
| ... | additional parameters to be passed to the classification algorithm. | 
List:
train_proj projection of politeness model within training set.
test_proj projection of politeness model onto test set (i.e. out-of-sample).
train_coef coefficients from the trained model.
train_model The LASSO model itself (for modelPlot)
List of df_polite_train and df_polite_test with projection. See details.
data("phone_offers")
data("bowl_offers")
polite.data<-politeness(phone_offers$message, parser="none",drop_blank=FALSE)
polite.holdout<-politeness(bowl_offers$message, parser="none",drop_blank=FALSE)
project<-trainModel(polite.data,
                              phone_offers$condition,
                              polite.holdout)
# Difference in average politeness across conditions in the new sample.
mean(project$test_proj[bowl_offers$condition==1])
mean(project$test_proj[bowl_offers$condition==0])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.