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
| n <- 100000 | |
| pe <- .2 #patriarchy benefit to male ability | |
| ba <- rnorm(n) #baseline ability | |
| m <- rbinom(n,1,.5) #male | |
| h <- ba + pe * m + rnorm(n)#h index | |
| e1 <- ba + pe *m + rnorm(n)#earnings assuming caused by ability | |
| e2 <- h + rnorm(n)#earnings assuming caused by h-index | |
| lm(e1~h+m) | |
| lm(e2~h+m) |
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
| stn_md> stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}' | |
| stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE) | |
| TRANSLATING MODEL '73fc79f8b1915e8208c736914c86d1a1' FROM Stan CODE TO C++ CODE NOW. | |
| successful in parsing the Stan model '73fc79f8b1915e8208c736914c86d1a1'. | |
| The NEXT version of Stan will not be able to pre-process your Stan program. | |
| Please open an issue at | |
| https://github.com/stan-dev/stanc3/issues | |
| if you can share or at least describe your Stan program. This will help ensure that Stan |
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
| invlogit <- function(x) { | |
| exp(x)/(1+exp(x)); | |
| } | |
| corbase <- matrix(c(1,2,0,1),2,2) | |
| mcor <- cov2cor(corbase %*% t(corbase)) | |
| print(mcor) | |
| corchol <- t(chol(mcor)) | |
| r <- matrix(rnorm(2000000),ncol=2) |
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
| # The current manual is here: | |
| # https://cran.r-project.org/web/packages/ctsem/vignettes/hierarchicalmanual.pdf | |
| # A few blog posts with examples are here: https://cdriver.netlify.app/ | |
| # Here's a bivariate panel example script: | |
| library(ctsem) | |
| data(AnomAuth) | |
| longdat <- ctDeintervalise(ctWideToLong(AnomAuth,Tpoints = 5,n.manifest = 2)) |
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
| #generate data from python script | |
| library('reticulate') | |
| # reticulate::install_python() | |
| a=py_run_string(" | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from random import random | |
| from random import seed |
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
| # Multiple subjects -- correlated intercept and slope --------------------- | |
| N <- 50 | |
| times <- seq(0,10,1) | |
| interceptmu <- 4 #intercept / starting point | |
| slopemu <- .3 #slope / growth rate |
OlderNewer