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
nsim<-100000 | |
sd_est<-width<-rep(NA,nsim) | |
for(i in 1:nsim){ | |
y<-rnorm(10) | |
sd_est[i]<-sd(y) | |
ci<-t.test(y)$conf.int | |
width[i]<-ci[2]-ci[1] | |
} | |
plot(width,sd_est) |
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
## Load library: | |
library("exams") | |
## exam questions: | |
myexamlist<-list("pnorm1","sesamplesize1multiplechoice") | |
## output directory | |
## create new test dir if one does not exist: | |
files.list<-system("ls",intern=TRUE) |
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(lme4) | |
## load data | |
hindi10<-read.table("datacode/hindi10a.txt",header=TRUE) | |
## skipping: 1 if word is skipped, 0 otherwise | |
skip<-ifelse(hindi10$TFT==0,1,0) | |
hindi10$skip<-skip | |
summary(hindi10$word_complex) | |
## make a sum contrast for illustration |
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
> # Calculate the predicted random effects by hand for the ergoStool data | |
> (fm1<-lmer(effort~Type-1 + (1|Subject),ergoStool)) | |
Linear mixed model fit by REML | |
Formula: effort ~ Type - 1 + (1 | Subject) | |
Data: ergoStool | |
AIC BIC logLik deviance REMLdev | |
133 143 -60.6 122 121 | |
Random effects: | |
Groups Name Variance Std.Dev. | |
Subject (Intercept) 1.78 1.33 |
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
\documentclass[10pt,a4paper]{article} | |
%% packages | |
\usepackage{a4wide,verbatim,Sweave,url} | |
%% new environments | |
\newenvironment{question}{\item \textbf{Problem}\newline}{} | |
\newenvironment{solution}{\textbf{Solution}\newline}{} | |
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}} |
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
\documentclass[10pt,a4paper]{article} | |
%% packages | |
\usepackage{a4wide,verbatim,Sweave,url} | |
%% new environments | |
\newenvironment{question}{\item}{} | |
\newenvironment{solution}{\comment}{\endcomment} | |
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}} |
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
<<echo=FALSE, results=hide>>= | |
## DATA GENERATION | |
mean.val<-round(rnorm(1,mean=100,sd=10),digits=0) | |
sd.val<-round(abs(rnorm(1,mean=10,sd=10)),digits=0) | |
n<-round(abs(rnorm(1,mean=100,sd=10)),digits=0)+1 | |
se1<-round(sd.val/sqrt(n),digits=3) | |
se2<-round(sd.val/sqrt(n^2),digits=3) | |
questions <- character(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
<<echo=FALSE, results=hide>>= | |
## DATA GENERATION | |
mean.val<-round(rnorm(1,mean=100,sd=100),digits=0) | |
sd.val<-round(rnorm(1,mean=100,sd=10),digits=0) | |
upper<-round(rnorm(1,mean=100,sd=100)+50,digits=0) | |
lower<-round(rnorm(1,mean=100,sd=100)-100,digits=0) | |
sol<-pnorm(upper,mean=abs(mean.val),sd=abs(sd.val))-pnorm(lower,mean=abs(mean.val),sd=abs(sd.val)) | |
sol<-round(sol,digits=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
data { | |
int<lower=1> N; | |
real rt[N]; //outcome | |
real c1[N]; //predictor | |
real c2[N]; //predictor | |
real c3[N]; //predictor | |
int<lower=1> I; //number of subjects | |
int<lower=1, upper=I> id[N]; //subject id | |
vector[4] mu_prior; //vector of zeros passed in from R | |
} |
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
Details: | |
key: | |
beta[1] = Intercept | |
beta[2] = c1 | |
beta[3] = c2 | |
beta[4] = c3 | |
1. Fixed effects, Stan vs lmer: | |
Stan: |
NewerOlder