Skip to content

Instantly share code, notes, and snippets.

View eliardocosta's full-sized avatar
🎯
Focusing

Eliardo Costa eliardocosta

🎯
Focusing
View GitHub Profile
rNx <- function(k = 1E3, x = 1) {
out <- numeric()
for (i in 1:k) {
nx <- 1
u <- runif(1)
while(u <= x) {
u <- u + runif(1)
nx <- nx + 1
}
out <- append(out, nx)
library(tidyverse)
library(ggplot2)
diamonds %>%
count(cut) %>%
arrange(desc(cut)) %>%
mutate(prop = n/sum(n) ) %>%
mutate(lab.ypos = cumsum(prop) - 0.5*prop) %>%
ggplot(aes(x = "", y = prop, fill = cut)) +
geom_bar(width = 1, stat = "identity", color = "white") +
#- EST0116 INFERENCIA II
#- Slides 0
# slide 23 ----------------------------------------------------------------
estu_sim1 <- function(eps, theta, K = 100) {
ns <- seq(5, 10000, 1000)
prob <- numeric()
for (n in ns) {
cont <- numeric()
#- EST0116 INFERENCIA II
#- Slides 0
# slide 37 ----------------------------------------------------------------
library(animation)
ani.options(interval = 0.1, nmax = 200)
# gerando valores de uma exponencial com media = 1
clt.ani()
#- EST0116 INFERENCIA II
#- Slides 0
# slide 97 ----------------------------------------------------------------
library(MASS)
theta <- 3
n <- 20
x <- rgamma(n, shape = theta, rate = 1); x
@eliardocosta
eliardocosta / README.md
Last active August 2, 2021 13:39
Script R com comandos para o cálculo do alfa de Cronbach e quantidades relacionadas.
@eliardocosta
eliardocosta / LinksR.md
Last active August 17, 2021 21:41
Livros e links relacionados à linguagem R.

Primeiros passos

Usando o R no seu computador

  1. Instale o R neste link.
  2. Instale o RStudio neste link (recomendado).

Usando o R online

  1. Acesse este link e crie uma conta free.

Livros

# PARTE I -----------------------------------------------------------------
# upload do conjunto de dados
# Metodo 1: ir ao botao 'Import Dataset'
# Metodo 2: via comandos abaixo
install.packages("readxl") # instalando pacote 'readxl'
library(readxl) # carregando pacote 'readxl'
dados_estud = read_excel("C:\caminho\para\arquivo\dados-exemplo-estudantes.xls")
View(dados_estud)
# Animacao
# https://yihui.org/animation/example/least-squares/
# Exemplo 1 ---------------------------------------------------------------
x <- c(1.9, 0.8, 1.1, 0.1, -0.1, 4.4, 4.6, 1.6, 5.5, 3.4)
y <- c(0.7, -1, -0.2, -1.2, -0.1, 3.4, 0, 0.8, 3.7, 2)
library(aplore3)
data(chdage)
head(chdage)
# ajuste 1
mod1 <- glm(chd ~ age, family = binomial(), data = chdage)
summary(mod1)
#