{"cells":[{"metadata":{"trusted":true,"_uuid":"f2509412fead5e49384a66a12e64dc3c4421f028"},"cell_type":"code","source":"library(splitstackshape)\nlibrary(VGAM)\nlibrary(BBmisc)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1c3fd7d3aaf4ac09d3e71da24860c5974d2cbc37"},"cell_type":"code","source":"# Set constants\nset.seed(12345)\nN = 100000","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1d50b4d71d4b6b17a363dbd24168c54a8e896b7e"},"cell_type":"code","source":"# Read the data\ndf = fread(\"../input/train.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7ff630757b99bb1a3fea0860fc1e8cfd04692b93"},"cell_type":"code","source":"# Stratified sampling of data\nsampled <- stratified(df, 'event', N)\nattach(sampled)\n\n# encode event\nsampled$event = as.factor(sampled$event)\n\n# normalize data\nsampled = normalize(sampled, method='range')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1890336269a68dab8bd0196e80d6cd109009130d"},"cell_type":"code","source":"# Get a summary\nsummary(sampled)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"72c3e12357a662765d96fc70f286f41fd6d32b15"},"cell_type":"code","source":"lm2 = vglm(event~ crew*(r + gsr + ecg) + ecg*gsr,family='multinomial',data=sampled)\nsummary(lm2)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}