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
library(tidyverse) | |
library(metamicrobiomeR) | |
set.seed(3421) | |
# Sample size (fixed!) | |
n_CFS <- 50 | |
n_control <- 50 | |
# How many metabolites to be sent for biological screening |
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
library(tidyverse) | |
library(polycor) # for hetcor | |
set.seed(7567) | |
N <- 1e4 # Sample size | |
J <- 100 # Number of groups | |
ρ <- 0.7 # Within-group correlation | |
τ <- c(-Inf, -2, 0, 1, Inf) # Thresholds for categories | |
K <- length(τ) - 1 # Number of categories |
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
# A small simulation to investigate bagging | |
# 2020-10-30 DLO | |
set.seed(4232) | |
# Root mean squared error metric | |
rmse <- function(y_pred, y) { | |
r <- y_pred - y | |
sqrt(mean(r^2)) | |
} |
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
# Function that takes desrired mean, distance, and probability, and outputs | |
# another function to be optimized. | |
get_objective <- function(desired_mean, desired_dist, desired_mass) { | |
# Return a function that can be passed to optim() | |
function(shape1) { | |
# Enforce desired mean: | |
shape2 <- shape1 * ((1 / desired_mean) - 1) | |
# Use R internals to get the definite integral: |
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
# This code is a lavaan implementation of the standard error correction found in | |
# | |
# Oberski, D. L., & Satorra, A. (2013). | |
# Measurement error models with uncertainty about the error variance. | |
# Structural equation modeling, 20, 409-428. | |
# DOI:10.1080/10705511.2013.797820 | |
# | |
# Author: Daniel Oberski | |
# Date 27 november 2018 | |
# License: MIT (https://opensource.org/licenses/MIT) |
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
# MIT license | |
# Author: Daniel Oberski | |
# Input: result of a poLCA model fit | |
# Output: entropy R^2 statistic (Vermunt & Magidson, 2013, p. 71) | |
# See: daob.nl/wp-content/uploads/2015/07/ESRA-course-slides.pdf | |
# And: https://www.statisticalinnovations.com/wp-content/uploads/LGtecnical.pdf | |
machine_tolerance <- sqrt(.Machine$double.eps) | |
entropy.R2 <- function(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
library(lubridate) | |
library(rjson) | |
library(tidyverse) | |
library(ISOcodes) | |
library(ggplot2) | |
library(ggthemes) | |
setwd("~/Dropbox/ERC/templates/") |
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
# Author: Daniel Oberski | |
# Date: 2017-08-01 | |
# Bivariate residual statistic for latent class analysis | |
# Calculate the BVR for poLCA objects | |
# Argument: a poLCA object | |
# Value: a dist object with BVRs | |
# Example: bvr(fit) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.