Giter Site home page Giter Site logo

mixed_model_examples's Introduction

Examples of Mixed Models in R

This repository contains simple examples of fitting random effect models in R. I assume basic familiarity with R, and mixed effect models. This mainly focuses on the tools. These examples were shown in class in SAS. The mixed.R file aims to replicate many of the SAS results. I included 3 examples:

  • One-Way Random Effect CRD
  • RCBD with random block
  • Split-Plot design with RCBD on whole plots

Libraries for R

lme4

This is how to fit random models in R, it offers a function called lmer which functions very similarly to lm in base R.

lmerTest

This will modify the behavior of R, so that the anova function returns p-values. lme4 by default does not return "p-values" and the reason for this is well documented. After installing the package, you can read about this by running help("pvalues")

emmeans

This replicates a lot of the functionality of the lsmeans statement, i.e. comparisons of marginal means between different groups.

Getting started

  1. Click the green "Clone or download" -> Download zip. Or clone the respository if you have git installed.
  2. Download the appropriate libraries above with the command install.packages(...)
  3. Open mixed.R and read through the comments as you run the code. Note, some assignment (variable <- expression) commands are wrapped with parentheses just to show you the output when you run it.

Other Resources

This example should give you a good start. If you need more detail in one particula area, here are some places to start.

mixed_model_examples's People

Contributors

lioumens avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.