Skip to content

Commit

Permalink
Agregar datos y modelos
Browse files Browse the repository at this point in the history
  • Loading branch information
felipegonzalez committed Jan 24, 2024
1 parent 8791905 commit ae33edd
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
20 changes: 20 additions & 0 deletions datos/golf.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
x n y
2 1443 1346
3 694 577
4 455 337
5 353 208
6 272 149
7 256 136
8 240 111
9 217 69
10 200 67
11 237 75
12 202 52
13 192 46
14 174 54
15 167 28
16 201 27
17 195 31
18 191 33
19 147 20
20 152 24
33 changes: 33 additions & 0 deletions datos/golf_grande.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
dis make count exitos
0.28 100.0% 45198 45183
0.97 99.9% 183020 182899
1.93 99.5% 169503 168594
2.92 96.3% 113094 108953
3.93 87.7% 73855 64740
4.94 76.6% 53659 41106
5.94 65.6% 42991 28205
6.95 57.6% 37050 21334
7.95 49.9% 33275 16615
8.95 43.8% 30836 13503
9.95 38.6% 28637 11060
10.95 34.4% 26239 9032
11.95 31.2% 24636 7687
12.95 28.1% 22876 6432
14.43 23.8% 41267 9813
16.43 20.2% 35712 7196
18.44 16.8% 31573 5290
20.44 14.4% 28280 4086
21.95 12.4% 13238 1642
24.39 10.2% 46570 4767
28.40 7.8% 38422 2980
32.39 6.3% 31641 1996
36.39 5.2% 25604 1327
40.37 4.1% 20366 834
44.38 3.5% 15977 559
48.37 2.6% 11770 311
52.36 2.7% 8708 231
57.25 2.3% 8878 204
63.23 1.9% 5492 103
69.18 1.1% 3087 35
75.19 1.4% 1742 24

25 changes: 25 additions & 0 deletions notas/src/peso-estatura-1.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
data {
int<lower=0> N;
vector[N] h;
vector[N] w;
}

parameters {
real alpha;
real <lower=0> beta;
real <lower=0> sigma;
}

transformed parameters {
vector[N] w_media;
// determinístico dado parámetros
w_media = alpha + beta * (h - 160);
}

model {
// partes no determinísticas
w ~ normal(w_media, sigma);
alpha ~ normal(60, 10);
beta ~ normal(0, 1);
sigma ~ normal(0, 20);
}
27 changes: 27 additions & 0 deletions notas/src/peso-estatura-2.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data {
int<lower=0> N;
vector[N] w;
array[N] int s;
}

parameters {
array[2] real alpha;
real <lower=0> sigma;
}

transformed parameters {

}

model {
// modelo para peso
w ~ normal(alpha[s], sigma);
// también se puede escribir como
// for (i in 1:N) {
// w[i] ~ normal(alpha[s[i]], sigma);
// }
// iniciales
alpha ~ normal(60, 10);
sigma ~ normal(0, 20);
}

40 changes: 40 additions & 0 deletions notas/src/peso-estatura-3.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
data {
int<lower=0> N;
vector[N] w;
vector[N] h;
array[N] int s;
}

transformed data {
real h_media;
h_media = mean(h);
}

parameters {
array[2] real alpha;
array[2] real<lower=0> beta;
real <lower=0> sigma;
}

transformed parameters {
array[N] real mu;
for (i in 1:N) {
mu[i] = alpha[s[i]] + beta[s[i]] * (h[i] - h_media);
}
}

model {
// modelo para peso
w ~ normal(mu, sigma);
// también se puede escribir:
//for (i in 1:N) {
// w[i] ~ normal(mu[i], sigma);
//}
alpha ~ normal(60, 10);
beta ~ normal(0, 1);
sigma ~ normal(0, 20);
}

generated quantities {

}

0 comments on commit ae33edd

Please sign in to comment.