GithubHelp home page GithubHelp logo

nfultz / randomizr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from declaredesign/randomizr

5.0 2.0 0.0 1.56 MB

randomizr: Easy-to-Use Tools for Common Forms of Random Assignment and Sampling

Home Page: https://declaredesign.org/R/randomizr

License: Other

R 98.50% C 1.45% Rebol 0.06%

randomizr's Introduction

randomizr: Easy to use tools for common forms of random assignment and sampling

CRAN Status Travis-CI Build Status AppVeyor Build Status Coverage Status CRAN downloads

randomizr is designed to make conducting field, lab, survey, or online experiments easier by automating the random assignment process. Social and lab scientists conducting experiments need a process to assign individuals or units of observation to treatment or control wings. Common designs include simple random assignment, complete randomization, block randomization, cluster randomization, and blocked cluster randomization. randomizr automates all of these processes and assists scientists in doing transparent, replicable science. We offer randomizr for both R and Stata.

randomizr for R

Installing randomizr for R

Installing the latest stable version of randomizr in R:.

install.packages("randomizr")

If you would like to use the current development release of randomizr (please be aware that development releases may include bugs or syntax changes), run the following:

install.packages("randomizr", repos="http://r.declaredesign.org")

Getting started with randomizr for R

randomizr has five main random assignment functions, corresponding to the common experimental designs listed above. You can read more about using each of these functions in our reference library or by clicking on the function names: simple_ra(), complete_ra(), block_ra(), cluster_ra(), and block_and_cluster_ra().

complete_ra() (Complete randomization) is the function that will be most appropriate for a large number of experimental situations: when you want to assign a fixed m units out of a population of N units to treatment:

library(randomizr)
Z <- complete_ra(N = 100, m = 50)
table(Z)
0 1
50 50

A more complicated design that, for example, assigns different numbers of clusters to three different treatments, makes use of cluster_ra() (Cluster randomization):

# This makes a cluster variable: one unit in cluster "a", two in "b"...
clust_var <- rep(letters[1:15], times = 1:15)

Z <- cluster_ra(
  clusters = clust_var,
  m_each = c(4, 4, 7),
  conditions = c("control", "placebo", "treatment")
  )
table(Z, clust_var)
a b c d e f g h i j k l m n o
control 0 0 3 0 0 0 7 8 9 0 0 0 0 0 0
placebo 0 2 0 0 5 0 0 0 0 0 0 0 13 14 0
treatment 1 0 0 4 0 6 0 0 0 10 11 12 0 0 15

For more information about all of randomizr's functionality, please see our online tutorial

randomizr for Stata

Installing the latest stable version of randomizr from ssc is easy:

ssc install randomizr

If you would like to install the latest development release directly from GitHub, run the following code:

net install randomizr, from(https://raw.githubusercontent.com/DeclareDesign/strandomizr/master/) replace

Getting started with randomizr for Stata

complete_ra (complete randomization) is the workhorse function that will be most appropriate for a large number of experimental situations: it assigns m of N units to treatment:

ssc install randomizr
set obs 100
complete_ra, m(50)

A Stata version of our online tutorial is also available.

Happy randomizing!

randomizr's People

Contributors

aaronrudkin avatar acoppock avatar ck37 avatar graemeblair avatar lukesonnet avatar nfultz avatar nick-rivera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.