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
#get ctsem | |
install.packages("devtools") | |
library(devtools) | |
install_github("cdriveraus/ctsem") | |
#load lorenz data | |
ldat=read.csv(file='ldat.csv') | |
ldat=ldat[seq(1,nrow(ldat),5),] #subsample | |
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
install.packages('ctsem') | |
library(ctsem) | |
#generate data (columns of drift matrix 'cause' rows) | |
genmodel <- ctModel(n.manifest=3,n.latent=3,LAMBDA=diag(3),Tpoints=10, | |
DRIFT=matrix(c( | |
-.3, .1,0, | |
0,-.3,.1, | |
0,0,-.3), nrow=3, ncol=3), | |
DIFFUSION=diag(1,3)) |
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
N=10000 #iterations | |
obs=20 #observations per iteration | |
beta=exp(rnorm(N,-2,1)) | |
Bs=c() #bias in estimated Beta (standardised) for no error condition | |
Bsm=c() #bias in estimated Beta (standardised) for with error condition | |
betas2=c() #unstandardised true beta for no error iterations that came out significant | |
betasm2=c() #unstandardised true beta for with error iterations that came out significant | |
for(i in 1:N){ |
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
n=10000 | |
beta=.4 | |
#no effect | |
p=c() | |
for(i in 1:n){ | |
s=rnorm(30,0,1) | |
sm=s+rnorm(30,0,1) #with measurement error | |
x=rnorm(30,0,1) | |
p=c(p,summary(lm(sm~x))$coefficients[2,4]) |
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
library("qgraph") | |
library("igraph") | |
library("IsingSampler") | |
library("IsingFit") | |
library('rstan') | |
set.seed(1337) | |
Kappa <- as.matrix(get.adjacency(watts.strogatz.game(1,10,1,0))) | |
Kappa[1,5] <- Kappa[5,1] <- Kappa[3,9] <- Kappa[9,3] <-Kappa[7,1] <-Kappa[1,7] <- Kappa[5,9] <-Kappa[9,5] <-Kappa[7,3] <-Kappa[3,7] <-.5 |
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
b=.8 | |
n=100 | |
nruns=10000 | |
out<-rep(NA,nruns) | |
for(i in 1:nruns){ | |
x=rnorm(n,3,2) | |
y=b*x + rnorm(n, 0, 3) | |
fit=lm(y~x) |
NewerOlder