Skip to content

Instantly share code, notes, and snippets.

View joaovissoci's full-sized avatar

Joao Ricardo N Vissoci joaovissoci

View GitHub Profile
@joaovissoci
joaovissoci / template_network_analysis.R
Last active August 29, 2017 03:25
template_network_analysis
#####################################################################################
#TEMPLATE DE ANALISE - contexto_study_3.R
#####################################################################################
#
# Glossário
# $ = Pertence a = data$sexo, que dizer variável sexo pertencente ao banco data
#
#
#####################################################################################
#ORGANIZANDO O AMBIENTE DO R
@joaovissoci
joaovissoci / metanalysis_template.md
Last active August 29, 2015 14:04
metanalysis_template

Methods

[insert information on the definition of the outcomes modeled]. Heterogeneity across studies was first examined using quantitative and qualitative criteria and clinical judgment. Qualitative factors included the type of [criteria used to evaluate methodological homogeneity]. While quantitative indicators were Cochrane's Q (considering p-values lower than 0.05 to indicators of heterogeneity), H and I statistics (Higgins and Thompson, 2002). High Iˆ2 values indicate high heterogeneity, with a proposed categorization of 25% (low), 45% (moderate) and 75% (high) (Higgins et al., 2003). In our study, we adopted the interpretation of the [method of estimation] because our main goal is to [random-effect-summarize the estimates of XXXX, across a variety of studies, being applicable to different scenarios and populations as comprehended in the systematic revire OR fixed-effect-find the true-effect of of XXXX along different populations sized reported in the literature]. Also, as a form of sensibility for the

# bootstrapped standard errors and confidence intervals for sem
# original sem code from sem:::bootSem.sem
# original post: http://r.789695.n4.nabble.com/Bootstrap-bootSem-causes-R-to-crash-tp4661900p4677999.html
# commented out lines referencing tcltk
bootSem2 <- function (model, R = 100, Cov = cov, data = model$data, max.failures = 10,
...)
{
@joaovissoci
joaovissoci / kmo_function.R
Last active October 5, 2023 08:11
Kmo calculation
#KMO
kmo = function( data ){
library(MASS)
X <- cor(as.matrix(data))
iX <- ginv(X)
S2 <- diag(diag((iX^-1)))
AIS <- S2%*%iX%*%S2 # anti-image covariance matrix
IS <- X+AIS-2*S2 # image covariance matrix
Dai <- sqrt(diag(diag(AIS)))
@joaovissoci
joaovissoci / r_nma_template.R
Created June 25, 2014 04:28
#R TEMPLATE FOR NETWORK METANALYSIS
#####################################################################################
#R TEMPLATE FOR NETWORK METANALYSIS
#####################################################################################
#
#
#
#
#
#####################################################################################
#SETTING ENVIRONMENT
@joaovissoci
joaovissoci / script_exemplo_metanalise.R
Last active May 14, 2018 17:40
example of R script for metanalysis in R
#######################################################################################
#example_metanalysis.R is licensed under a Creative Commons Attribution - Non commercial 3.0 Unported License. see full license at the end of this file.
#######################################################################################
#this script follows a combination of the guidelines proposed by Hadley Wickham http://goo.gl/c04kq as well as using the formatR package http://goo.gl/ri6ky
#if this is the first time you are conducting an analysis using this protocol, please watch http://goo.gl/DajIN while following step by step
#link to manuscript
#####################################################################################
#SETTING ENVIRONMENT
# script stolen and adapted from http://goo.gl/kUzaov
if (!require('sem')) install.packages('sem')
if (!require('lavaan')) install.packages('lavaan')
if (!require('Rcmdr')) install.packages('Rcmdr')
# creating a dataset for g + 3 factors, all orthogonal
@joaovissoci
joaovissoci / r_basics_template.R
Last active July 6, 2016 22:21
basic R statistical functions
######################################################################
#BASIC R STATISTICS TEMPLATE
######################################################################
#
#
#
#
#
######################################################################
#SETTING ENVIRONMENT
# Mayo Clinic Lung Cancer Data
library(survival)
# learn about the dataset
help(lung)
# create a Surv object
survobj <- with(lung, Surv(time,status))
# Plot survival distribution of the total sample
#
# Functions to make ggplot KM survivor curves made with survfit() in library(survival)
#
# code written by Ramon Saccilotto
# and included in his ggplot2 tutorial
# 2010-12-08
# define custom function to create a survival data.frame
createSurvivalFrame <- function(f.survfit){
# initialise frame variable