Skip to content

Instantly share code, notes, and snippets.

@samuelsaari
samuelsaari / readSHAREsetup.do
Last active November 23, 2021 09:59
readSHARE setup for Stata
// Instructions for setting up readSHARE in Stata
// What is readSHARE?
view browse "https://ideas.repec.org/c/boc/bocode/s458405.html"
// 2.1. Load all the waves that you want to use in the same folder
* In other words, all folders containing the data for a SHARE wave should be found following the same path , for example under "C:/Users/JohnSmith/Documents/SHARE"
* Remember to extract the zip-files.
* We recommend you download all waves at once
#Part03-e12 radial_fade:
import os
import numpy as np
import matplotlib.pyplot as plt
# comment this when submitting
#uncomment when testing locally
os.chdir("C:/Users/fnsuc/OneDrive - University of Helsinki/Tilasto/python_data_analysis/hy-data-analysis-with-python-spring-2020/part03-e12_radial_fade")
print(os. getcwd())
@samuelsaari
samuelsaari / flh-results.md
Last active January 26, 2022 12:33
Sneak peek at the results of "Family and couple life histories in Europe"

Preliminarily results from the paper "Stable marital histories boost happiness and health across educational groups". Not for dissemination. All rights reserved.

Author: Miika Mäki

Relationship histories with sequence analysis

clusters_and_title Partnership history clusters for Western and Northern Europeans born in 1945 - 1957 at the age of 15 - 60

Associations of relationship histories with wellbeing (women)

multi_sub_life f

require(devtools)
#devtools::install_github("benjaminrich/table1")
library(boot)
library(table1)
library(kableExtra)
melanoma2 <- melanoma
# Factor the basic variables that
# modified from https://tex.stackexchange.com/a/162763/244928 by StackExhange user imriss
"""Copy figures and .tex-files used by document."""
import os
import shutil
import glob
import re
from pathlib import Path
os.chdir(os.path.dirname(__file__)) # working directory to file directory
# TexPublish - Preparing LaTeX Projects for Publication with Ease
# URL: https://gist.github.com/samuelsaari/07cfff92e157fad84cd9d1988e108d95
# Author: Miika Mäki https://github.com/samuelsaari
# - creates a new directory for publishable files
# - copies files matching user defined regular expressions to the new directory
# - copies all desired files that are used by the main tex document (like figures and tables)
# - creates a parsed bibliography that includes only entries used by the main tex file
# - flattens the tex file (inserts \input and \include commands and custom preambles in the main tex file)
# - pastes the parsed bibliography to the flattened tex file if desired
@samuelsaari
samuelsaari / z1det_MVE.R
Last active September 7, 2022 08:33
Parallel wrapper for stepFlexmix
# Parallel wrapper test for stepFlexmix
# Miika Maki
# R-code
Sys.time()
rm(list=ls())
# NB! Set interactive to TRUE or FALSE
INTERACTIVE=F
@samuelsaari
samuelsaari / a1det_MVE.sh
Last active September 7, 2022 08:33
Batch job specification for stepFlexmix parallel wrapper
#!/bin/bash -l
#SBATCH --job-name=r_multicore_flh
#SBATCH --account=project_2003758
#SBATCH --output=x_output_all_%j.R
#SBATCH --error=x_errors_%j.R
#SBATCH --partition=large # small # test # hugemem_longrun # hugemem
#SBATCH --time=00:09:59 # 2-23:58:00 # 00:14:54 # 6-23:49:00 # 2-23:49:00
#SBATCH --nodes=12 #nr_of_classses
[makimiik@puhti-login12 ~]$ sinteractive --account project_2003758 --mem 64000 --tmp 640 --cores 4
Launching a new interavtive job
Interactive batch job is launched with following resources:
Maximum run time (hours:min:sec): 24:00:00
Maximum memory (MB): 64000
$TMPDIR size (GB): 640
Number of cores/threads: 4
Accounting project: project_2003758
@samuelsaari
samuelsaari / z1det_MVE_biofam.R
Created November 1, 2022 10:12
Latent Class Growth Modelling with multinomial response in R
#---------------------------------------------------------
# libraries
rm(list=ls())
library(flexmix) # GMM & LCGM
library(TraMineR) # example data
library(OpenRepGrid)# random words for headings
library(khroma) # color palletttes
library(tidyverse)
library(car)