├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── NAMESPACE ├── R └── extractEffect.R ├── README-unnamed-chunk-5-1.png ├── README-unnamed-chunk-6-1.png ├── README.Rmd ├── README.md ├── appveyor.yml ├── man └── extract.estimateEffect.Rd └── tidystm.Rproj /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.gitignore$ 4 | ^\.travis\.yml$ 5 | ^README\.Rmd$ 6 | ^README-.*\.png$ 7 | ^appveyor\.yml$ 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | *~ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: tidystm 2 | Title: Extract Effect from estimateEffect in the stm Package 3 | Version: 0.0.0.9000 4 | Authors@R: person("Mikael", "Johannesson", email = "mikael.johannesson@uib.no", role = c("aut", "cre")) 5 | Description: Extracts the effect of a covariate on a set of topics selected by the user. Different effect types available depending on type of covariate. Before running this, the user should run a function to simulate necessary confidence intervals. See estimateEffect of the stm package. 6 | Depends: 7 | R (>= 3.3.1), 8 | stm 9 | License: MIT 10 | Encoding: UTF-8 11 | LazyData: true 12 | RoxygenNote: 5.0.1 13 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(extract.estimateEffect) 4 | import(stm) 5 | importFrom(stats,quantile) 6 | importFrom(stats,sd) 7 | -------------------------------------------------------------------------------- /R/extractEffect.R: -------------------------------------------------------------------------------- 1 | #' Extract effect of covariates on topics 2 | #' 3 | #' Extracts the effect of a covariate on a set of topics selected by 4 | #' the user. Different effect types available depending on type of 5 | #' covariate. Before running this, the user should run a function to 6 | #' simulate necessary confidence intervals. See 7 | #' \code{link{estimateEffect}}. 8 | #' 9 | #' @import stm 10 | #' @importFrom stats quantile sd 11 | #' 12 | #' @param x Output of estimateEffect, which calculates simulated betas 13 | #' for plotting or extraction. 14 | #' @param covariate String of the name of the main covariate of 15 | #' interest. Must be enclosed in quotes. All other covariates within 16 | #' the formula specified in estimateEffect will be kept at their 17 | #' median. 18 | #' @param model Model output, only necessary if labeltype is "prob", 19 | #' "frex", "score", or "lift". Models with more than one spline 20 | #' cannot be used for extract.estimateEffect. 21 | #' @param topics Topics to plot. 22 | #' @param method Method used for plotting. "pointestimate" estimates 23 | #' mean topic proportions for each value of the covariate. 24 | #' "difference" estimates the mean difference in topic proportions 25 | #' for two different values of the covariate (cov.value1 and 26 | #' cov.value2 must be specified). "continuous" estimates how topic 27 | #' proportions vary over the support of a continuous covariate. 28 | #' @param cov.value1 For method "difference", the value or set of 29 | #' values of interest at which to set the covariate. In the case of 30 | #' calculating a treatment/control contrast, set the treatment to 31 | #' cov.value1. 32 | #' @param cov.value2 For method "difference", the value or set of 33 | #' values which will be set as the comparison group. cov.value1 and 34 | #' cov.value2 must be vectors of the same length. 35 | #' @param moderator When two terms are interacted and one variable in 36 | #' the interaction is the covariate of interest, the user can 37 | #' specify the value of the interaction with moderator.value, and 38 | #' the name of the moderator with moderator. 39 | #' @param moderator.value When two terms are interacted and one 40 | #' variable in the interaction is the covariate of interest, the 41 | #' user can specify the value of the interaction term. 42 | #' @param npoints Number of unique points to use for simulation along 43 | #' the support of a continuous covariate. For method "continuous" 44 | #' only. 45 | #' @param nsims Number of simulations for estimation. 46 | #' @param n Number of words to print if "prob", "score", "lift", or 47 | #' "frex" is chosen. to signal how far the function have come. 48 | #' @param ci.level Confidence level for confidence intervals. 49 | #' @param frexw If "frex" labeltype is used, this will be the frex 50 | #' weight. 51 | #' @param custom.labels A vector of custom.labels if labeltype is 52 | #' equal to "custom". 53 | #' @param labeltype Determines the labeltype for the topics. The 54 | #' default is "number" which prints the topic number. Other options 55 | #' are "prob", which prints the highest probability words, "score", 56 | #' "lift", and "frex", from labeltopics (see 57 | #' \code{stm::labeltopics()} for more details). The user can also 58 | #' select "custom" for custom labels, which should be inputted under 59 | #' custom.labels. Labels appear in the legend for continous 60 | #' covariates. 61 | #' 62 | #' @examples 63 | #' \dontrun{ 64 | #' prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian) 65 | #' effect <- extract.estimateEffect(prep, "treatment", model = gadarianFit, method = "pointestimate") 66 | #' } 67 | #' @export 68 | 69 | extract.estimateEffect <- function(x, covariate, model = NULL, 70 | topics = x$topics, 71 | method = "pointestimate", 72 | cov.value1 = NULL, cov.value2 = NULL, 73 | moderator = NULL, moderator.value = NULL, 74 | npoints = 100, nsims = 100, ci.level = .95, 75 | custom.labels = NULL, labeltype = "numbers", 76 | n = 7, frexw = .5) { 77 | 78 | cthis <- stm:::produce_cmatrix(prep = x, 79 | covariate = covariate, 80 | method = method, 81 | cov.value1 = cov.value1, 82 | cov.value2 = cov.value2, 83 | moderator = moderator, 84 | moderator.value = moderator.value) 85 | simbetas <- stm:::simBetas(parameters = x$parameters, 86 | nsims = nsims) 87 | 88 | uvals <- cthis$cdata[[covariate]] 89 | offset <- (1 - ci.level) / 2 90 | labels <- stm:::createLabels(labeltype = labeltype, 91 | covariate = covariate, 92 | method = method, 93 | cdata = cthis$cdata, 94 | cov.value1 = cov.value1, 95 | cov.value2 = cov.value2, 96 | model = model, 97 | n = n, 98 | topics = x$topics, 99 | custom.labels = custom.labels, 100 | frexw = frexw) 101 | 102 | out <- lapply(topics, function(i) { 103 | 104 | sims <- cthis$cmatrix %*% t(simbetas[[which(x$topics == i)]]) 105 | 106 | if (method == "difference") { 107 | 108 | diff <- sims[1, ] - sims[2, ] 109 | out_inner <- data.frame(method = method, 110 | topic = i, 111 | covariate = covariate, 112 | covariate.value = paste0(cov.value1, "-", cov.value2), 113 | estimate = mean(diff), 114 | std.error = sd(diff), 115 | ci.level = ci.level, 116 | ci.lower = quantile(diff, offset), 117 | ci.upper = quantile(diff, 1 - offset), 118 | label = labels[which(x$topics == i)]) 119 | 120 | } else { 121 | 122 | out_inner <- data.frame(method = method, 123 | topic = i, 124 | covariate = covariate, 125 | covariate.value = uvals, 126 | estimate = apply(sims, 1, mean), 127 | std.error = apply(sims, 1, sd), 128 | ci.level = ci.level, 129 | ci.lower = apply(sims, 1, quantile, probs = offset), 130 | ci.upper = apply(sims, 1, quantile, probs = (1 - offset)), 131 | label = labels[which(x$topics == i)]) 132 | 133 | } 134 | 135 | if (!is.null(moderator)) { 136 | out_inner$moderator <- moderator 137 | out_inner$moderator.value <- moderator.value 138 | } 139 | 140 | rownames(out_inner) <- NULL 141 | return(out_inner) 142 | 143 | }) 144 | out <- do.call("rbind", out) 145 | 146 | return(out) 147 | } 148 | -------------------------------------------------------------------------------- /README-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikajoh/tidystm/d71262922d38f1128861d205a032acd27b2574db/README-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /README-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikajoh/tidystm/d71262922d38f1128861d205a032acd27b2574db/README-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | md_document: 4 | variant: markdown_github 5 | --- 6 | 7 | 8 | 9 | ```{r, echo = FALSE} 10 | knitr::opts_chunk$set( 11 | collapse = TRUE, 12 | comment = "#>", 13 | fig.path = "README-" 14 | ) 15 | ``` 16 | 17 | ### tidystm: Extract (tidy) effect from `estimateEffect` in the [stm package](http://www.structuraltopicmodel.com/) 18 | 19 | [![Travis-CI Build Status](https://travis-ci.org/mikaelpoul/tidystm.svg?branch=master)](https://travis-ci.org/) 20 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/mikaelpoul/tidystm?branch=master&svg=true)](https://ci.appveyor.com/project/mikaelpoul/tidystm) 21 | 22 | Extracts the effect of a covariate on a set of topics selected by the user. Different effect types available depending on type of covariate. Before running this, the user should run a function to simulate necessary confidence intervals. See `estimateEffect` of the [stm package](http://www.structuraltopicmodel.com/). 23 | 24 | #### Install 25 | 26 | You need the `devtools` package in order to install `tidystm`. You can install it using the follow code (note that you only need to run this once): 27 | 28 | ```{r} 29 | if (!require(devtools)) install.packages("devtools") 30 | ``` 31 | 32 | You can then install `tidystm` by running: 33 | 34 | ```{r, eval = FALSE} 35 | devtools::install_github("mikajoh/tidystm", dependencies = TRUE) 36 | ``` 37 | 38 | #### Use 39 | 40 | The package, for now, includes one function: `extract.estimateEffect()`. You run it just as you would run the `plot.estimateEffect()` function included in the `stm` package. E.g.: 41 | 42 | ```{r} 43 | ## Load the packages and set seed 44 | library(stm) 45 | library(tidystm) 46 | 47 | set.seed(2016) 48 | 49 | ## Load the example data from the stm pacakge 50 | data(gadarian) 51 | 52 | ## Estimate the effect on all three topics and return the point 53 | ## estimates in a tidy data frame 54 | prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian) 55 | effect <- extract.estimateEffect(prep, "treatment", model = gadarianFit, method = "pointestimate") 56 | 57 | knitr::kable(effect) 58 | ``` 59 | 60 | You can then use the results however you like. This is especially helpful if you want to plot it for yourself when the included plot functions doesnt cut it. For example: 61 | 62 | ``` {r results = "hold"} 63 | 64 | ## This time, lets estimate treatment effect as a function of party 65 | ## id. We can than get an idea of whether the treatment effect vary 66 | ## for people with different ids. 67 | prep <- estimateEffect(formula = 1:3 ~ treatment + pid_rep + treatment:pid_rep, 68 | stmobj = gadarianFit, 69 | metadata = gadarian) 70 | 71 | ## And lets plot it using the included plotting function. 72 | op <- par(mfrow = c(1, 2)) 73 | for (i in c(0, 1)) { 74 | plot.estimateEffect(x = prep, 75 | covariate = "pid_rep", 76 | method = "continuous", 77 | model = gadarianFit, 78 | labeltype = "frex", 79 | n = 4, 80 | moderator = "treatment", 81 | moderator.value = i) 82 | } 83 | par(op) 84 | 85 | ``` 86 | 87 | Not very easy to see what going on. Instead, lets extract the estimates in a tidy format so that we can plot it ourselves 88 | 89 | ```{r} 90 | ## Lets extract the estimates in a tidy format so that we can plot it 91 | ## ourselves. We can now use lapply instead to first run it with 92 | ## moderator.value 0 and then with moderator.value 1, and then bind 93 | ## the two data frames together. 94 | effect <- lapply(c(0, 1), function(i) { 95 | extract.estimateEffect(x = prep, 96 | covariate = "pid_rep", 97 | method = "continuous", 98 | model = gadarianFit, 99 | labeltype = "frex", 100 | n = 4, 101 | moderator = "treatment", 102 | moderator.value = i) 103 | }) 104 | effect <- do.call("rbind", effect) 105 | 106 | ## And, for example, plot it with ggplot2 and facet by topic instead. 107 | library(ggplot2) 108 | 109 | ggplot(effect, aes(x = covariate.value, y = estimate, 110 | ymin = ci.lower, ymax = ci.upper, 111 | group = moderator.value, 112 | fill = factor(moderator.value))) + 113 | facet_wrap(~ label, nrow = 2) + 114 | geom_ribbon(alpha = .5) + 115 | geom_line() + 116 | scale_x_continuous(labels = function(x) ifelse(x == 1, "1\nREP", ifelse(x == 0, "0\nDEM", x))) + 117 | labs(x = "Party ID", 118 | y = "Expected Topic Proportion", 119 | fill = "Treated (0/1)") + 120 | theme(legend.position = "bottom") 121 | 122 | 123 | ``` 124 | 125 | Much better :) 126 | 127 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ### tidystm: Extract (tidy) effect from `estimateEffect` in the [stm package](http://www.structuraltopicmodel.com/) 3 | 4 | [![Travis-CI Build Status](https://travis-ci.org/mikaelpoul/tidystm.svg?branch=master)](https://travis-ci.org/) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/mikaelpoul/tidystm?branch=master&svg=true)](https://ci.appveyor.com/project/mikaelpoul/tidystm) 5 | 6 | Extracts the effect of a covariate on a set of topics selected by the user. Different effect types available depending on type of covariate. Before running this, the user should run a function to simulate necessary confidence intervals. See `estimateEffect` of the [stm package](http://www.structuraltopicmodel.com/). 7 | 8 | #### Install 9 | 10 | You need the `devtools` package in order to install `tidystm`. You can install it using the follow code (note that you only need to run this once): 11 | 12 | ``` r 13 | if (!require(devtools)) install.packages("devtools") 14 | #> Loading required package: devtools 15 | ``` 16 | 17 | You can then install `tidystm` by running: 18 | 19 | ``` r 20 | devtools::install_github("mikajoh/tidystm", dependencies = TRUE) 21 | ``` 22 | 23 | #### Use 24 | 25 | The package, for now, includes one function: `extract.estimateEffect()`. You run it just as you would run the `plot.estimateEffect()` function included in the `stm` package. E.g.: 26 | 27 | ``` r 28 | ## Load the packages and set seed 29 | library(stm) 30 | #> stm v1.1.3 (2016-01-14) successfully loaded. See ?stm for help. 31 | library(tidystm) 32 | 33 | set.seed(2016) 34 | 35 | ## Load the example data from the stm pacakge 36 | data(gadarian) 37 | 38 | ## Estimate the effect on all three topics and return the point 39 | ## estimates in a tidy data frame 40 | prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian) 41 | effect <- extract.estimateEffect(prep, "treatment", model = gadarianFit, method = "pointestimate") 42 | 43 | knitr::kable(effect) 44 | ``` 45 | 46 | | method | topic| covariate | covariate.value| estimate| std.error| ci.level| ci.lower| ci.upper| label | 47 | |:--------------|------:|:----------|----------------:|----------:|----------:|---------:|----------:|----------:|:----------------------------| 48 | | pointestimate | 1| treatment | 1| 0.2804612| 0.0206076| 0.95| 0.2402753| 0.3201613| Topic 1(Covariate Level: 1) | 49 | | pointestimate | 1| treatment | 0| 0.4439191| 0.0236996| 0.95| 0.3987170| 0.4904847| Topic 1(Covariate Level: 1) | 50 | | pointestimate | 2| treatment | 1| 0.4569280| 0.0229809| 0.95| 0.4121723| 0.5011797| Topic 2(Covariate Level: 1) | 51 | | pointestimate | 2| treatment | 0| 0.2099581| 0.0214375| 0.95| 0.1670091| 0.2519835| Topic 2(Covariate Level: 1) | 52 | | pointestimate | 3| treatment | 1| 0.2629073| 0.0196289| 0.95| 0.2244965| 0.3043431| Topic 3(Covariate Level: 1) | 53 | | pointestimate | 3| treatment | 0| 0.3459851| 0.0225885| 0.95| 0.3024164| 0.3903011| Topic 3(Covariate Level: 1) | 54 | 55 | You can then use the results however you like. This is especially helpful if you want to plot it for yourself when the included plot functions doesnt cut it. For example: 56 | 57 | ``` r 58 | 59 | ## This time, lets estimate treatment effect as a function of party 60 | ## id. We can than get an idea of whether the treatment effect vary 61 | ## for people with different ids. 62 | prep <- estimateEffect(formula = 1:3 ~ treatment + pid_rep + treatment:pid_rep, 63 | stmobj = gadarianFit, 64 | metadata = gadarian) 65 | 66 | ## And lets plot it using the included plotting function. 67 | op <- par(mfrow = c(1, 2)) 68 | for (i in c(0, 1)) { 69 | plot.estimateEffect(x = prep, 70 | covariate = "pid_rep", 71 | method = "continuous", 72 | model = gadarianFit, 73 | labeltype = "frex", 74 | n = 4, 75 | moderator = "treatment", 76 | moderator.value = i) 77 | } 78 | ``` 79 | 80 | ![](README-unnamed-chunk-5-1.png) 81 | 82 | ``` r 83 | par(op) 84 | ``` 85 | 86 | Not very easy to see what going on. Instead, lets extract the estimates in a tidy format so that we can plot it ourselves 87 | 88 | ``` r 89 | ## Lets extract the estimates in a tidy format so that we can plot it 90 | ## ourselves. We can now use lapply instead to first run it with 91 | ## moderator.value 0 and then with moderator.value 1, and then bind 92 | ## the two data frames together. 93 | effect <- lapply(c(0, 1), function(i) { 94 | extract.estimateEffect(x = prep, 95 | covariate = "pid_rep", 96 | method = "continuous", 97 | model = gadarianFit, 98 | labeltype = "frex", 99 | n = 4, 100 | moderator = "treatment", 101 | moderator.value = i) 102 | }) 103 | effect <- do.call("rbind", effect) 104 | 105 | ## And, for example, plot it with ggplot2 and facet by topic instead. 106 | library(ggplot2) 107 | 108 | ggplot(effect, aes(x = covariate.value, y = estimate, 109 | ymin = ci.lower, ymax = ci.upper, 110 | group = moderator.value, 111 | fill = factor(moderator.value))) + 112 | facet_wrap(~ label, nrow = 2) + 113 | geom_ribbon(alpha = .5) + 114 | geom_line() + 115 | scale_x_continuous(labels = function(x) ifelse(x == 1, "1\nREP", ifelse(x == 0, "0\nDEM", x))) + 116 | labs(x = "Party ID", 117 | y = "Expected Topic Proportion", 118 | fill = "Treated (0/1)") + 119 | theme(legend.position = "bottom") 120 | ``` 121 | 122 | ![](README-unnamed-chunk-6-1.png) 123 | 124 | Much better :) 125 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | # Adapt as necessary starting from here 14 | 15 | build_script: 16 | - travis-tool.sh install_deps 17 | 18 | test_script: 19 | - travis-tool.sh run_tests 20 | 21 | on_failure: 22 | - 7z a failure.zip *.Rcheck\* 23 | - appveyor PushArtifact failure.zip 24 | 25 | artifacts: 26 | - path: '*.Rcheck\**\*.log' 27 | name: Logs 28 | 29 | - path: '*.Rcheck\**\*.out' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.fail' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.Rout' 36 | name: Logs 37 | 38 | - path: '\*_*.tar.gz' 39 | name: Bits 40 | 41 | - path: '\*_*.zip' 42 | name: Bits 43 | -------------------------------------------------------------------------------- /man/extract.estimateEffect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/extractEffect.R 3 | \name{extract.estimateEffect} 4 | \alias{extract.estimateEffect} 5 | \title{Extract effect of covariates on topics} 6 | \usage{ 7 | extract.estimateEffect(x, covariate, model = NULL, topics = x$topics, 8 | method = "pointestimate", cov.value1 = NULL, cov.value2 = NULL, 9 | moderator = NULL, moderator.value = NULL, npoints = 100, nsims = 100, 10 | ci.level = 0.95, custom.labels = NULL, labeltype = "numbers", n = 7, 11 | frexw = 0.5) 12 | } 13 | \arguments{ 14 | \item{x}{Output of estimateEffect, which calculates simulated betas 15 | for plotting or extraction.} 16 | 17 | \item{covariate}{String of the name of the main covariate of 18 | interest. Must be enclosed in quotes. All other covariates within 19 | the formula specified in estimateEffect will be kept at their 20 | median.} 21 | 22 | \item{model}{Model output, only necessary if labeltype is "prob", 23 | "frex", "score", or "lift". Models with more than one spline 24 | cannot be used for extract.estimateEffect.} 25 | 26 | \item{topics}{Topics to plot.} 27 | 28 | \item{method}{Method used for plotting. "pointestimate" estimates 29 | mean topic proportions for each value of the covariate. 30 | "difference" estimates the mean difference in topic proportions 31 | for two different values of the covariate (cov.value1 and 32 | cov.value2 must be specified). "continuous" estimates how topic 33 | proportions vary over the support of a continuous covariate.} 34 | 35 | \item{cov.value1}{For method "difference", the value or set of 36 | values of interest at which to set the covariate. In the case of 37 | calculating a treatment/control contrast, set the treatment to 38 | cov.value1.} 39 | 40 | \item{cov.value2}{For method "difference", the value or set of 41 | values which will be set as the comparison group. cov.value1 and 42 | cov.value2 must be vectors of the same length.} 43 | 44 | \item{moderator}{When two terms are interacted and one variable in 45 | the interaction is the covariate of interest, the user can 46 | specify the value of the interaction with moderator.value, and 47 | the name of the moderator with moderator.} 48 | 49 | \item{moderator.value}{When two terms are interacted and one 50 | variable in the interaction is the covariate of interest, the 51 | user can specify the value of the interaction term.} 52 | 53 | \item{npoints}{Number of unique points to use for simulation along 54 | the support of a continuous covariate. For method "continuous" 55 | only.} 56 | 57 | \item{nsims}{Number of simulations for estimation.} 58 | 59 | \item{ci.level}{Confidence level for confidence intervals.} 60 | 61 | \item{custom.labels}{A vector of custom.labels if labeltype is 62 | equal to "custom".} 63 | 64 | \item{labeltype}{Determines the labeltype for the topics. The 65 | default is "number" which prints the topic number. Other options 66 | are "prob", which prints the highest probability words, "score", 67 | "lift", and "frex", from labeltopics (see 68 | \code{stm::labeltopics()} for more details). The user can also 69 | select "custom" for custom labels, which should be inputted under 70 | custom.labels. Labels appear in the legend for continous 71 | covariates.} 72 | 73 | \item{n}{Number of words to print if "prob", "score", "lift", or 74 | "frex" is chosen. to signal how far the function have come.} 75 | 76 | \item{frexw}{If "frex" labeltype is used, this will be the frex 77 | weight.} 78 | } 79 | \description{ 80 | Extracts the effect of a covariate on a set of topics selected by 81 | the user. Different effect types available depending on type of 82 | covariate. Before running this, the user should run a function to 83 | simulate necessary confidence intervals. See 84 | \code{link{estimateEffect}}. 85 | } 86 | \examples{ 87 | \dontrun{ 88 | prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian) 89 | effect <- extract.estimateEffect(prep, "treatment", model = gadarianFit, method = "pointestimate") 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /tidystm.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | Encoding: UTF-8 9 | 10 | AutoAppendNewline: Yes 11 | StripTrailingWhitespace: Yes 12 | 13 | BuildType: Package 14 | PackageUseDevtools: Yes 15 | PackageInstallArgs: --no-multiarch --with-keep.source 16 | PackageRoxygenize: rd,collate,namespace 17 | --------------------------------------------------------------------------------