-
Notifications
You must be signed in to change notification settings - Fork 12
/
notes.Rmd
75 lines (56 loc) · 2.29 KB
/
notes.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: "PAP"
author: "Fernando Hoces de la Guardia"
date: "2/16/2018"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
# Sub-group: SD
df <- data.frame("id" = 100+1:1e5)
df$treatment <- rbinom(1e5, 1, 0.5)
df$state <- rep(state.abb, length.out = 1e5)
df$dice <- sample(1:6, 1e5, replace = TRUE)
library(tidyverse)
df %>%
group_by(treatment) %>%
summarise(mean(dice))
cbind(sapply(state.abb, function(x) (t.test(dice~treatment, data = df[df$state == x, ])$p.value)))
#https://www.khanacademy.org/test-prep/mcat/critical-analysis-and-reasoning-skills-practice-questions/critical-analysis-and-reasoning-skills-tutorial/e/the-ultimatum-game
library(googlesheets)
resp <- gs_title("Quick survey")
df <- gs_read(resp)
# create treatment var
df$treatment <- as.integer(df$`ID number`<=500)
# Define outcome
# handle missing and outliers 0.2573
# Balance tables t.test(asd~treatment_generous, data = df, var.equal = T)
# row 1 intercept (mean for control group)
# col 1 estimates AQUI VOY
covariates <- c("name1", "name2")
balance.table <- data.frame(row.names = covariates,
"mean_control" = rep(NA,length(covariates)),
"diff" = rep(NA,length(covariates)),
"sd" = rep(NA,length(covariates)))
aux.2 <- summary(lm(asd~treatment_generous, data = df))$coefficients[, 1:2]
# Estimate effect
lm(outcome_1~ treatment, data=df)
lm(outcome_1~ treatment_generous, data=df)
# Estimate effect with covariates
#My first power calculation
pwr.t.test(n = 7, d = 1, sig.level = 0.1)
#https://goo.gl/aj8W61
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.