Tag Archives: r

2 types of chi-squared test

Most people have heard of chi-squared test, but not many know that there are (at least) two types of chi-squared tests. The two most common chi-squared tests are: 1-way classification: Goodness-of-fit test 2-way classification: Contingency test The goodness-of-fit chi-squared test … Continue reading

Posted in Uncategorized | Tagged , , | 1 Comment

Popular packages in R and Python for Data Science

Most of the time, users of R and Python will rely on packages and libraries as far as possible, in order to avoid “reinventing the wheel”. Packages that are established are also often superior and preferred, due to lower chance … Continue reading

Posted in Uncategorized | Tagged , , | 1 Comment

caret package in R: known issue when converting factor variables

In the R language, often you have to convert variables to “factor” or “categorical”. There is a known issue in the ‘caret’ library that may cause errors when you do that in a certain way. The correct way to convert … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Calculate Cronbach Alpha using Python

R has the package “psych” which allows one to calculate the Cronbach’s alpha very easily just by one line: psych::alpha(your_data, column_list) For Python, the situation is more tricky since there does not seem to exist any package for calculating Cronbach’s … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Python code for PCA Rotation “varimax” matrix

The R programming language has an excellent package “psych” that Python has no real equivalent of. For example, R can do the following code using the principal() function: principal(r=dat, nfactors=num_pcs, rotate=”varimax”) to return the “rotation matrix” in principal component analysis … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment