- Instale o R neste link.
- Instale o RStudio neste link (recomendado).
- Acesse este link e crie uma conta free.
# Adaptacao da funcao 'mwar.ani' do pacote 'animation' do R para | |
# ilustrar o conceito de media movel para k observacoes consecutivas | |
mm.ani = function(x, k = 7, mat = matrix(1:2, 2), | |
widths = rep(1, ncol(mat)), | |
heights = rep(1, nrow(mat)), lty.rect = 2, ...) { | |
nmax = ani.options('nmax') | |
n = length(x) | |
if (k > n) | |
stop('A largura da janela k deve ser menor que o tamanho de x!') |
val_agregado insu_trab insu_capital | |
38372840 424471 2689076 | |
1805427 19895 57997 | |
23736129 206893 2308272 | |
26981983 304055 1376235 | |
217546032 1809756 13554116 | |
19462751 180366 1790751 | |
28972772 224267 1210229 | |
14313157 54455 421064 | |
159921 2029 7188 |
# 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) | |
# |
# 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) |
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) |