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
| odds_to_rr <-function (fit) | |
| { | |
| Estimates <- fixef(fit) | |
| param <-data.frame(Estimates) | |
| param$Parameter <- row.names(param) | |
| est <- param %>% select(Parameter, Estimates) | |
| rownames(est) <- NULL | |
| est[[2]] <- exp(est[[2]]) | |
| ci <- stats::confint(fit, method = "Wald", parm = "beta_") | |
| else ci <- stats::confint(fit) |
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
| #!/bin/bash | |
| # Update Ubuntu | |
| sudo apt-get update | |
| # Install gcc and clang C++ compilers | |
| sudo apt-get install gcc | |
| sudo apt-get install clang | |
| #Install libcurl4 |
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
| # In your terminal navigate to key pair | |
| cd <your directory> | |
| # Connect to the server via Secure Shell (SSH) | |
| ssh -i YOUR_KEYPAIR.pem.txt ubuntu@PUBLIC_DNS | |
| # You may get an error so you will need to modify the key | |
| chmod 600 YOUR_KEYPAIR.pem.txt | |
| # Connect to the server via Secure Shell (SSH) |
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
| # Load libraries | |
| lapply(c("R2MLwiN","arm","ggplot2","RColorBrewer","grid"),library, character.only=TRUE) | |
| # Set working directory and load data | |
| setwd("~/R") | |
| data(tutorial) | |
| str(tutorial) | |
| # Fit a linear varying intercept multilevel model with group level predictors of normexam ~ sex + standlrt + vrband + schgend + avslrt + schav + (1|school) | |
| fit.1 <-lmer(normexam ~ sex + standlrt + vrband + schgend + avslrt + schav + (1|school), data=tutorial) |
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
| # Load libraries | |
| lapply(c("R2MLwiN","arm","ggplot2","RColorBrewer","grid"),library, character.only=TRUE) | |
| # Set working directory and load data | |
| setwd("~/R") | |
| data(tutorial) | |
| str(tutorial) | |
| # Fit a linear varying intercept multilevel model with group level predictors of normexam ~ sex + standlrt + vrband + schgend + avslrt + schav + (1|school) | |
| fit.1 <-lmer(normexam ~ sex + standlrt + vrband + schgend + avslrt + schav + (1|school), data=tutorial) |
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
| # Load libraries | |
| lapply(c("datasets","arm","ggplot2","RColorBrewer","grid"),library, character.only=TRUE) | |
| # Set working directory and load data | |
| setwd("~/R") | |
| data(mtcars) | |
| # Fit a linear model of mpg ~ wt + disp + hp + qsec | |
| fit.1 <-lm(mpg ~ wt + disp + hp + qsec, data=mtcars) | |
| display(fit.1) |
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
| require("RColorBrewer") | |
| # not run: | |
| # model = lm(y~x1+x2+x3+x4...) | |
| # Construct quantile table for varialbes of interest | |
| # t value: n-p=df.residual=634, alpha=5%,50%. t(1-alpha/2, n-p) | |
| t.05 <- qt(1-0.025, 634, lower.tail = TRUE, log.p=FALSE) | |
| t.5 <- qt(1-0.25, 634, lower.tail = TRUE, log.p=FALSE) | |
| coef.quantil <- data.frame(matrix(0, nrow=length(model$coefficients)-1, ncol=8)) |