Articles by Ken Kleinman

Example 7.20: Simulate categorical data

January 4, 2010 | Ken Kleinman

Both SAS and R provide means of simulating categorical data (see section 1.10.4). Alternatively, it is trivial to write code to do this directly. In this entry, we show how to do it once. In a future entry, we'll demonstrate writing a SAS Macro (section A.8.1) and a function in R (...
[Read more...]

Example 7.19: find the closest pair of observations

December 28, 2009 | Ken Kleinman

Suppose we need to find the closest pair of observations on some variable x. For example, we might be concerned that some data had been accidentally duplicated. We return the ID's of the two closest observations, and their distance from each other. In both languages, we'll first create the data, ...
[Read more...]

Example 7.18: Displaying missing value categories in a table

December 14, 2009 | Ken Kleinman

When displaying contingency tables (section 2.3.1), there are times when it is useful to either show or hide the missing data category. Both SAS and the typical R command default to displaying the table only for observations where both factors are observed.In this example, we generate some multinomial data (section 1.10.4) ...
[Read more...]

Example 7.15: A more complex sales graphic

October 13, 2009 | Ken Kleinman

The plot of Amazon sales rank over time generated in example 7.14 leaves questions. From a software perspective, we'd like to make the plot prettier, while we can embellish the plot to inform our interpretation about how the rank is calculated.For the latter purpose, we'll create an indicator of whether ...
[Read more...]

Example 7.14: A simple graphic of sales

September 29, 2009 | Ken Kleinman

In this example, we show a simple plot of the sales rank data read in as shown in example 7.13.SASIn SAS, we use the symbol statement (section 5.3) to request small (with the h option) dots (with the v option, and that the dots not be connected (with the i option. (...
[Read more...]

Example 7.10: Get data from R into SAS

August 13, 2009 | Ken Kleinman

In our previous entry, we described how to generate a dataset from SAS that could be used for analyses in R. Alternatively, someone primarily using R might want to test the new ”statistical graphics” procedures available starting with SAS 9.2. Her...
[Read more...]

Example 7.9: Get data from SAS into R

August 8, 2009 | Ken Kleinman

Some people use both SAS and R in their daily work. They might be more familiar with SAS as a tool for manipulating data and R preferable for plotting purposes. While our goal in the book is to enable people to avoid having to switch back and forth, ...
[Read more...]

Example 7.4: A prettier jittered scatterplot

July 2, 2009 | Ken Kleinman

The plot in section 7.3 has some problems. At the very least, the jittered values ought to be between 0 and 1, so the smoothed lines fit better with them. Once again we use the data generated in section 7.2 as an example. For both SAS and R, we use conditioning (section 1.11.2) to make ...
[Read more...]

Book now discounted 33% at Amazon!

June 24, 2009 | Ken Kleinman

Our book, SAS and R: Data Management, Statistical Analysis, and Graphics, is discounted by a full third at Amazon. With free shipping! Also, they claim if it is further discounted before it ships, they'll give you the reduced price.
[Read more...]

Example 7.2: Simulate data from a logistic regression

June 13, 2009 | Ken Kleinman

It might be useful to be able to simulate data from a logistic regression (section 4.1.1). Our process is to generate the linear predictor, then apply the inverse link, and finally draw from a distribution with this parameter. This approach is useful in that it can easily be applied to other ...
[Read more...]
1 4 5 6

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)