This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
forked from James-Thorson/2018_FSH556
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2e9318
commit db3b564
Showing
6 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
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
Binary file modified
BIN
-11 KB
(98%)
Week 2 -- mixed-effects/Lab 2/Lab 2 -- Mixed-effects models.pdf
Binary file not shown.
Binary file modified
BIN
+62.6 KB
(110%)
Week 2 -- mixed-effects/Lab 2/Lab 2 -- Mixed-effects models.pptx
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
Week 2 -- mixed-effects/Lab 2/Laplace_approximation_example.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
setwd( "C:/Users/James.Thorson/Desktop/Project_git/2018_FSH556/Week 2 -- mixed-effects/Lab 2/") | ||
|
||
png( file="Laplace_example.png", width=10, height=7.5, res=200, units="in") | ||
par( mfrow=c(2,2), mgp=c(2,0.5,0), tck=-0.02, xaxs="i", yaxs="i", mar=c(2,2,2,1), oma=c(2,2,0,0) ) | ||
for(i in 1:4){ | ||
if(i==1) X = seq(-5,12,length=1000) | ||
if(i==2) X = seq(-5,25,length=1000) | ||
if(i==3) X = seq(0,50,length=1000) | ||
if(i==4) X = seq(0,100,length=1000) | ||
DF = c(4,8,16,32)[i] | ||
Y1 = dchisq( X, df=DF ) | ||
Y2 = dnorm( X, mean=DF-2, sd=sqrt(2*(DF-2)) ) | ||
Y2 = Y2/max(Y2)*max(Y1) | ||
matplot( x=X, y=cbind(Y1,Y2), type="l", lwd=2, col=c("black","red"), ylim=c(0,max(c(Y1,Y2))*1.2), xlab="", ylab="", main=paste("Degrees of freedom = ",DF) ) | ||
abline( v=1, lty="dotted" ) | ||
Integral1 = sum(Y1) * mean(diff(X)) | ||
Integral2 = sum(Y2) * mean(diff(X)) | ||
legend( "topleft", col="black", legend=paste0("Integral= ",formatC(Integral1,format="f",digits=3)), bty="n" ) | ||
legend( "topright", col="red", legend=paste0("Approximation= ",formatC(Integral1,format="f",digits=3)), bty="n" ) | ||
mtext( side=1:2, text=c("Value","Density"), outer=TRUE, cex=1.5 ) | ||
} | ||
dev.off() | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.83 KB
(100%)
Week 2 -- mixed-effects/Lecture 2/Lecture 2 -- Mixed-effects models.pptx
Binary file not shown.