<?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; regression</title>
	<atom:link href="http://www.rensenieuwenhuis.nl/tag/regression/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>Weighted Effect Coding: New publication in the R Journal</title>
		<link>http://www.rensenieuwenhuis.nl/weighted-effect-coding-new-publication-in-the-r-journal/</link>
		<comments>http://www.rensenieuwenhuis.nl/weighted-effect-coding-new-publication-in-the-r-journal/#comments</comments>
		<pubDate>Mon, 03 Jul 2017 08:00:21 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Peer Reviewed]]></category>
		<category><![CDATA[R-Project]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[categorical]]></category>
		<category><![CDATA[dummy]]></category>
		<category><![CDATA[dummy coding]]></category>
		<category><![CDATA[factor]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[regression]]></category>
		<category><![CDATA[unbalanced data]]></category>
		<category><![CDATA[wec]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=6109</guid>
		<description><![CDATA[Weighted effect coding is a technique for dummy coding that can have attractive properties, particularly when analysing observational data. In a new publication in the R Journal we explain the rationale of weighted effect coding, ...]]></description>
				<content:encoded><![CDATA[<p>Weighted effect coding is a technique for dummy coding that can have attractive properties, particularly when analysing observational data. In a <a href="https://journal.r-project.org/archive/2017/RJ-2017-017/index.html">new publication in the R Journal</a> we explain the rationale of weighted effect coding, introduce the &#8216;wec&#8217; package, and provide examples that include interactions.</p>
<p>The attractive property of applying weighted effect coding to categorical (&#8216;factor&#8217;) variables is that each category represents the deviation of that category from the sample mean. This is unlike the more commonly used treatment coding where each a specific category has to be selected as a reference. Weighted effect coding is a generalized form of effect coding that applies to both balanced and unbalanced data. </p>
<p>A form of weighted effect coding was already formulated in 1972 by Sweeney and Ulveling, but it seems to never have found its place in statistical repertoires. Weighted effect coding was not implemented in mainstream statistical software. In an ongoing project, we have now further developed weighted effect coding to also apply to interactions (with both categorical and continuous variables), and provide procedures for mainstream statistical software. <a href="https://cran.r-project.org/web/packages/wec/index.html">For R, we developed the &#8216;wec&#8217; package</a>, and <a href="http://www.ru.nl/sociology/mt/wec/downloads/">procedures for STATA and SPSS are available as well.</a></p>
<p>A key innovation in our article in the R Journal is the formulation of interactions between a categorical variable with a continuous variable. This is visualised in the Figure above. The benefit of estimating such an interaction with weighted effect coding is that upon entering the interaction terms the estimate for the continous variable (as well as the &#8216;main effects&#8217; for the categorical variable) does not change. The &#8216;main&#8217; continous term reflects the average effect in the sample, and the interaction terms represent the deviation of the effect size for each category. </p>
<h2>References</h2>
<p><a href="http://doi.org/10.1007/s00038-016-0902-0">Grotenhuis, Te, M, Pelzer, B., Eisinga, R., Nieuwenhuis, R., Schmidt-Catran, A., &#038; Konig, R. (2017b). A novel method for modelling interaction between categorical variables. International Journal of Public Health, 62(3), 427–431. (open access!) </a></p>
<p><a href="http://doi.org/10.1007/s00038-016-0901-1">Grotenhuis, Manfred, Ben Pelzer, Eisinga, R., Nieuwenhuis, R., Schmidt-Catran, A., &#038; Konig, R. (2017a). When size matters: advantages of weighted effect coding in observational studies. International Journal of Public Health, (62), 163–167. (open access!) </a></p>
<p><a href="https://journal.r-project.org/archive/2017/RJ-2017-017/index.html">Nieuwenhuis, R., Grotenhuis, Te, M., &#038; Pelzer, B. (2017). Weighted Effect Coding for Observational Data with wec. R Journal, 9(1), 477–485.  (open access!)</a></p>
<p><a href="http://amstat.tandfonline.com/doi/abs/10.1080/00031305.1972.10478949?journalCode=utas20">Sweeney, R. E., &#038; Ulveling, E. F. (1972). A transformation for simplifying the interpretation of coefficients of binary variables in regression analysis. The American Statistician.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/weighted-effect-coding-new-publication-in-the-r-journal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Super Crunchers &#8211; Ayres (2007) &#8211; 1/2</title>
		<link>http://www.rensenieuwenhuis.nl/super-crunchers-ayres-2007-1/</link>
		<comments>http://www.rensenieuwenhuis.nl/super-crunchers-ayres-2007-1/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 10:00:30 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[Ian Ayres]]></category>
		<category><![CDATA[Reading List]]></category>
		<category><![CDATA[regression]]></category>
		<category><![CDATA[super crunchers]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=1111</guid>
		<description><![CDATA[With the Triumph of Numbers, I read and wrote about the power of using numbers, and how the observation of empirical regularities led to the basic knowledge on how to use such numbers. Already in ...]]></description>
				<content:encoded><![CDATA[<p>With the <a href="http://www.rensenieuwenhuis.nl/the-triumph-of-numbers-cohen-2005/">Triumph of Numbers</a>, I read and wrote about the power of using numbers, and how the observation of empirical regularities led to the basic knowledge on how to use such numbers. Already in the triumph of numbers, it was indicated how valuable (numerical) data were regarded to be, for instance by the recollection how the first censuses were regarded as state secrets, because the information could be used to make assertions about the military strength of (rival) nations.</p>
<p>Unfortunately, I.B. Cohen&#8217;s Triumph of Numbers ended quite abruptly with a description of Florence Nightingale. It felt unfinished. But the use of numbers has evolved since, and quite substantially so.</p>
<p>How much our use of numerical data has evolved, and to what extent is has invaded our daily lives (without many of us knowing it!), is convincingly described by Ian Ayers, in his magnificent book &#8216;Super Crunchers&#8217; (2007).</p>
<p>Companies know more and more (and more!) about you: you buy products online, you speak with the customer relations department (with a person behind a computer), you gain discounts with customer cards, and of course you are careful to make sure you receive you frequent flyer miles. Right? If not, you may have bought it all using a credit card, the transactions of which are stored anyway.<span id="more-1111"></span></p>
<p>So, the companies from whom you buy, know all this, because they have learned to store all this precious information. And using this information &#8211; and believe me, we&#8217;re dealing with massive amounts of data &#8211; each of these companies crunches the data and is able to very <em>exactly</em> predict what each of its&#8217; customers will do next. Groceries successfully predict what to buy the next summer, based on what they sold <em>months or weeks</em> ago. Casino&#8217;s know how to predict how much money each individual customer is willing to lose before leaving (it&#8217;s actually called the &#8216;pain point&#8217;). You can be sure that if a gambler reaches this pain point, an employee of the casino steps forward to offer him/her an incentive to stay (i.e. a free drink or meal). Airlines predict when you will be unsatisfied by their service (i.e. they lost your baggage too often), and will upgrade your seat (for free) just before you&#8217;ll start flying with another company.</p>
<p>The list of excellent examples goes on and on. But, the general &#8211; and possibly frightening &#8211; conclusion drawn by Ian Ayres is, that if a company starts giving you gifts, you probably have paid too much.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/super-crunchers-ayres-2007-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Influence.ME: Tools for detecting influential data in mixed models</title>
		<link>http://www.rensenieuwenhuis.nl/introducing-influenceme/</link>
		<comments>http://www.rensenieuwenhuis.nl/introducing-influenceme/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 09:03:25 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Influence.ME]]></category>
		<category><![CDATA[lmer]]></category>
		<category><![CDATA[mixed models]]></category>
		<category><![CDATA[R-Project]]></category>
		<category><![CDATA[regression]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=914</guid>
		<description><![CDATA[I&#8217;m highly excited to announce that influence.ME is now available. Influence.ME is a new software package for R, providing statistical tools for detecting influential data in mixed models. It has been developed by Rense Nieuwenhuis, ...]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m highly excited to announce that <a href="rensenieuwenhuis.nl/r-project/influenceme/">influence.ME</a> is now available. <a href="rensenieuwenhuis.nl/r-project/influenceme/">Influence.ME</a> is a new software package for <a href="www.r-project.org">R</a>, providing statistical tools for detecting influential data in mixed models. It has been developed by <a href="www.rensenieuwenhuis.nl">Rense Nieuwenhuis</a>, <a href="http://benpelzer.ruhosting.nl/"> Ben Pelzer</a>, and <a href="http://www.ru.nl/methodenentechnieken/syntax/mtg/">Manfred te Grotenhuis</a>. The basic rationale behind identifying influential data is that when iteratively single units are omitted from the data, models based on these data should not produce substantially different estimates. To standardize the assessment of how influential data is, several measures of influence are commonly used, such as DFBETAS and Cook&#8217;s Distance.<br />
<!--adsense--><br />
<span id="more-914"></span><br />
Mixed effects regression models tend to become common practice in the field of Social Sciences. However, diagnostic tools to evaluate these models lag behind. For instance there is no general applicable tool to check whether all units (or cases) roughly have the same influence on the regression parameters. It is however commonly accepted that tests for influential cases should be performed, especially when estimates are based on a relatively small number of cases. Testing for influence with mixed effects models is especially important in Social Science applications, for two reasons. First, models in the Social Sciences are frequently based on large numbers of individuals while the number of higher level units is often relatively small. Secondly, often the higher level units are remarkably similar, for instance in the case of neighboring countries. Influence.ME is a new package for R which provides two innovations for evaluating influential cases: it extends existing procedures for use with mixed effects models, and it allows to not only search for single influential cases, but for combinations of cases that as a combination exert too much influence.</p>
<p>I plan to use my blog to provide more information about influence.ME. For instance, you can expect some example analyses soon. Other developments, new features, or exciting applications in research papers will be discussed here as well in due time. <a href="http://www.rensenieuwenhuis.nl/r-project/influenceme/">A static page on influence.ME</a> is available as well, where all important information is collected.  </p>
<p>Questions, comments, thoughts, experiences, notes on bugs (and other vermin), feature requests, and what more: it is all highly appreciated. They can be sent by e-mail, or placed in the comments-section on this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/introducing-influenceme/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://i0.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://i1.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://i1.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>
		<item>
		<title>R-Sessions 17: Generalized Multilevel {lme4}</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-17-generalized-multilevel-lme4/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-17-generalized-multilevel-lme4/#comments</comments>
		<pubDate>Mon, 01 Sep 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[generalised]]></category>
		<category><![CDATA[lme4]]></category>
		<category><![CDATA[logistic regression]]></category>
		<category><![CDATA[multilevel]]></category>
		<category><![CDATA[regression]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=552</guid>
		<description><![CDATA[Although all introductions on regression seem to be based on the assumption of data that is distributed normally, in practice this is not the case. Many other types of distributions exist. To name a few: normal distribution, binomial distribution, poisson, gaussian and so on. The lmer()-function in the lme4-package can easily estimate models based on these distributions. This is done by adding the 'family'-argument to the command syntax, thereby specifying that not a linear multilevel model needs to be estimated, but a generalized linear model.]]></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--><br />
Although all introductions on regression seem to be based on the assumption of data that is distributed normally, in practice this is not the case. Many other types of distributions exist. To name a few: normal distribution, binomial distribution, poisson, gaussian and so on. The lmer()-function in the lme4-package can easily estimate models based on these distributions. This is done by adding the &#8216;family&#8217;-argument to the command syntax, thereby specifying that not a linear multilevel model needs to be estimated, but a generalized linear model.<br />
<span id="more-552"></span></p>
<h2>Logistic Multilevel Regression</h2>
<p>Let us say, we want to estimate the chance for success on a test a student in a specific school has. Therefor, we can use the Exam data-set in the mlmRev-package. This contains the standardized scores on a test. Here, we&#8217;ll define success on the test as having a standardized score of 0 or larger. This is recoded to a 0-1 variable below, using the <a href="http://www.rensenieuwenhuis.nl/r-project/manual/basics/data-manipulation/">ifelse() function</a>. Using summary() the process of recoding is checked. The needed packages are loaded as well, using the library() function.</p>
<blockquote><p>
library(lme4)<br />
library(mlmRev)<br />
names(Exam)</p>
<p>Exam$success <- ifelse(Exam$normexam >= 0,1,0)<br />
summary(Exam$normexam)<br />
summary(Exam$success)
</p></blockquote>
<pre>
> library(lme4)
Loading required package: Matrix
Loading required package: lattice
> library(mlmRev)
> names(Exam)
 [1] "school"   "normexam" "schgend"  "schavg"   "vr"       "intake"  
 [7] "standLRT" "sex"      "type"     "student" 
> 
> Exam$success <- ifelse(Exam$normexam >= 0,1,0)
> summary(Exam$normexam)
      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
-3.6660000 -0.6995000  0.0043220 -0.0001138  0.6788000  3.6660000 
> summary(Exam$success)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0000  0.0000  1.0000  0.5122  1.0000  1.0000 
</pre>
<p>In order to be able to properly use the so created binary &#8216;success&#8217; variable, a logistic regression model needs to be estimated. This is done by specifying binomial family, using the logit as a link-function, using &#8220;family = binomial(link = &#8220;logit&#8221;)&#8221;. The rest of the specification is exactly the same as a <a href="http://www.rensenieuwenhuis.nl/r-project/manual/multilevel-analysis/model-specification/">normal linear multilevel regression model using the lmer() function</a>.</p>
<blockquote><p>
lmer(success~ schavg + (1|school), data=Exam, family=binomial(link = &#8220;logit&#8221;))
</p></blockquote>
<pre>
> lmer(success~ schavg + (1|school), 
+ 	data=Exam, 
+ 	family=binomial(link = "logit"))
Generalized linear mixed model fit using Laplace 
Formula: success ~ schavg + (1 | school) 
   Data: Exam 
 Family: binomial(logit link)
  AIC  BIC logLik deviance
 5323 5342  -2658     5317
Random effects:
 Groups Name        Variance Std.Dev.
 school (Intercept) 0.23113  0.48076 
number of obs: 4059, groups: school, 65

Estimated scale (compare to  1 )  0.9909287 

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  0.08605    0.07009   1.228    0.220    
schavg       1.60548    0.21374   7.511 5.86e-14 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Correlation of Fixed Effects:
       (Intr)
schavg 0.072 
</pre>
<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><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/multilevel-analysis/generalized-multilevel/">Find the original article embedded in the manual.</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-17-generalized-multilevel-lme4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
