Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [statistics]

Consider whether your question would be better asked at CrossValidated, a Stack Exchange site for probability, statistics, data analysis, data mining, and machine learning. Code Review questions on statistics should be about implementation and working program review, not about theoretical discussions of statistics or research design.

6
votes
1answer
255 views

R function for Dynamic Ordinary Least Squares regression

SHORT VERSION: Made a workflow function, want a better output with methods. General Background I have been working on a package for some time to eliminate the tedium of preliminary time series ...
5
votes
1answer
164 views

Summarizing downtime statistics

I am not satisfied with the performance and especially the time my piece of code takes to complete. The surrounding environment for better understanding is the following: A statistic for Downtime ...
5
votes
1answer
743 views

Django Rest Framework Totaling API values in different ways

I am working on a stats website for my softball teams that I manage/play for. Here is my current Stat model: ...
3
votes
1answer
91 views

Calculating difference statistics over a moving window

I'd like to calculate some statistics of given data (frequencies of difference among elements on various distances in percent multiplied by 10) using moving window within that data. Is it possible to ...
1
vote
1answer
20 views

Groovy script to get average price per group from different data arrays

I've been trying to learn Groovy lately and I tried to solve a problem which involves designing a routine that will calculate the average Product price per Group. I have the following data: ...
0
votes
1answer
93 views

Rolling mean lag function for multiple variables

Thanks to @josliber's help (Rolling mean lag function), I was able to speed up a rolling mean function for different groups and rollmean lengths. Now I'd like to add to this function the ability to ...
0
votes
1answer
85 views

Finding the mean using RxJava

I'm learning RxJava and this is what I attempted to find the mean of 'n' transactions. ...
5
votes
0answers
3k views

Calculate relationship between 2 categorical variables in a pandas Dataset with chi square test

I'm working on a Machine Learning project and I'm in Data Exploration step, and my dataset has both categorical and continuous attributes. I decided to compute a chi square test between 2 categorical ...
5
votes
0answers
1k views

Rolling z-score function in R

I have written a rolling z-score function myself. Is my implementation of rolling z-score function correct? ...
5
votes
0answers
126 views

Kernel density regression in Julia

Here is a naive implementation of a kernel density regression algorithm in Julia. The code works, but there is quite a bit of room for improvement though. First, there is not an optimal bandwidth ...
5
votes
0answers
78 views

Pivot-friendly binning of arbitrary vector

I frequently get a situation in which I want a pretty binned column from a vector of values, so that I divide the vector in approximately even ranges and choose 'sensible' values so that it looks ...
4
votes
0answers
762 views

Pandas/Numpy statistical odds ratio test

I'm looking for a faster way to do odds ratio tests on a large dataset. I have about 1200 variables (see var_col) I want to test against each other for mutual exclusion/ co-occurrence. An odds ratio ...
4
votes
0answers
145 views

Vectorize Fisher's Exact Test

I have two data frames/ lists of data, humanSplit and ratSplit, and they are of the form ...
3
votes
0answers
40 views

Download and analyze PDFs of Congressional records

This is built with Python 2.7.15. The goal of this script is to count the number of words spoken by each Senator on the floor of Congress between given dates. It pulls from the Congressional Record, ...
3
votes
0answers
49 views

'Weighted sample' from overlapping categories

I wish to write a function, that will sample from various (potentially overlapping) categories \$C_1, C_2, \ldots C_k\$, such that the sampled values are in the ratio \$r_1:r_2:\ldots: r_k\$ or as ...
3
votes
0answers
299 views

PCA, LDA and Logistic Regression

