Publications by Nick Horton

Example 8.24: MplusAutomation and Mplus

07.02.2011

In recent entries (here, here, and here), we’ve been fitting a series of latent class models using SAS and R. One of the most commonly used and powerful software package for latent class model estimation is Mplus. This commercial software includes support for many features that are not presently available in R or SAS. As an exampl...

2333 sym R (2264 sym/5 pcs) 14 img

Example 8.25: more latent class models (plus a graphical display)

15.02.2011

In recent entries (here, here, here and here), we’ve been fitting a series of latent class models using SAS and R. One of the most commonly used and powerful package for latent class model estimation is Mplus. In this entry, we demonstrate how to use the MplusAutomation package to automate the process of fitting and interpreting a series of m...

2276 sym R (2498 sym/3 pcs) 16 img

Example 8.26: reading data with variable number of words in a field

22.02.2011

A student came with a question about how to snag data from a PDF report for analysis. Once she’d copied things her text file looked like:1 Las Vegas, NV --- 53.3 --- --- 1 2 Sacramento, CA --- 42.3 --- --- 2 3 Miami, FL --- 41.8 --- --- 3 4 Tucson, AZ --- 41.7 --- --- 4 5 Cleveland, OH --- 38.3 --- --- 5 6 Cincinnati, OH 15 36.4 --...

2765 sym R (2718 sym/6 pcs) 14 img

Example 8.27: using regular expressions to read data with variable number of words in a field

25.02.2011

A more or less anonymous reader commented on our last post, where we were reading data from a file with a varying number of fields. The format of the file was:1 Las Vegas, NV --- 53.3 --- --- 1 2 Sacramento, CA --- 42.3 --- --- 2 The complication in the number of fields related to spaces in the city field (which could vary from one t...

2356 sym R (607 sym/4 pcs) 14 img

Example 8.28: should we buy snowstorm insurance?

28.02.2011

It’s been a long winter so far in New England, with many a snow storm. In this entry, we consider a simulation to complement the analytic solution for a probability problem concerning snow. Consider a company that buys a policy to insure its revenue in the event of major snowstorms that shut down business. The policy pays nothing ...

1928 sym R (804 sym/6 pcs) 14 img

Example 8.34: lack of robustness of t test with small n

12.04.2011

Tim Hesterberg has effectively argued for a larger role for resampling based inference in introductory statistics courses (and statistical practice more generally). While the Central Limit Theorem is a glorious result, and the Student t-test remarkably robust, there are subtleties that Hesterberg, Jones and others have pointed out that are not a...

2621 sym R (3090 sym/6 pcs) 14 img

Example 8.36: Quadratic equation with real roots

29.04.2011

We often simulate data in SAS or R to confirm analytical results. For example, consider the following problem from the excellent text by Rice:Let U1, U2, and U3 be independent random variables uniform on [0, 1]. What is the probability that the roots of the quadratic U1*x^2 + U2*x + U3 are real?Recall that for a quadratic equation A...

1930 sym R (1055 sym/6 pcs) 14 img

To attach() or not attach(): that is the question

03.05.2011

R objects that reside in other R objects can require a lot of typing to access. For example, to refer to a variable x in a dataframe df, one could type df$x. This is no problem when the dataframe and variable names are short, but can become burdensome when longer names or repeated references are required, or objects in complicated s...

2550 sym R (601 sym/3 pcs) 14 img

Example 8.38: WriteXLS to create spreadsheets

16.05.2011

In our last entry, we described reading Excel files. In this entry, we do the opposite: write native Excel files.RIn R, the WriteXLS package provides this functionality. It uses perl to do the heavy lifting, and the main complication is to install this with the needed Perl modules. There are detailed instructions here. On Nick’s...

1800 sym R (535 sym/6 pcs) 14 img

another look at CRAN Task Views

26.05.2011

We’ve been impressed with how helpful the CRAN Task Views are in guiding us in R as we wend our way through the huge number of add-on packages (3021 as of May, 2011). These are web pages that are maintained by volunteers with expertise in a specified area. The maintainers provide annotated guidance to routines and packages. This ...

3023 sym 14 img