e <- new.env()
e$x <- 10
e$y <- 20
eval(quote(x + y), envir = e)
#> [1] 30
e2 <- new.env()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example code from test_posteriors_geweke | |
devtools::load_all(".") | |
n <- 10 | |
# mu1 <- rnorm(1, 0, 3) | |
# sd1 <- rlnorm(1) | |
# sd2 <- rlnorm(1) | |
mu1 <- 0 | |
sd1 <- 2 | |
sd2 <- 1 |
# Warming up the sampler and running extra samples on the model with the initial dataset (ie. not changing it each iteration) should tell us whether the sampler is correctly adapted.
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
library(rlang)
preserved_goods_none <- function(goods = c("cucumber", "lemon", "pear")) {
goods
}
preserved_goods_rlang <- function(goods = c("cucumber", "lemon", "pear")) {
goods <- rlang::arg_match(
arg = goods
mat1 <- matrix(1:10, ncol = 2)
mat2 <- matrix(2:11, ncol = 2)
list_matrices <- list(mat1, mat2)
list_matrices
#> [[1]]
#> [,1] [,2]
#> [1,] 1 6
#> [2,] 2 7
mat <- matrix(
sample(x = c(1, 0), size = 9, replace = TRUE),
nrow = 3,
ncol = 3
)
mat
#> [,1] [,2] [,3]
#> [1,] 1 1 0
# implement bursted sampling, but unbirsted warmup using TFP adaptation
# use greta to get log prob for a knotty model
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
people <- c("ousmane", "sylviane", "victoire")
indices <- c(1,1,1,2,2,3,3,3,3)
repeated_people <- people[indices]
# how to count these people?
table(repeated_people)
#> repeated_people
#> ousmane sylviane victoire
n <- 1000
x <- sort(rnorm(n))
alpha <- -1
beta <- 0.3
obs_sd <- 1.2
y <- rnorm(n, alpha + beta * x, obs_sd)
library(greta)
NewerOlder