bstewart/stm

Typo in line 209 of plot wrapper

margaretfoster opened this issue · 5 comments

Hello STM team,

I've been having some trouble using the "perspectives" plot with covariates.
I'm not sure yet if this is the underlying problem that I've been having, but there seems to be a typo on line 209:

covlabels <- model$seetings$covariates$yvarlevels

Wanted to flag that.

Margaret

(I'm actually still having the issue with the perspective plot, it seems that mod.out$settings.covariates$yvarlevels isn't storing covariate levels anymore...)

Margaret- oh that's not great. Let me see what I can do.

Can you send me a reproducible example using the data in package (or just shoot me an email at bms4@princeton.edu if its more specific to your setting)?

I threw a fix for the issue you flagged in the staging branch and will try to fold it in with some other small things soon to a minor patch release (you can use devtools to install from the staging branch though). It does still story yvarlevels when using a content covariate and it never did if it wasn't (you shouldn't end up at line 209 in plot.stm if its not a content covariate model). Long story short, I think I don't exactly what the issue is, but let me know and we will see if we can find it.

Hi Brandon,

Thanks for getting back to me. The line 209 typo was something that I found while trying to troubleshoot the problem that R throws me the error "+ + + Error in plot.window(...) : need finite 'xlim' values" when I've been trying to use the perspectives plot to show words associated with covariate levels.

Here is an example from the gadarian data with the package and using the example model from the stm.pdf manual. I've reproduced the xlim error and also the wall that I got to when trying to work through the perspectives plot.

Feel free to email me at margaret.foster@unc.edu if you have questions or need more info.

## Set up a toy model:
temp<-textProcessor(documents=gadarian$open.ended.response, 
                    metadata=gadarian) ## Data

out <- prepDocuments(temp$documents,
                     temp$vocab, 
                     temp$meta)  ## Data prep

mod.out <- stm(out$documents,
               out$vocab,
	       K=3, ## Toy model
               prevalence=~treatment + s(pid_rep),
	       data=out$meta)

## Take model and plot perspectives with covariate levels:
## throws xlim error:

plot(gadarianFit,
     type="perspectives",
     topics=c(3),
     covarlevels=c("0", "1"))

## Go into the plot.STM.R code on github, try to rebuild the call, starting from line 192 where the perspectives plot starts. [ Skip various conditionals].  
Go to the block that starts with line 203, aspects:

## covlabels <-  model$[settings]$covariates$yvarlevels

## Go into model out, look for the "treatment" covariate levels:
mod.out$settings$covariates$yvarlevels  ## NULL

Thanks!

Margaret

Wanted to follow up here, as I'm experiencing the same issue with the perspectives plot: my.model$settings$covariates$yvarlevels is NULL. Was there a resolution?