h1

Not quite dead

September 18, 2013

It’s been a long time since I’ve posted and several things have changed. First, I am no longer a graduate student at the University of Minnesota. I finished my MS in statistics in Dec 2012 and my PhD in applied stats in education in May 2013. Second, I will be starting a post-doc at the University of Iceland where my position will be an amalgam of ecology, mathematics, statistics, and education. It should be quite the adventure. Third, a recent graduate of my program and I started a consulting company. We are available for hire and you can learn more about us at Parsimony. We have worked with the Minnesota Department of Health, Capella University, and other private and public organizations. Parsimony primarily focuses on statistical, psychometric, and evaluation consulting. I have also recently completed a stint as the statistical consultant for the Institute of Child Development at the University of Minnesota. Finally, and most importantly, I really hope to revitalize this blog. I intend to do some more R modeling and programming, specifically I intend to co-author a multilevel zero-inflated and hurdle models R package. All the code will be available at my github site until it’s on CRAN. I also intend to blog about the mathematical and statistical problems that I encounter as I transition back into having an ecological focus as a post-doc.

h1

Zero-inflation and overdispersion in count models and penalized regression

November 18, 2011

It has been a while since I’ve posted but I am still busy working away at my dissertation. For my dissertation, I am developing a Bayesian mixture model with my co-advisor Dr. Chatterjee in the school of statistics at the University of Minnesota. My hope is that this approach can be useful when your data are a realization of a mixture model with more than two components. Specifically this approach is being developed to address what I perceive as a shortcoming for dealing with count data that are both zero-inflated and overdispersed. Currently the best approaches for dealing with this kind of data are the zero-inflated Poisson and zero-inflated negative binomial models, with the latter models fitting best in the case of zero-inflation and overdispersion in your non-zero counts. These approaches work best when your data arise from two latent classes: structural zeros and sampling zeros. However, in a data set that I have been working with it seems reasonable that the data are from more than two latent classes and thus the inspiration behind the development of this new technique. I will post more about this as we develop it as well as R code.

Finally, I am getting really excited about penalized regression. Specifically ridge, lasso, and elastic-net regression. I will hopefully be back to blog about this soon with some examples of how to do this in R. The benefits of these approaches seem limitless and would be a great addition to the arsenal of methodologies that an applied researcher in education or psychology might use. Specifically I think these types of regressions could work well as a substitute for factor analysis (as these techniques act to reduce the dimensionality of your data).

h1

TeXworks with Sweave

July 31, 2010

Recently, I’ve started trying TeXworks for my LaTeX editing needs. It’s pretty basic but works well, is fast, cross-platform, open-source, and has a nice previewer. I didn’t find any information regarding how to set up Sweave to run with it, so I’ve decided to post how I’ve done it.

Do the following
Edit -> Preferences...

Under the Typesetting tab, in the Processing tools section look for the ‘+’ and click it. This will bring up a dialog box to add your own ‘tool’

I added the following.

In the Name field:
Sweave

In the Program field:
R

And I gave it 3 arguments, each is a separate argument and should not be on the same line!
CMD
Sweave
$fullname

Also, I deselected view PDF as it doesn’t make sense as you now need to run LaTeX.

Click OK, then OK, and now you’ll have Sweave available in the drop down box.

It should look like the screenshot below.

texworks

h1

WinBUGS on Ubuntu and R2WinBUGS with Wine

July 27, 2010

The following is a how-to for setting up WinBUGS on the latest version of Ubuntu 10.04 LTS Lucid Lynx.

1. Install wine-1.0 not wine-1.2 (wine-1.2 will seg fault!)
sudo apt-get install wine-1.0

2. Download WinBUGS from here.

3. Navigate to the directory where you downloaded WinBUGS, I’ll assume it was /home/user/Downloads, and run the following:
wine WinBUGS14.exe

4. Launch WinBUGS
wine ~/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14.exe

