Skip to content
Snippets Groups Projects
Commit c1d83f8b authored by Pierre Pudlo's avatar Pierre Pudlo
Browse files

ok

parent 8e7ff7d7
No related branches found
No related tags found
No related merge requests found
library(survival)
lung
library(readr)
write_csv(lung, "lung.csv")
knitr::opts_chunk$set(echo = TRUE)
data(mammals)
data(mammals, package = "MASS")
force(mammals)
libary(tidyverse)
library(tidyverse)
ggplot(mammals, aes(x = body, y = brain)) +
geom_point()
ggplot(mammals, aes(x = body, y = brain)) +
geom_point() + theme_classic()
ggplot(mammals, aes(x = body, y = brain)) +
geom_point() + theme_bw()
mammals <- mammals %>%
mutate(log_body = log(body),
log_brain = log(brain))
ggplot(mammals, aes(x = log_body, y = log_brain)) +
geom_point() + theme_bw()
library(tidyverse)
library(rstan)
options(mc.cores = 4)
rstan_options(auto_write = TRUE)
library(saemix)
theo <- read_csv("theophyllineData.csv",
col_types = cols(id = col_factor()))
theo <- theo %>%
mutate(id_num = as.integer(id))
bayes_model_ka <- stan_model("bayes_TP2.stan")
init_func_ka <- function(){
ka_pop <- 1.86 #psi0_hat[1]
ke <- 0.086 #psi0_hat[2]
V <- 33 #psi0_hat[3]
a <- 1
ka <- rep(1.8, 12) #as.matrix(psi(sfit))[,1]
tau <- 1 #sqrt(diag(sfit@results@omega))[1]
eta <- (ka - ka_pop)/tau
list(ka_pop = ka_pop, ke = ke, V = V, a = a, eta = eta, tau = tau)}
posterior_ka <- sampling(bayes_model_ka, data = stan_data,
init = init_func_ka,
chains = 4, warmup = 5000,
iter = 10000,
refresh = 1000)
stan_data <- list(ntot = nrow(theo), N = 12, y = theo$concentration,
id = as.integer(theo$id), tps = theo$time, D = 320)
posterior_ka <- sampling(bayes_model_ka, data = stan_data,
init = init_func_ka,
chains = 4, warmup = 5000,
iter = 10000,
refresh = 1000)
bayes_model_ka <- stan_model("bayes_mixed_ka.stan")
library(nycflights13)
?flights
head(flights)
write.csv2(flights, row.names = FALSE)
path <- "/Users/ppudlo/git/m1-donnees-tp/data"
setwd(path)
write.csv2(flights, file="fligths.csv", row.names = FALSE)
write.csv2(airlines, file="airlines.csv", row.names = FALSE)
write.csv2(airports, file="airports.csv", row.names = FALSE)
write.csv2(planes, file="planes.csv", row.names = FALSE)
write.csv2(weather, file="weather.csv", row.names = FALSE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment