<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rense Nieuwenhuis &#187; R-Sessions</title>
	<atom:link href="http://www.rensenieuwenhuis.nl/tag/r-sessions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rensenieuwenhuis.nl</link>
	<description>&#34;The extra-ordinary lies within the curve of normality&#34;</description>
	<lastBuildDate>Thu, 12 Mar 2026 14:58:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>Applied R: Manual for the quantitative social scientist</title>
		<link>http://www.rensenieuwenhuis.nl/applied-r-manualfor-the-quantitative-social-scientist/</link>
		<comments>http://www.rensenieuwenhuis.nl/applied-r-manualfor-the-quantitative-social-scientist/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 10:50:31 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=1425</guid>
		<description><![CDATA[Applied R for the quantitative social scientist is a manual on R written specifically as an introduction for the quantitative social scientist. To my opinion, R-Project is a magnificent statistical program, ready to be accepted and implemented in the social sciences. The flexibility of this program and the way data are handled gives the user a sense of closeness to and control over the data. I think this inspires users to analyze their data more creatively and sometimes in a more advanced way.]]></description>
				<content:encoded><![CDATA[<p>R-Project is an advanced software package for statistical analysis. Several years ago, already, I wrote an introductory manual for several analyses that can be performed with R. Although several parts of this are available from my blog as the <a href="http://www.rensenieuwenhuis.nl/index-of-the-r-sessions/">R-Sessions</a>, I never publicly published the full document. Now, this changes: for those looking for an applied guide to R-Project, <a href="http://www.rensenieuwenhuis.nl/documents/Applied%20R.pdf">here it is!</a></p>
<p>This manual was written specifically as an introduction for the quantitative social scientist. To my opinion, R-Project is a magnificent statistical program, ready to be accepted and implemented in the social sciences. The flexibility of this program and the way data are handled gives the user a sense of closeness to and control over the data. I think this inspires users to analyze their data more creatively and sometimes in a more advanced way. At present, this manual has a strong focus on multilevel regression techniques. Reason for this is that in R-Project it is very easy to estimate these types of models, even the more complex variants. The more basic and fundamental aspects of R-Project are introduced as well. All this is done with the needs of the quantitative social scientist in mind.</p>
<p>Of course, this manual it provided without any warranty. Please realize that I wrote it almost four years ago. </p>
<p>I&#8217;d love to hear any feedback for (future) improvements!</p>
<h2>Download:</h2>
<p> <a href="http://www.rensenieuwenhuis.nl/documents/Applied%20R.pdf"> Applied R for the quantitative social scientist</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/applied-r-manualfor-the-quantitative-social-scientist/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Index of the R-Sessions</title>
		<link>http://www.rensenieuwenhuis.nl/index-of-the-r-sessions/</link>
		<comments>http://www.rensenieuwenhuis.nl/index-of-the-r-sessions/#comments</comments>
		<pubDate>Mon, 17 May 2010 10:00:19 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=1209</guid>
		<description><![CDATA[The R-Sessions are a series of blog entries on using R. A large part consists of an R-manual I once wrote. Other posts include some tricks I found out, as well as entries detailing functions ...]]></description>
				<content:encoded><![CDATA[<p>The R-Sessions are a series of blog entries on using R. A large part consists of an R-manual I once wrote. Other posts include some tricks I found out, as well as entries detailing functions and packages I wrote for R. The series already entails over forty posts, so I decided to create an index. It is found below. On a fixed page on this website (<a href="http://www.rensenieuwenhuis.nl/r-project/r-sessions-index/">www.rensenieuwenhuis.nl/r-project/r-sessions-index/</a>) I will continue to update this index with new editions of the R-Sessions.</p>
<p><a href="http://www.rensenieuwenhuis.nl/applied-r-manualfor-the-quantitative-social-scientist/">A .PDF manual containing many of the R-Sessions material is available here.</a></p>
<p><span id="more-1209"></span></p>
<h2>Introducing R</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-introducing-the-r-sessions/">Introducing the R-Sessions</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-01-what-is-r/">What is R?</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-02-why-r-project/">Why R-Project?</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-03-getting-r-project/">Getting R-Project</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-04/">Getting Packages</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-05-getting-help/">Getting Help</a></li>
</ul>
<h2>Data Manipultion</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-06-most-basic-of-all/">Most Basic of All</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-07-data-structure/">Data Structure</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-08-getting-data-into-r/">Getting Data into R</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-09-data-manipulation/">Data Manipulation</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-10-conditionals/">Conditionals</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-11-tables/">Tables</a></li>
</ul>
<h2>Graphics</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-12-basic-graphics/">Basic Graphics</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-13-overlapping-data-points/">Overlapping Data Points</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-14-multiple-graphs/">Multiple Graphs</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-15-intermediate-graphics/">Intermediate Graphics</a></li>
</ul>
<h2>Mixed Models</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-16-multilevel-model-specification-lme4/">Multilevel Model Specification: LME4</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-17-generalized-multilevel-lme4/">Generalized Multilevel: LME4</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-18-helper-functions/">Helper Functions</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-19-extractor-functions/">Extractor Functions: NLME</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-21-multilevel-model-specification-nlme/">Multilevel Model Specification: NLME</a></li>
</ul>
<h2>Influence.ME: Tools for detecting influential cases in mixed models</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/introducing-influenceme/">Introducing Influence.ME</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-project/influenceme/overview/">Influence.ME Overview</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-project/influenceme/influence-me-manual/">Influence.ME Manual</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/influence-me-simple-analysis/">Influence.ME: Simple Analysis</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/influence-me-dont-specify-the-intercept/">Specification of the intercept</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-project/influenceme/change-log/">Influence.ME: Change-log</a></li>
</ul>
<h2>Some small functions I wrote</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-32/">Forward.lmer: Basic stepwise function for mixed effects in R</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-31-combining-lmer-output-in-a-single-table/">Combining Output in a Single Table</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-33-select-nested-observations-with-equal-number-of-occurences/">Select Nested Observations with Equal Number of Occurences</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-30-visualizing-missing-values/">Visualizing Missing Values</a></li>
</ul>
<h2>Books</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-25-book-mixed-effects-models-in-s-and-s-plus-pinheiro-bates-2000/">Book: Mixed Effects Models in S and S-Plus (Pinheiro &#038; Bates, 2000)</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-24/">Book: An R and S-PLUS Companion to Applied Regression (Fox, 2002)</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-23-book-data-analysis-using-regression-and-multilevelhierarchical-models-gelman-hill-2007/">Book: Data Analysis using Regression and Multilevel / Hierarchical Models (Gelman &#038; Hill, 2007)</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-22-introductory-statistics-with-r-peter-dalgaard-2002/">Book: Introductory Statistics with R (Dalgaard, 2002)</a></li>
</ul>
<h2>Various</h2>
<ul>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-29-running-r-project-twice-on-apple-mac-os-x/">Running R Twice on Apple Mac OS X</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-28-impressive-r-speeds/">Impressive R Speeds</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-27/">Text Editors for R: Textmate</a></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-sessions-26-text-editors-for-r-internal-editor-on-os-x/">Text Editors for R: Internal Editor on OS X></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/index-of-the-r-sessions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>R Sessions 33: Select (nested) observations with equal number of occurences</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-33-select-nested-observations-with-equal-number-of-occurences/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-33-select-nested-observations-with-equal-number-of-occurences/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 10:00:05 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[balanced data]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[subset]]></category>
		<category><![CDATA[unbalanced data]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=1107</guid>
		<description><![CDATA[Recently, I was contacted with an question about R code. A befriended researcher was working with nested data, which was unbalanced. He was working with data in a &#8216;long&#8217; format: all observations nested within the ...]]></description>
				<content:encoded><![CDATA[<p>Recently, I was contacted with an question about R code. A befriended researcher was working with nested data, which was unbalanced. He was working with data in a &#8216;long&#8217; format: all observations nested within the same group had the same identification number. But, the number of observations in each of the groups differed (hence: unbalanced data).</p>
<p>He asked me for a piece of code that creates a subset of the data that <i>is</i> balanced, i.e. all observations that are nested within equally sized groups. Or, as an alternative, all observations nested within groups with at least a minimum number of observations.</p>
<p>I solved it the quick and dirty way, and the solution involves creating additional variables, a new data.frame, and merging. It sure can be done much prettier, but it works. </p>
<p>So, I share it below:<br />
<span id="more-1107"></span></p>
<p><code><br />
id <- c("a", "b","b", "c","c","c", "d","d","d","d", "e","e","e")<br />
y <-  c(3,4,3,2,4,5,6,5,6,7,5,4,3)<br />
df <- data.frame(id, y) # setting up original data.frame</p>
<p>tab <- data.frame(id=names(table(df$id)), fre=as.vector(table(df$id))) # table of frequencies</p>
<p>df.new <- merge(df, tab, by="id") # merging frequencies-variable</p>
<p>subset(df.new, fre==3) # subsetting<br />
subset(df.new, fre>3)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-33-select-nested-observations-with-equal-number-of-occurences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 31: Combining lmer output in a single table (UPDATED)</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-31-combining-lmer-output-in-a-single-table/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-31-combining-lmer-output-in-a-single-table/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 11:00:38 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[lme4]]></category>
		<category><![CDATA[lmer]]></category>
		<category><![CDATA[mixed effect models]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=891</guid>
		<description><![CDATA[There are various ways of getting your output from R to your publication draft. Most of them are highly efficient, but unfortunately I couldn&#8217;t find a function that combines the output from several (lmer) models ...]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img title="R-Sessions" src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" alt="" data-recalc-dims="1" /></a><br />
<!--adsense--></p>
<p>There are various ways of getting your output from R to your publication draft. Most of them are highly efficient, but unfortunately I couldn&#8217;t find a function that combines the output from several (lmer) models and presents it in a single table. lmer is the mixed effects model function from the lme4 package. So, I wrote a simple function that does exactly that.<br />
<span id="more-891"></span></p>
<p>Using it for a specific purpose, it is not a general function or something, but it can easily be adapted for use in other settings. Here it goes:</p>
<p><code><br />
require(lme4)<br />
require(mlmRev)<br />
require(lme4)<br />
require(mlmRev)</p>
<p>model.1 <- lmer(normexam ~ 1 + (1 | school), data=Exam)<br />
model.2 <- lmer(normexam ~ standLRT + (1 | school), data=Exam)<br />
model.3 <- lmer(normexam ~ standLRT + sex + (1 | school), data=Exam)<br />
model.4 <- lmer(normexam ~ standLRT + sex + schavg + (1 | school), data=Exam)</p>
<p>model.a <- lmer(use ~ 1 + (1 | district), family=binomial, data=Contraception)<br />
model.b <- lmer(use ~ livch + (1 | district), family=binomial, data=Contraception)<br />
model.c <- lmer(use ~ age + (1 | district), family=binomial, data=Contraception)<br />
model.d <- lmer(use ~ livch + age + (1 | district), family=binomial, data=Contraception)</p>
<p>m1 <- c(model.1, model.2, model.3, model.4)<br />
m2 <- c(model.a, model.b, model.c, model.d)</p>
<p>combine.output.lmer <- function(models, labels=FALSE)<br />
	{</p>
<p>	fix.coef <- lapply(models, function(x) summary(x)@coefs)<br />
	var.coef <- lapply(models, function(x) summary(x)@REmat)<br />
	n.par <- dim(summary(models[[1]])@coefs)[2]</p>
<p>	ifelse(labels==FALSE,<br />
		fix.labels <- colnames(summary(models[[1]])@coefs),<br />
		fix.labels <- labels)</p>
<p>	var.labels <- colnames(var.coef[[1]])</p>
<p>	# Creating table with fixed parameters<br />
	output.coefs <- data.frame(Row.names=row.names(fix.coef[[1]]))<br />
	for (i in 1:length(models))<br />
		{</p>
<p>		a <- fix.coef[[i]]<br />
		colnames(a) <- paste("Model", i, fix.labels)<br />
		output.coefs <- merge(output.coefs, a, by.x=1, by.y=0, all=T, sort=FALSE)</p>
<p>		}<br />
	output.coefs[,1] <- as.character(output.coefs[,1])<br />
	output.coefs[dim(output.coefs)[1]+2, 1] <- "Loglikelihood"<br />
	LL <- unlist(lapply(models, function(x) as.numeric(logLik(x))))<br />
	output.coefs[dim(output.coefs)[1], 1:length(models)*n.par-n.par+2] <- LL</p>
<p>	# Creating table with random parameters<br />
	output.vars <- data.frame(var.coef[[1]])[,1:2]<br />
	for (i in 1:length(models))<br />
		{</p>
<p>		a <- var.coef[[i]]<br />
		colnames(a) <- paste("Model", i, var.labels)<br />
		output.vars <- merge(output.vars, a, by.x=1:2, by.y=1:2, all=T, sort=FALSE)</p>
<p>		}</p>
<p>	# Combining output.coefs and output.vars<br />
	n.cols <- dim(output.coefs)[2]<br />
	n.coefs <- dim(output.coefs)[1]<br />
	n.vars <- dim(output.vars)[1]</p>
<p>	output <- matrix(ncol=n.cols +1 , nrow=n.vars+n.coefs+2)</p>
<p>	output[1:n.coefs, -2] <- as.matrix(output.coefs)<br />
	output[n.coefs+2, 1] <- "Variance Components"<br />
	output[(n.coefs+3) : (n.coefs+n.vars+2), 1:2] <- as.matrix(output.vars[,1:2])<br />
	output[<br />
		(n.coefs+3) : (n.coefs+n.vars+2),<br />
		which(rep(c(1,1,rep(0, n.par-2)),length(models))!=0)+2] <- as.matrix(output.vars[,c(-1,-2)])</p>
<p>	colnames(output) <- c("Parameter", "Random", colnames(output.coefs)[-1])</p>
<p>	return(output)<br />
	}</p>
<p>combined <- combine.output.lmer(m1)<br />
combined <- combine.output.lmer(m2)</p>
<p>combined <- combine.output.lmer(m1, labels=c("appel", "banaan", "grapefruit"))<br />
combined <- combine.output.lmer(m2, labels=c("appel", "peer", "banaan", "grapefruit"))</p>
<p>write.csv(combined, "combined.csv", na=" ")<br />
</code></p>
<p>In this example I estimate four mixed effects models, which are concatenated in a single object 'm'. The function itself is called 'combine.output.lmer', and is used on the object 'm'. The output is a data.frame with the variable names in the first column. Not-estimated parameters in models are indicated by 'NA' in their respective columns. By writing the 'combined'-object to an external file, the NA's are lost and the file can be read into other software, such as Open Office Spreadsheet or Excell. Use the xtable-package to get it in your latex document. </p>
<p>UPDATE<br />
I updated and improved the code somewhat, for I wasn't satisfied with the results. Now the code adapts to the number of parameters derived form the models' summary, allows to add your own names to the columns, and, most importantly, also reports the random slopes.</p>
<p>Please note: due to the internal matching procedure, errors may occur when the same variable is random 'within' more than one other variable. This is only the case when other variables are random within each nesting factor as well. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-31-combining-lmer-output-in-a-single-table/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>R-Sessions 30: Visualizing missing values</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-30-visualizing-missing-values/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-30-visualizing-missing-values/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 10:00:39 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[GSS]]></category>
		<category><![CDATA[GSS cumulative file]]></category>
		<category><![CDATA[Missing values]]></category>
		<category><![CDATA[R-Project]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=872</guid>
		<description><![CDATA[<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img title="R-Sessions" src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg" alt="" width="470" /></a> 

It always takes some time to get a grip on a new dataset, especially large ones. The code-books are often as indispensable as they are massive, and not always as clear as one would want. Routings, and resulting and strange patterns of missing values are at times difficult to find.

I found a nice way to plot missing values, using R. Basically, I thought it would be nice to calculate the percentage of missings on each variable, and do so for each year represented in the data. These numbers could be visualized using a levelplot(), which resulted in the graph below.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img title="R-Sessions" src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" alt="" data-recalc-dims="1" /></a> </p>
<p>It always takes some time to get a grip on a new dataset, especially large ones. The code-books are often as indispensable as they are massive, and not always as clear as one would want. Routings, and resulting and strange patterns of missing values are at times difficult to find.</p>
<p>I found a nice way to plot missing values, using R. Basically, I thought it would be nice to calculate the percentage of missings on each variable, and do so for each year represented in the data. These numbers could be visualized using a levelplot(), which resulted in the graph below.</p>
<p><a href="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2009/01/missings.jpg"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2009/01/missings.jpg?w=450" alt="missings" title="missings" class="alignnone size-medium wp-image-873" data-recalc-dims="1" /></a><br />
<span id="more-872"></span><br />
In this example I used a small subset of variables from the <a href="http://www.icpsr.umich.edu/cocoon/ICPSR/STUDY/04697.xml">cumulative file of the General Social Survey</a>, which is freely available from the web. I used this syntax:</p>
<p><code><br />
testing.NA <- matrix(ncol=26, nrow=21)<br />
for (i in 1:dim(GSS)[2])<br />
	{<br />
	testing.NA[i,] <- tapply(GSS[[i]], GSS$year, function(x) sum(is.na(x)) / length(x))<br />
	}</p>
<p>dimnames(testing.NA) <- list(<br />
	names(GSS),<br />
	sort(unique(GSS$year)))</p>
<p>library(lattice)</p>
<p>levelplot(testing.NA,<br />
	scales=list(x=list(rot=90)),<br />
	main="Percentage missing values on variables in GSS",<br />
	xlab="Variable",<br />
	ylab="Year")<br />
</code></p>
<p>First, I defined the testing.NA matrix, using the number of years and variables. Then, in a loop, I calculate the percentage missing values, basically using is.na() and length(). I assign dimnames to the matrix and use the levelplot() function from the lattice-library to plot the matrix. That's it, easy does it.</p>
<p>But: does it help? I think it does. Of course, all this information can be gained from the code-book, and needs to be verified. However, it does give us some immediate notes on the availability of these variables. For instance, we see that in the first few years, the abany variable is missing, whereas other variables on abortion don't. When creating scales this needs to be taken into account, not to lose the complete data on the first few years. The speduc-variable (spouse's educational level) has a high number of missings, as does the denom variable. This, however, makes sense: not everybody has a spouse and the denom-variable only applies to protestants. Finally, this graph gives some pointers on a change in survey-strategy from 1988 onwards regarding the items on induced abortion. The percentage missing values increased sharply at that point, and does so for all abortion-related variables. </p>
<p>This graph does not tell what exactly happened, but does provides nice pointers on what to look for when reading the code-book. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-30-visualizing-missing-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>R-Sessions 29: Running R-Project twice on Apple Mac OS X</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-29-running-r-project-twice-on-apple-mac-os-x/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-29-running-r-project-twice-on-apple-mac-os-x/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 10:00:40 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[statistical software]]></category>
		<category><![CDATA[twice]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=835</guid>
		<description><![CDATA[Working with statistics can be quite time consuming. As anyone working with relatively advanced models and large amounts of data knows, especially the waiting can be excruciating. Your statistical software is locked up while crunching those numbers, while you'd actually prefer to run some minor procedures, such as post-estimations, testing some loops, or simply displaying the output of a previously estimated model. With Apple's Mac OS X you now can run R-Project twice, making the most of your dual core processor. ]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img title="R-Sessions" src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" alt="" data-recalc-dims="1" /></a><br />
Working with statistics can be quite time consuming. As anyone working with relatively advanced models and large amounts of data knows, especially the waiting can be excruciating. Your statistical software is locked up while crunching those numbers, while you&#8217;d actually prefer to run some minor procedures, such as post-estimations, testing some loops, or simply displaying the output of a previously estimated model. With Apple&#8217;s Mac OS X you now can run R-Project twice, making the most of your dual core processor. <span id="more-835"></span></p>
<p>The procedure is very easy, and it works like a charm. Mind though that, obviously, it drains your computers&#8217; resources heavily, so performance of each instance of R-Project decreases slightly at least. For that to change, we would need dual-hard disk laptops, and dual-RAM laptops and the such. Dual laptop-laptops basically.</p>
<p><img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/r-copy.jpg?resize=500%2C287" alt="" title="Duplicating R-Project to run it twice" class="aligncenter size-full wp-image-837" data-recalc-dims="1" /></p>
<p>Back to running R-Project twice. Just start R-Project as usual. Then go to your applications folder and secondary-click on the R-Project app. Select &#8216;duplicate&#8217;, and there you are: an app named R copy emerges. Start this as usual and start working. </p>
<p>in the image below you see two instances of R-Project running. The first is working on a heavy-weight function that results in some output every hour or so and runs 96 times. In other words: it takes ages. However, it stores the output in an external file, and since each little bit of output needs some post-estimation before being interpreted, I can use the second instance to load that data and examine it (not shown).</p>
<p><a href="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/2-r.jpg"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/2-r.jpg?w=470" alt="" title="R-Project running twice on Mac OS X" class="alignnone size-medium wp-image-836" data-recalc-dims="1" /></a></p>
<p>Although you don&#8217;t need to re-install packages, the only thing I did not (yet) find out how to do is to share resources between these two instances of R-Project. Being able to share variables, models, and such would be great. Ideas anyone? </p>
<p><!--adsense--></p>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><strong><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-29-running-r-project-twice-on-apple-mac-os-x">Discuss this article and pose additional questions in the R-Sessions Forum</a></strong></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-29-running-r-project-twice-on-apple-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>R-Sessions 28: Impressive R Speeds</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-28-impressive-r-speeds/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-28-impressive-r-speeds/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 10:00:22 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[R-Project]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[system.time]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=778</guid>
		<description><![CDATA[Yesterday, I received my new Apple MacBook. It's running a Core 2 Duo at 2.4 Ghz and it's fast. Really fast! I tested it with using R-Project, doing some timings on matrix transformations.

Apparently, it's very cool to show of the speed of R-Project on your system. Optimized .DLL files help to speed up your R on Windows systems (and possibly other systems as well) with respect to matrix transformations, which has led to enormous speed increases. So, let's perform a speed-test of our own.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img title="R-Sessions" src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" alt="" data-recalc-dims="1" /></a> </p>
<p>Yesterday, I received my new Apple MacBook. It&#8217;s running a Core 2 Duo at 2.4 Ghz and it&#8217;s fast. Really fast!</p>
<p>Apparently, it&#8217;s very cool to show of the speed of R-Project on your system. <a href="http://cran.r-project.org/bin/windows/contrib/ATLAS/">Optimized .DLL files</a> help to speed up your R on Windows systems (and possibly other systems as well) with respect to matrix transformations, which has led to enormous speed increases. So, let&#8217;s perform a speed-test of our own.<br />
<span id="more-778"></span></p>
<p>First of all, in the syntax below, the Matrix package is activated, using the require() command. Since we will be creating random data, we set the seed in order to receive the exact same data every time the test is run. This is done with set.seed(). The next line creates a matrix X, which in the last three lines is manipulated in different ways. </p>
<p>To test how long this takes, we enclose that matrix operations in the system.time() function, which clocks the operation.</p>
<p><code><br />
require(Matrix)<br />
set.seed(123)<br />
X <- Matrix(rnorm(1e6), 1000)<br />
system.time(for(i in 1:25) X%*%X)<br />
system.time(for(i in 1:25) solve(X))<br />
system.time(for(i in 1:10) svd(X))<br />
</code></p>
<p>This results in the following output:</p>
<p><code><br />
> X <- Matrix(rnorm(1e6), 1000)<br />
> system.time(for(i in 1:25) X%*%X)<br />
   user  system elapsed<br />
  8.306   0.591   5.031<br />
> system.time(for(i in 1:25) solve(X))<br />
   user  system elapsed<br />
  8.933   1.331   6.684<br />
> system.time(for(i in 1:10) svd(X))<br />
   user  system elapsed<br />
 36.989   3.665  33.384<br />
 </code></p>
<p>WOW! This is the <a href="http://stijnr.socsci.ru.nl/blog/?p=228">fastest I've seen in real life</a>, even faster than some of the desktops that I know people currently work with (i.e. my own). I'm however very sure that it is not the fastest possible, not to say compared with how fast future calculations will be. </p>
<p>Additionally, in the near future my MacBook will be configured with 4 Gb RAM, so I'm curious to find out whether or not this will result in an additional speed increase. I expect, however, most benefit from the additional RAM when doing binomial mixed effects models, so of course expect a comparative benchmark on that one as well as soon as the new RAM arrives.</p>
<p>So, in the meantime, you can use this code to do some benchmarks yourself, on various computers. Please post the results here, or discuss them in the R-Sessions Forum.</p>
<p>UPDATE:<br />
I also tested my old Powerbook G4 (1.5 Ghz, 1.25 Gb RAM):<br />
<code><br />
> set.seed(123)<br />
> X <- Matrix(rnorm(1e6), 1000)<br />
> system.time(for(i in 1:25) X%*%X)<br />
   user  system elapsed<br />
 34.661   1.590  47.528<br />
> system.time(for(i in 1:25) solve(X))<br />
   user  system elapsed<br />
 37.184   1.656  51.516<br />
> system.time(for(i in 1:10) svd(X))<br />
   user  system elapsed<br />
247.694  11.258 331.979<br />
</code></p>
<p><!--adsense--></p>
<p>- - -- --- ----- --------</p>
<ul>
<li><strong><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-28-impressive-r-speeds">Discuss this article and pose additional questions in the R-Sessions Forum</a></strong></li>
</ul>
<p>- - -- --- ----- --------<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
-------- ----- --- -- - -</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-28-impressive-r-speeds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>R Sessions 26: Text editors for R: Internal editor on OS X</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-26-text-editors-for-r-internal-editor-on-os-x/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-26-text-editors-for-r-internal-editor-on-os-x/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 10:00:38 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[text editor]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=654</guid>
		<description><![CDATA[<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg" " title="R-Sessions" width="470" /></a>
Since <a href="www.r-project.org">R-Project</a> is essentially syntax based, one needs a good text editor to write some code before it is executed in R. And, since we are all writing high quality code, we need a high quality text editor. This is the first in a series on text editors for using with R-Project on MacOSX.

The first editor to look at, is the internal one. The Mac OS X version of R-Project comes with quite a strong, although basic, text editor.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a><br />
<!--adsense--></p>
<p>Since <a href="www.r-project.org">R-Project</a> is essentially syntax based, one needs a good text editor to write some code before it is executed in R. And, since we are all writing high quality code, we need a high quality text editor. This is the first in a series on text editors for using with R-Project on MacOSX.<br />
<span id="more-654"></span><br />
The first editor to look at, is the internal one. The Mac OS X version of R-Project comes with quite a strong, although basic, text editor. It is shown in the picture below, where it is being used to edit a fragment of code of my own. We readily see some syntax coloring, which is a great help regarding the readability of the syntax (syntax colouring is only available in the Mac OS X version of R-Project). Also, on the top of the window, a drop-down list is shown, which now shows `dp.HI.cook&#8217;, which happens to be the name of one of the functions that is defined in the syntax file. By clicking one of the items in this drop-down list, the cursor automatically jumps to that section of the file, allowing for fast and easy navigation. As to be expected, the code can easily be send from the editor to the R prompt, where it is executed. </p>
<p><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/10/r-project-text-editor.jpg?resize=500%2C473" alt="" title="r-project-text-editor" class="alignnone size-full wp-image-655" data-recalc-dims="1" /></p>
<p>To my liking, this editor is just a little too light-weight. It does a nice job colouring the syntax and such, but it lacks on other features such as advanced find &#038; replace, or management of multiple files. If you&#8217;re editing more than a single file, you will be doing it in more than a single window, which might be a little inconvenient. Also, when working on large files for a longer period, I found that at times the text wasn&#8217;t rendered any-longer. I then had to save and re-open the file. Also, working on long files can be a tad slow, for it seems that the text-colouring tends to run behind easily. </p>
<p>Nevertheless, having your text editor integrated in R-Project does have one strong advantage: the syntax help provided by the Mac OS X version of R-Project is also shown in the editor. So, if you type the name of a function and the opening bracket &#8216;(&#8216;, you immediately see all the pre-defined parameters to that function. This greatly reduces the necessity of using the help-pages and is provided by only a very few of the external editors.</p>
<p>All in all, the internal editor of R-Project is not bad at all, particularly on Mac OS X. For simple analyses and writing or editing of some small helper functions, it suffices. However, for more serious projects it will soon prove to be too ill equipped. Fortunately, we have some excellent external text editors for this, some of which will be discussed in the upcoming <a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a>. </p>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/R-forum/">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-26-text-editors-for-r-internal-editor-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 25: Book &#8211; Mixed Effects Models in S and S-PLUS (Pinheiro &amp; Bates, 2000)</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-25-book-mixed-effects-models-in-s-and-s-plus-pinheiro-bates-2000/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-25-book-mixed-effects-models-in-s-and-s-plus-pinheiro-bates-2000/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 10:00:51 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[hierarchical]]></category>
		<category><![CDATA[mixed effects models]]></category>
		<category><![CDATA[multilevel]]></category>
		<category><![CDATA[R-Project]]></category>
		<category><![CDATA[regression]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=628</guid>
		<description><![CDATA[<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg" " title="R-Sessions" width="470" /></a>
<img src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/cover-pinheiro.png" alt="Cover: Mixed-Effects Models in S and S-PLUS" />
Despite the reference to S and S-PLUS in the title of this book, it offers an excellent guide for the nlme-package in R-Project. Reason for this is the close resemblance between R and S. The nlme-package, available in R-Project for estimation of both linear and non-linear multilevel models, is written and maintained by the authors of this book.

]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a><br />
<!--adsense--></p>
<p>Despite the reference to S and S-PLUS in the title of this book, it offers an excellent guide for the nlme-package in R-Project. Reason for this is the close resemblance between R and S. The nlme-package, available in R-Project for estimation of both linear and non-linear multilevel models, is written and maintained by the authors of this book.<br />
<span id="more-628"></span><br />
The book is not an introduction to R. Basic knowledge of R-Project (or S / S-PLUS) is required to get the most out of it, as well as some knowledge on multilevel theory. Although the book forms a thorough introduction to multilevel modeling, addressing both some theory, the mathematics and of course the estimation and specification in R-Project (or S / S-PLUS), the learning curve it offers is quite steep. The authors are not shunned to apply matrix algebra and specify exactly the used estimation procedures.</p>
<p>Not only the specification of basic models is described, but many other subjects are brought up. A specific grouped-data object is considered, as well as ways to visualize hierarchical data and multilevel models. Heteroscedasticity, often a violation of assumptions, can be caught in the models easily, as is described clearly in one of the chapters. Finally, not only linear models are tackled, but non-linear models as well.</p>
<p>All in all, this book is an excellent addition for those who have prior knowledge of both R-Project and multilevel analysis. Using real-data examples and by providing tons of output, the authors accomplish to make clear the necessity of the more complex models and thereby invite the reader to invest time for the more fundamental aspects of multilevel analysis.</p>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/R-forum/">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><a href="http://www.rensenieuwenhuis.nl/r-project/books/pinheiro-bates-2000/">Find the original article embedded in the manual.</a></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-25-book-mixed-effects-models-in-s-and-s-plus-pinheiro-bates-2000/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>R-Sessions 23: Book: Data Analysis Using Regression and Multilevel/Hierarchical Models &#8212; Gelman &amp; Hill (2007)</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-23-book-data-analysis-using-regression-and-multilevelhierarchical-models-gelman-hill-2007/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-23-book-data-analysis-using-regression-and-multilevelhierarchical-models-gelman-hill-2007/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 10:00:05 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Andrew Gelman]]></category>
		<category><![CDATA[hierarchical]]></category>
		<category><![CDATA[Jennifer Hill]]></category>
		<category><![CDATA[multilevel]]></category>
		<category><![CDATA[regression]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=608</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<h2>Data Analysis Using Regression and Multilevel/Hierarchical Models</h2>
<p><a href="http://www.stat.columbia.edu/%7Egelman/arm/"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/cover-gelmann.png?w=200" alt="Cover Gelman" data-recalc-dims="1" /></a>  Andrew Gelman is known for his expertise on Bayesian statistics. Based on that knowledge he wrote a book in multilevel regression using R and WINbugs. This book aims to be a thorough description of (multilevel) regression techniques, implementation of these techniques in R and bugs, and a guide on interpreting the results of your analyses. Shortly put, the books excels on all three subjects.<br />
<span id="more-608"></span><br />
<br />
 Admittedly, this review has been written based on first impressions on the book. But, a sunny day in the park reading this book (literally) left me to believe that I have some understanding on what this book is trying to achieve. I bought this book in order to have an overview on fitting multilevel regression models using R. Starting to read the book, I soon found out that that is indeed what it has to offer me, but it offers me a lot more.  After some introductory chapters, the book starts off with an introduction to both linear regression as well as introducing the reader to R software, by showing how to fit linear regression models in R. This is readily expanded to logistic regression and generalized regression models. All is illustrated lushly with many examples and illustrations. </p>
<p>Before these &#8216;basic&#8217; regression models are extended to multilevel models, Bayesian statistics are introduced. Based on simulation techniques, causal inferences, based on regression models, are made.  The multilevel section of the book is set up similarly. First, &#8216;basic&#8217; multilevel regression models are introduced. Throughout the book, the lmer function is used. This function is not only able to fit simple multilevel models, but logistic and generalized models as well. It can even estimate non-nested models. All in all, this forms a thorough introduction to multilevel regression analysis in itself, but the book continues here as well to introduce the reader to Bayesian statistics. </p>
<p>All above-mentioned models, as well as more complicated models, are fitted using WINbugs as well. This very flexible method allows the reader to estimate a greater variety of (multilevel) models. Causal inference on multilevel models, using Bayesian statistics, is described as well.  The third main part of the book elaborates on the skills the reader uses to &#8216;just&#8217; fitting models. It learns the reader to really think about what it going on. Topics such as &#8216;understanding and summarizing the fitted models&#8217;, &#8216;sample size and power calculations&#8217;, and most of all &#8216;model checking and comparison&#8217; each receive their own chapter of the book. In this we can see that the authors of this book aimed higher than just writing instructions on how to let R fit (multilevel) regression models. The aim of this book, is to teach the reader how to analyze data the proper way. Much attention is paid to assumptions, testing theory, and interpretation of what you&#8217;re doing. To quote the authors: &#8220;If you show something, be prepared to explain it&#8221;. </p>
<p>This philosophy seemed to be a guideline for the authors while writing this book, as well as flexibility. The book starts off with some examples of the authors&#8217; own research. These examples return throughout the book, resulting in some degree of familiarity with the data by the reader. Due to this, the concepts, models and/or analyses described are certainly more easy to be understood. As a reader, you start to think along with the author, when a new problem is described. The relative worth of the techniques, as well as their drawbacks, are made perfectly clear. The use of R software, as well as WINbugs, pays of well in the sense that it requires some more effort to master these programs, but in that process the reader learns to think deeply about what he really want to do and how it is done properly.  </p>
<p>I found it not an easy book, but thanks to the many examples throughout the book it can be fully understood by people with some prior knowledge in regression techniques. All of the examples in the book can be tried yourself, since the data and syntax are available on the author&#8217;s website on the book. This helps the reader to get some feel for the more difficult subjects of the book. All in all, this seems to me as a great book for every applied researcher that has basic prior understanding of regression analysis. Due to its focus on one set of techniques, a great depth of understanding can be derived from this book.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-23-book-data-analysis-using-regression-and-multilevelhierarchical-models-gelman-hill-2007/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