5. Patch WinBUGS with the following patch – available here. Apply that patch as described on the WinBUGS website. Then close WinBUGS and launch it again as previously described.

6. Add the immortality key – available here. Apply it the same way you did the patch!

7. Launch R and install R2WinBUGS
R
install.packages("R2WinBUGS")

8. Load R2WinBUGS and run the Gelman example to check that it worked
library(R2WinBUGS)
model.file <- system.file(package="R2WinBUGS","model",
"schools.txt")
data(schools)
J <- nrow(schools)
y <- schools$estimate
sigma.y <- schools$sd
data <- list ("J", "y", "sigma.y")
inits <- function(){
list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
sigma.theta=runif(1, 0, 100))
}
parameters <- c("theta", "mu.theta", "sigma.theta")
schools.sim <- bugs(data, inits, parameters, model.file, n.chains=3, n.iter=5000)
print(schools.sim)
plot(schools.sim)

You will get a couple of messages from Wine, but I believe you can ignore these. I have not thoroughly tested this but I can corroborate that it gives similar estimates to R2WinBUGS from Windows (see below gnome-terminal vs. Windows XP in VirtualBox). I still recommend JAGS but if you need to use WinBUGS here is how.

Also this should work on any Linux distribution or Mac OS X provided that you can get Wine 1.0 as the latest Wine versions do not work with WinBUGS. Let me know if you have troubles.

r2winbugs

9. Add a desktop launcher (OPTIONAL)
Right Click gnome-panel
Click 'Add to Panel ...'
Click 'Custom Application Launcher'

Add the following to the Name field
WinBUGS14

Add the following to the Command field (do include the quotes!)
wine '/home/USER/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14.exe'

Finally, if you want to add the WinBUGS icon, click here. Right click the image and select:
Save image as ...

Save it to /home/user/Downloads/ and then add it by clicking the Wine icon, navigating to the directory where you downloaded it and finally selecting the icon. Then close the Custom Application Launcher dialog box by clicking Close.

h1

Rgedit plugin (32 bit + 64 bit) and JAGS 2.1.0 (64 bit) for Ubuntu 10.04

July 26, 2010

I’ve rolled my own .deb package for Ubuntu 10.04 of Rgedit. This is a plugin for gedit that makes it act as an IDE for R in a similar fashion to ESS or TINN-R. To download the .deb file which is platform independent click here.

Also, I’ve recently updated to JAGS 2.1.0 and have rolled my own Ubuntu 10.04 64 bit packages. I will continue to keep JAGS updated by rebuilding Dirk’s packages from Debian Sid while 10.04 is supported (unless I move back to Debian once Squeeze is released). I will not roll packages for Ubuntu releases that are not LTS. You can get JAGS by clicking here. If anyone is willing to roll 32 bit package I am happy to host it here. Please let me know.

h1

Summer update #1

June 23, 2010

It has been a little while since I last blogged. I have been busy finishing up a Ph.D. related project, namely my written prelim, and haven’t had any time for posting updates. However, I have three important things.

First, I am continuing to work with the Fedora project to get JAGS formally into Fedora. Afterwards, I do hope to get R-rjags and R-coda into Fedora as well but these are much more easily installable via the fantastic R package manager and admittedly are very low on my priorities.

The second big thing that I’ve been working on is writing a KDE/Qt R editor. I know cantor and rkward exist and that you can use kate, kwrite, etc., however, none of these editors really meet my R needs. Rkward is the closest, but is way too feature rich for my needs. I am hoping that my R editor will be similar to ESS and TINN-R. I mostly just want syntax highlighting (which I already have partially implemented), the ability to easily send a line(s) of coding to a terminal using a keystroke (will default to Ctrl+R like RGui in Windows but will be configurable in a preferences dialog), the ability to launch R from the editor in a separate window (e.g. konsole, gnome-terminal, etc.), and the ability to run Sweave on the document. Maybe by the end of the summer I will be ready to release a preview or a beta version, but I am not sure.

