This file contains hidden or 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
import numpy as np | |
from collections import OrderedDict | |
def pystan_vb_extract(results): | |
param_specs = results['sampler_param_names'] | |
samples = results['sampler_params'] | |
n = len(samples[0]) | |
# first pass, calculate the shape | |
param_shapes = OrderedDict() |
This file contains hidden or 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
# testing effect of correlated predictors on non-linearity when assuming a linear model | |
rho = 0.9 | |
N = 20 | |
set.seed(1) | |
# generate correlated x1 and x2 predictors | |
z = matrix(rnorm(N*2, 0, 1), 2) | |
L = t(chol(matrix(c(1, rho, rho, 1), 2))) | |
x = L %*% z |