Based on the great blog by Joel Grus, I implemented LogisticRegression, PCA, and LDA. I'd appreciate feedback as I'm not sure that the logistic classifier is good enough (as it supposed to achieve ...
3
votes
0answers
1k views

A Simple K-Means Cluster Analyzer v0.1

[NOTE] This question can be depreciated in favor of version 0.2. This code works well. This my first attempt at creating a robust, computationally lean K-Means Cluster analyzer. I first saw this ...
3
votes
0answers
980 views

KS-Statistic in C++

Consider the MCG with parameters: a = 23, M = 10^8 + 1, and let the seed be 47594118. (This is the original MCG proposed by Lehmer in 1948.) Apply the Kolmogorov-Smirnov test to the first 1000 random ...
3
votes
0answers
206 views

Naive implementation of Naive Bayes in Haskell

A simple implementation of Naive Bayes, as I'm a Haskell beginner I've tried to put an emphasis on clarity and documentation. I've tried to incorporate the feedback from a similar question. This is ...
3
votes
0answers
135 views

Read in file, Filter out records, output results

I have been working on a project for some time and have let one Python file grow into a huge file that tries to do everything. The structure is pretty flat and I don't like it. I've used other ...
3
votes
0answers
89 views

Survey adjusted contingency table with Taylor Series linearization

I am an R programmer who is learning C++/Rcpp. I wrote some code to recreate survey adjusted contingency tables a la SAS's surveyfreq procedure using Taylor Series linearization to generate standard ...
3
votes
0answers
162 views

Nonlinear Nonparametric Regression

I explain the nonlinear correlation coefficients in this paper and provided the code in this post. The nonlinear nonparametric regression is an extension of this work and its description can be found ...
3
votes
0answers
124 views

Correlation and Dependence

It is well known that 0 dependence implies 0 correlation, while 0 correlation does not imply 0 dependence. I have a paper here illustrating nonlinear correlation coefficients from relationship subsets ...
3
votes
0answers
142 views

Computing pairwise distance covariances for a symmetric matrix

I wrote a non-vectorized, non-parallel wrapper function for computing the pairwise distance covariances (Wikipedia) (original paper) in a data frame: ...
2
votes
0answers
19 views

Simple data analysis for forecasting

This Python script extracts data from txt files containing raw numerical data, notably the increase average, the relative evolution and the standard deviation of ...
2
votes
0answers
54 views

Simple linear regression of two variables

This is the code I built to implement a simple linear regression to check the impact of variable A on B. I am not interested in predicting that's why the statistical approach is important for me to ...
2
votes
0answers
53 views

Regression on Pandas DataFrame

I am working on the following assignment and I am a bit lost: Build a regression model that will predict the rating score of each product based on attributes which correspond to some very common ...
2
votes
0answers
355 views

A Simple K-Means Cluster Analyzer v0.2

This code is a revision of a previous post and works well. This my first attempt at creating a robust, computationally lean K-Means Cluster analyzer. I first saw this algorithm in an intermediate ...
2
votes
0answers
92 views

Module for statistics

Here is my module for statistics: ...
2
votes
0answers
82 views

Getting the math right for a Hidden Markov Model in Java

In an effort to learn and use hidden markov models, I am writing my own code to implement them. I am using this wiki article to help with my work. I do not wish to resort to pre-written libraries, ...
2
votes
0answers
43 views

MCMC Metropolis Hastings for German Tank Puzzle

I have implemented the following MCMC algorithm for the german tank puzzle found here I just want to make sure everything is legit and that I am not getting the right answer by chance. ...
1
vote
0answers
103 views

Linear Regression Model with Python 3

I am trying to create a python module calculating correlation and creating regression model for single independent variable and two independent variables. The program works correctly, I use lots of ...
1
vote
0answers
47 views

Lazy Statistics: XYSamples java

After previous review I chose to alter this project to use lazy evaluation. Looking for any and all improvement feedback. This project is meant to represent a two dimensional data set, i.e., single-...
1
vote
0answers
78 views

JSON file for storing means and standard deviation values per demographic group

I wrote an ad hoc script in Python 3 that calculates where the patient result reside with a specific demographic group within the Turkish population, but until now I stored the data in the python code ...
1
vote
0answers
79 views

Backward elimination of fixed effects using lme4

I am trying to write a function that used drop1.merMod from the lme4 package to automatically remove fixed effect terms until ...
1
vote
0answers
113 views

Locking for accumulating counter with statistics

I have an Accumulator class that uses AtomicLong to track some counters. I have methods to calculate statistics based on those ...
1
vote
0answers
109 views

Monty Hall Problem in Javascript ES6 and React

Any suggestions for optimization are appreciated! ...
1
vote
0answers
94 views

Estimate Hidden Markov Model with both continuous and discrete observations, possible missing data

My code estimates a Hidden Markov Model (HMM) using the expectations-maximization (EM) algorithm. I followed https://www.princeton.edu/~rvan/orf557/hmm080728.pdf with modifications to allow for panel ...
1
vote
0answers
671 views

PHP rating function for getting the average value of column

I created a function to add and return the average rating. Rating Function ...
1
vote
0answers
253 views

Predicting a win/loss given prior game stats

The project: create a model that can (somewhat) accurately predict a win/loss given prior game stats. Wanted a review of code in general, in particular my use of the ...
1
vote
0answers
56 views

Simultaneous confidence interval

I recently read an article in which the authors present Algorithm 1 to compute a simultaneous confidence interval. I was interested in implementing Algorithm 1 in R here. The algorithm is freely ...
1
vote
0answers
55 views

Penalized logistic ridge regression

This code is for the penalized logistic regression that we should to choose \$\lambda\$ in regularization to control the trade off. I use the first function to estimate the \$\hat{\beta}\$ and the ...
1
vote
0answers
71 views

Numerical maximization procedure normal distribution

Firstly, I programmed this gaussian density as an R function which takes the parameters mean and variance (mean=4,sd=1) and ...
0
votes
0answers
50 views

Flask models for scores and statistics

I'm not sure whether I need to group a bunch of related methods in a single class or put them in a separate module. Which way would be preferable in Python? Here is what I've got so far but not sure ...
0
votes
0answers
41 views

Nested cross-validation

This is a homework assignment to implement nested cross validation. It seems to work fine (sometimes). The imports are inside the class and some methods are static, because this code needs to be in ...