Finally, and lowest down on the priority list, I plan on writing a MCMC program in C++. After creating this program and bolstering my C++ and MCMC skills, I will stop writing the program once I’ve learned enough (as it’s a didactic experience) and instead will actively contribute to JAGS or MCMCglmm or some other Bayesian program that can interact with R. Alternatively, I might consider trying to create a KDE/Qt frontend to JAGS that could also call R and rjags just to run the JAGS engine and nothing else. I am uninterested in a Qt fronted to R (btw, that’s called rkward).

But that’s a long way down the road.

Thoughts? Ideas? Comments?

h1

JAGS, rjags, and coda packages for Fedora 13 i386 & 64 bit

June 4, 2010

I spent the morning working on writing up a RPM spec file to package and maintain JAGS in Fedora. So hopefully my spec file looks good and my RPM can promptly be included in Fedora (hopefully 13). The beauty of this is that after installing JAGS from my RPM you don’t need to tell rjags where to look for JAGS because it’s already in a place where rjags will look by default. Also you don’t have to compile JAGS.

For the time being I am hosting the RPMs for jags i386 and jags 64 bit and jags-devel i386 and jags-devel 64 bit on Dropbox. Once they are accepted into Fedora they will be removed from Dropbox.

EDIT: This afternoon I packaged up rjags and coda for Fedora (also submitted for review). I hope to start maintaining these in Fedora. If you want to use them and try them out click here for rjags 64 bit and here for coda (both i386 and 64 bit) . Coda is platform independent but rjags is for 64 bit only. If you want to install rjags and you’re on a i386, just install the two JAGS rpms (jags and jags-devel) from above and fire up R and run:
install.packages("rjags")

And that should be it.

h1

JAGS and rjags for Fedora 13 64 bit

May 30, 2010

Unfortunately, JAGS is not in the Fedora repositories. However, it is very easy to install. This is a short how-to for installing JAGS and rjags for Fedora 13 64 bit and it should work for any 64 bit UNIX based OS. As a prerequisite, make sure you have the dependencies for JAGS installed (this is for Fedora only).

yum install R R-devel libblas-devel

Next thing you’ll want to do is to download the tarball and unpack it .

tar xvzf JAGS*

Next you need to tell it to install the libraries in /usr/local/lib64 otherwise you’ll need to tell rjags where to look for JAGS.

./configure --libdir=/usr/local/lib64
make
sudo make install

Next you can test that JAGS installed properly by typing:

jags

Once this is done, fire up R and install rjags like any other package and that’s it.

R
install.packages("rjags")

h1

GNU IceCat for Debian Squeeze 64 bit

May 25, 2010

I decided that I wanted a newer version of Firefox than 3.5.9 that was presently in Debian Squeeze. I read elsewhere that this would be the version that Squeeze would be shipping (Iceweasel 3.5.x) with and not Firefox 3.6.x. So I decided to roll my own. Rather then roll out the newer version of Iceweasel, I thought I would try GNU IceCat. I packaged up 3.6.3 for Squeeze 64 bit and if you’re interested you can download the 64 bit package here. I plan to continue to update this package if people are interested. Please let me know if you find it useful.

h1

MCMC CFA talk and update

May 21, 2010

As promised, here is my talk on how to run a Markov Chain Monte Carlo confirmatory factor analysis model in JAGS. Click here to download the talk. The talk is pretty complete. It provides a brief background on Bayesian, MCMC, CFA, and then some JAGS code. It also includes my tested model (using graphviz).

Feel free to leave comments on the talk.

This summer I am in the process of going through and reading Gelman’s Bayesian textbook. Last summer I worked through Bradley Carlin’s book and a few other books. I plan to adapt his code, especially the hierarchical modeling code, from BUGS to JAGS and I may post it here.

Also, it should be noted that all of my materials presented on this blog, including attachments, are released under a Creative Commons license or GNU GPL 3. Feel free to modify and distribute my materials as specified under the terms of these licenses.