From c1d83f8b7b2a7618a4b4bb3e359839ab80080c73 Mon Sep 17 00:00:00 2001 From: Pierre Pudlo <37126309+pierrepudlo@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:13:30 +0200 Subject: [PATCH] ok --- data/.Rhistory | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 data/.Rhistory diff --git a/data/.Rhistory b/data/.Rhistory new file mode 100644 index 0000000..a7984ee --- /dev/null +++ b/data/.Rhistory @@ -0,0 +1,64 @@ +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) -- GitLab