https://github.com/r0f1/rhelp
biostatistics datascience r statistics sweave
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/r0f1/rhelp
- Owner: r0f1
- Created: 2016-09-29T19:06:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T08:05:10.000Z (almost 9 years ago)
- Last Synced: 2025-01-24T16:38:13.891Z (over 1 year ago)
- Topics: biostatistics, datascience, r, statistics, sweave
- Size: 1000 Bytes
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# R help
## Exploratory data analysis
### Finding out n, distribution
library(psych)
cols <- c("n", "mean", "median", "min", "max", "sd")
desc <- data.frame(describe(dt))[cols]
More info see [here](http://www.statmethods.net/stats/descriptives.html) and [here](http://www.ats.ucla.edu/stat/r/faq/collapse.htm).
## Reliably importing packages
packages <- c("xtable", "stats", "plyr", "dplyr", "ggplot2", "RColorBrewer")
for(i in 1:length(packages)) {
pkg <- packages[i]
if (!require(pkg, character.only=TRUE)) {
install.packages(pkg, repos="http://cran.rstudio.com/")
library(pkg, character.only=TRUE)
}
}
## Misc
### Likelihood ratio test
# Likelihood of both models, degrees of freedom
# https://onlinecourses.science.psu.edu/stat504/node/220
p_interaction <- function(lik1, lik2, df){
d = abs(lik1-lik2);
return (dchisq(d, df));
}
p_interaction(5521.201, 5504.008, 8);