top_terms: Top Terms Function

Description Usage Arguments Value Examples

View source: R/top_terms.R

Description

Top Terms Function

Usage

1
2
top_terms(x, w, y, alpha, lambda, k, wordcloud, max.words, scale, rot.per,
  family)

Arguments

x

the input matrix of terms to be selected.

w

optional argument. the input matrix of structured data to not be selected.

y

the response variable

alpha

the glmnet alpha

lambda

the glmnet lambda

k

the k top terms

wordcloud

set TRUE to plot the wordcloud

max.words

the maximum number of words in the wordcloud

scale

the wordcloud size.

rot.per

wordcloud proportion 90 degree terms

family

glmnet family

Value

the top k terms and the corresponding wordcloud.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(1)
data("stock_data")
data("news_data")
y=as.matrix(stock_data[,2])
w=as.matrix(stock_data[,3])
data("news_data")
X=news_data[,2:ncol(news_data)]
x=as.matrix(X)
grid_alphas=seq(by=0.05,to=0.95,from=0.05)
cont_folds=TRUE
t=length(y)
optimal_alphas=optimal_alphas(x[1:(t-1),],w[1:(t-1),],
y[2:t],grid_alphas,TRUE,"gaussian")
top_trms<- top_terms(x[1:(t-1),],w[1:(t-1),],y[2:t],
optimal_alphas[[1]], optimal_alphas[[2]],10,TRUE,
10,c(2,0.3),.15,"gaussian")

lucasgodeiro/TextForecast documentation built on Sept. 19, 2019, 3:41 a.m.