Dr Juan Klopper
Julia environments
updated
Please watch the first three tutorials in this seminar series. Topics discussed in these video tutorials are used in this tutorial.
Linear regression youtu.be/6gtEfIbx6ko
Analysis of variance youtu.be/yeRtgKtbUFU
Analysis of covariance youtu.be/FhZB1oGVrYc
In logistic regression we use numerical or categorical variables to calculate an estimate of the probability of one of the classes or levels of the binary categorical dependent variable.
In this video lecture I talk about probability, odds, and odds ratios before we build three different logistic regression models. You will see just how easy it is to do in Python and how simple it is to understand logistic regression and how to interpret the results.
00:00 Introduction
19:25 Probability Odds and Odds Ratios
24:54 Continuous numerical variable as independent variable
41:06 Categorical variable as independent variable
46:51 Continuous numerical and categorical variable as independent variables
In the video I continue on from the previous video tutorial on the nullspace of a matrix. I explain what the column space is and go through examples that include all the types of matrices that you will come across. I also discuss what effect elementary row operations have on the column space. At the end of the tutorial I also show you how to prove that the column space is a vector subspace.
00:00 Introduction
03:55 Review of the nullspace
05:56 Square matrix with linear independence
09:19 Square matrix with linear dependence
17:01 Rectangular matrix with more columns than rows
20:43 Rectangular matrix with more rows than columns and linear independence
22:27 Rectangular matrix with more rows than columns and linear dependence
24: 16 Proof that the column space is a vector subspace
In ANCOVA we have a categorical variable as independent variable and a continuous numerical variable as dependent variable. This is typical in a study design, where participants are assigned to the levels made up by the unique values of the independent variable. Other variable might also have an effect on the dependent variable. We might not be able to control for these with the study design. If such a variable is a continuous numerical variable, we term it a covariate. So, in ANCOVA we look at the effect of the categorical independent variable on the continuous numerical variable after correcting for the covariate.
There are important assumptions for the use of ANCOVA models. The index below shows all the sections of the video lecture.
Please watch the first two videos in this seminar series, as I use concepts explained in these two videos in the tutorial on ANCOVA.
Linear regression: youtube.com/watch?v=6gtEfIbx6ko
ANOVA: youtube.com/watch?v=yeRtgKtbUFU
00:00 Introduction
05:55 Import data
20:23 Linearity
22:02 Homogeneity of regression
24:56 Normality of residuals
26:43 Homogeneity of variance of the residuals
27:53 Outliers
29:16 ANCOVA
In the video I explain what the nullspace is and go through examples that include all the types of matrices that you will come across. I also discuss linear independence and make clear how the nullspace differs from the column space. At the end of the tutorial I also show you how to prove that the nullspace is a vector subspace.
00:00 Introduction
05:59 Square matrix with linearly independent column vectors
11:03 Square matrix with dependent column vector
11:16 Rectangular matrix with more columns than rows with a single dependent column vector
20:01 Rectangular matrix with more columns than rows and more than one dependent column vector
21:48 Rectangular matrix with more rows than column and with independent column vectors
24:39 Rectangular matrix with more rows than columns and a dependent column vector
27:18 Proof that the nullspace is a subspace
In the video I use a Jupyter notebook in Visual Studio Code. I generate random data and walk through understandig the results of ANOVA by looking at the research equation, the null hypothesis and alternative hypothesis, the coefficients, standard errors, t statistics, and their p values, the confidence intervals for the coefficients, and then the analysis of variance table. The latter includes the degrees of freedom, the sum of squared errors (due to the regression and the error), the mean sum of squares, the F ratio, and it p value.
Lastly, I take a look at post-hoc tests and use the Tukey HSD and Bonferroni methods.
Here are time stamps for the various section in the tutorial.
00:00 Introduction
03:20 Generate data
08:45 Exploratory analysis
20:25 Generate ANOVA model
22:52 Understanding the coefficients
33:13 Understanding the errors
41:04 Post-hoc tests
This video is on linear regression using Python and the statsmodels package. In it, I demonstrate how to create data, and how to summarize and visualize the data for a simulated research project. I state the research question and the null hypothesis and alternative hypothesis.
There is a thorough explanation of a linear model in one variable in order to build intuition about the results of linear regression. I explain what all the important results are and show how they are calculated. These include the parameters estimates (coefficients), the standard error, test statistics, p value, and the confidence intervals.
I also explain the errors in the model such the sum of squared errors due to the regression and the residuals, the degrees of freedom in the model, the F statistic and its p value, as well as the coefficient of determination.
Linear regression is the fundamental linear model. I dive deep into this simplest of linear models and look at a typical results table and what it all means. The other three models follow quite naturally from linear regression.
00:00:00 Linear regression
00:31:14 Analysis of variance ANOVA
00:48:27 Analysis of covariance ANCOVA
01:11:44 Logistic regression
A quick video to take you through the installation of Julia, setting it up to run in the Terminal or Command Prompt, creating environments, setting up Jupyter notebooks and Pluto notebooks, and finally running Julia in Visual Studio code.
00:00:00 Install Julia
00:04:29 Running Julia from a command prompt or terminal
00:08:03 Creating environmnets
00:12:09 Jupyter notebooks
00:14:38 Pluto notebooks and environments
00:19:59 Visual Studio Code
00:22:40 End
The chapter markers below give an indication of the content of the video. I use the Julia language in Visual Studio Code.
00:00:00 Introduction
00:00:43 Packages used in this notebook
00:01:29 F distribution given two parameters
00:02:47 Generating data for this notebook
00:09:11 Summary statistics
00:10:27 Visualizing the data
00:11:00 Calculating the test statistic
00:20:32 Randomization to create the sampling distribution under the null hypothesis
The file is available on GitHub at github.com/juanklopper/Julia-for-scientifc-computing/blob/master/FRatioSimulation.jl
A PDF of the Pluto notebook is avaliable on GitHub at github.com/juanklopper/Julia-for-scientifc-computing/blob/master/FRatioUnderTheNullHypothesis.pdf
#VSCode #Julia #Statistics #F #Distribution #statistic #Randomization #null #hypothesis
Under a simple null hypothesis there is no difference in the mean of a variable between two groups. This means that we can randomly reassign individuals / instances between the two groups and that should not change the means. If our test statistic of interest is the difference in means, we can do this random reassignment over and over again, each time recording our test statistic. This will build up a sampling distribution of the test statistic and we can compare our original test statistic with this sampling distribution.
You can watch my video on installing environments for your Julia projects at youtube.com/watch?v=MC-wjQTXOOA
The file is available at github.com/juanklopper/Julia-for-scientifc-computing/blob/master/ResamplingUnderTheNullHypothesis.jl
There are chapter markers below if you want to skip ahead.
00:00:00 Introduction
00:00:28 Julia Language
00:00:49 Visual Studio Code
00:01:00 Terminal
00:02:08 Lauch Visual Studio Code
00:02:28 Julia Extension for Visual Studio Code
00:03:22 Contents of the tutorial
00:04:25 Julia packages used in this tutorial
00:05:32 Generating random data
00:08:23 Making sub-DataFrames
00:09:48 Extracting vectors from a DataFrame
00:11:06 Descriptive statistics
00:12:05 Data visualization
00:14:28 Test statistic
00:15:14 Reassignment under the null hypothesis
00:18:30 Visualize the sampling distribution
00:20:06 Estimating a p value
00:21:29 Verifying the p value
00:21:54 End
This is an announcment video of my course at Stellenbsoch University on deep learning in healthcare.
The link to sign up is at at https://shortcourses.sun.ac.za/application-form.html?offeringid=6cc261b2-45da-eb11-abe4-005056801c40
To dowload R go to cran.r-project.org and follow the links for your operating system.
Once you have installed R, go to rstudio.com/products/rstudio/download to dowload and install RStudio, the coding environment that we will use during this course. All the rquired study files will be send to those that sign up.
You can also run RStudio in the cloud. Sign up for a free account at https://rstudio.cloud If you want to go this route, a link will be sent to you after signing up to this course. The email link will take you to your RStudio account in the cloud (make sure that you are signed in) and provide a copy of all the study files.
The following R packages are used in the course:
data.table
DT
tidyverse
knitr
car
gmodels
Looking forward to seeing you.
This is an announcement of my course for the School of Data Science and Computational Thinking at Stellenbosch University.
The course starts on the 16th of August 2021. You will find a link to the course and information on signup at https://shortcourses.sun.ac.za/courses/c-19/2021-5760.html
This course aims to teach the fundamentals of statistics for helathcare and the life sciences using the R language.
There are 15 modules in the course. All are summarised in the video.
Matplotlib is the grandparent of plotting libraries in Python. There is not much that you cannot plot with this package. That makes it daunting to use.
In 80 minutes I try to give you the best introduction to using matplotlib for scientific plots.
0:00:00 I ramble about the tutorial :)
0:01:15 Tutorial starts
0:02:40 Table of contents
0:4:17 Python packages used in this tutorial
0:06:24 Pyplot interface
0:45:41 Object oriented interface
1:02:27 Plots for functions and vectors
1:18:58 Saving plots
WATCH NEXT:
▶️ Linear algebra using sympy: youtu.be/MBhPaqKRehg
▶️ Gram Schmidt process for QR decomposition using Python: youtu.be/fdshjUzUWTs
//You Might Also Like:
~~~~~~~~~~~~~~~
Udemy: udemy.com/mathematica-for-statistics
Udemy: udemy.com/biostatistics-fundamentals-using-python
Udemy: udemy.com/mathematica
Udemy: udemy.com/spss-for-healthcare-and-life-science-statistics
RPubs: http://rpubs.com/juanhklopper
Github: github.com/juanklopper?tab=repositories
//CONNECT WITH ME
~~~~~~~~~~~~~~~
👉 Web: http://www.juanklopper.com
The signup link is here: http://www.sun.ac.za/english/data-science-and-computational-thinking/Pages/Introduction-to-Data-Science-and-Computational-Thinking.aspx
This is an announcement about a new course in Data Science from Stellenbosch University.
I am Dr Juan Klopper from the School for Data Science and Computational Thinking. Hundreds of participants have already signed up. Check back right here in the description for full details on worldwide sign up and further notices.
In this course I teach Data Science using Python. The course will be easy to follow with video lectures, PDF documentation, exercise files, and live online sessions.
During the course we will use Google Colab notebooks so that no one has to worry about any local installations.
You will learn about Python, working with data, summary statistics, data visualisation, probabilities, distributions and sampling distributions, bootstrap resampling, uncertainty, confidence intervals, comparison of means, linear models, nonparametric tests, and comparing categorical variables. You will also learn about machine learning techniques such as k nearest neighbours and random forests and I will show you how to construct a machine learning project.
Watch the video for more information and tell everyone you know. Leave comments down below if you have questions. I hope to see you on the course.
SCHEDULE
Week 1
01 Data Science
02 Data and Definitions
03 The Python Language
Week 2
04 Importing and Manipulating Data
05 Descriptive Statistics
06 Data Visualisation
Week 3
07 Randomness and Sampling
08 Hypothesis Testing
09 Comparing Means
Week 4
10 Uncertainty
11 Linear Models
Week 5
12 Machine Learning
13 k Nearest Neighbours
14 Random Forests
In this video I show you how to think about using bootstrap resampling to express uncertainty in a statistic and also how to think about the sampling distribution of a test statistic and the probability of that test statistic. Using the Julia Language in Visual Studio Code we generate values for a continuous numerical variable for two groups (generated from the two sample space elements of a categorical variable).
Our test statistic is the difference in means for the variable between the two groups. We generate a sampling distribution of the test statistic under the assumption of the null hypothesis. The latter states that there is no difference between the two means, that is, the test statistic is zero. Given this assumption we can randomly reassign subjects to the two groups and recalculate the test statistic. Doing this many times over produces the sampling distribution. We can then see how many of the resampled tests statistics are below the negative of our test statistic and how many are more than positive our test statistic. Adding these and expressing it as a fraction of the number of resamples gives us the p value for our statistic.
We also express the mean for the variable in both groups as a whole. We must consider the uncertainty in this statistic. We estimate the lower and upper bounds for the parameter in the population. This is the confidence interval.
In this video I show you how to think about using bootstrap resampling to express uncertainty in a statistic and also how to think about the sampling distribution of a test statistic and the probability of that test statistic.
Using the Wolfram Language we generate values for a continuous numerical variable for two groups (generated from the two sample space elements of a categorical variable).
Our test statistic is the difference in means for the variable between the two groups. We generate a sampling distribution of the test statistic under the assumption of the null hypothesis. The latter states that there is no difference between the two means, that is, the test statistic is zero. Given this assumption we can randomly reassign subjects to the two groups and recalculate the test statistic. Dong this many times over produces the sampling distribution. We can then see how many of the resampled tests statistics are below the negative of our test statistic and how many are more than positive our test statistic. Adding these and expressing it as a fraction of the number of resamples gives us the p value for our statistic.
We also express the mean for the variable in both groups as a whole. We must consider the uncertainty in this statistic. We estimate the lower and upper bounds for the parameter in the population. This is the confidence interval.
In this 20 minute video I introduce the topic of the the Jacobian. It is simply a matrix of partial derivatives of single and multivariable functions or vector valued functions.
While the Jacobian is easy to calculate by hand, we can also use the symbolic Python package sympy to verify our work.
The Jacbian has many uses. In this video I take a look at its use in the forward propagation step of a simple neural network.
In this video tutorial I show you how to orthogonalize a basis for a vector space of polynomials. It might seems a strange thought, but yes, polynomials that are orthogonal to each other can be created.
In the tutorial I explain the concept of the inner product between two polynomials and use the Gram-Schmidt process to create the orthogonal set of polynomials.
While it is an easy task, I use the Wolfram Language in this video to make life (and understanding) even easier. Code along if you have access to the Wolfram Language or search Google for "Wolfram Programming Lab" and sign up for a free account. You can then code along right in your favorite browser.
At the end of the tutorial, when we have our set of orthogonal polynomials, I also discuss how they are slightly modified to give us the Legendre polynomials.
In this video tutorial I use Python to explain the easy steps of the Gram Schmidt process. Following the steps of this process yields a set of orthonormal basis vectors for the (sub) space spanned by the column vectors of a matrix. Each new column vector is orthogonal to all the other column vectors and each is of unit length.
This change of basis is used in QR factorization or QR decomposition of a matrix.
WATCH NEXT:
▶️ Modern Linear Algebra using Python: youtu.be/MBhPaqKRehg
▶️ Second order ODEs solved with Python using the Euler formula: youtu.be/pV0SY0EtKaI
▶️ Gram Schmidt process for QR decomposition using Python: youtu.be/fdshjUzUWTs
▶️ Second order ODE solved with RK4 in Python: youtu.be/-k64Xa0onfQ
▶️ Solving a system of first order ODEs with RK4 using Python: youtu.be/cQSQCv0XBx8
//You Might Also Like:
~~~~~~~~~~~~~~~
Udemy: udemy.com/mathematica-for-statistics
Udemy: udemy.com/biostatistics-fundamentals-using-python
Udemy: udemy.com/mathematica
Udemy: udemy.com/spss-for-healthcare-and-life-science-statistics
RPubs: http://rpubs.com/juanhklopper
Github: github.com/juanklopper?tab=repositories
//CONNECT WITH ME
~~~~~~~~~~~~~~~
👉 Web: http://www.juanklopper.com
This change of basis is used in QR factorization or QR decomposition of a matrix.
If you want to learn more about the Julia Language take a look at the Playlists here on my channel or earn a certificate from my massive open online course on Coursera coursera.org/learn/julia-programming.
Developing an intuition for OLS requires understanding of the column space of a matrix and how to project a vector onto that space. This is done through a simple schematic and I use Julia code to show just how easy it is to calculate using ordinary least squares.
In the video I develop and intuitive and visual explanation of OLS as a projection onto the column space of a matrix. The calculations are done using Python.
The turotial includes:
An overview of the F distribution given two parameters
Assessment of a linear regression mode using the coefficient of determination
Calculating an F statistic in linear regression
Calculating a p value from the F statistic
The F statistic in the t test and calculating a p value for the statistic
The F statistic in ANOVA and calculating a p value for the statistic
The fundamentals are introduced on the white board, before we open a Jupyter notebook and use python to create an intuitive understanding of the use of the F distribution.
In this fun tutorial I use the Wolfram Langue to look at which planets fit in the distance between the earth and the moon. The Wolfram Language has all of the data built-in.
The files for this tutorial will be made available on GitHub soon.
In this video tutorial I discuss the preparation of tabular data for use in statistical python packages such as statsmodels. The patsy package is ideal for creating design matrices that can be used in statsmodels.
Design matrices in models include the dependent vector and the matrix of independent variables. Functions in patsy can generate these from tabular data. The patsy package can also preprocess the data. It can, for instance, generate design matrices with interaction terms, add new variables to a feature matrix, transform the values of a variable, and many other such transformation.
These trial express their results as efficacy. Efficacy is calculated from relative risk. It is hoped that a vaccine will lower the risk of infection when compared to placebo.
In this video tutorial, I use the R language for statistical computing to explain risk, relative risk, efficacy, and most importantly, confidence intervals for efficacy.
In February 2021 South Africa received their first batch of vaccines (Astra Zeneca). Prior to a roll out to healthcare workers a small trial appeared which showed efficacy of only 21%. For this, and other findings in the trial, the vaccine was withdrawn.
Because the trial was so small and the risk of developing mild and moderate COVID-19 was low in each group, the confidence intervals around the efficacy was very wide.
Follow along in this video to learn more about risk, realative risk, efficacy and confidence intervals. The RPubs documents are avalaible at rpubs.com/juanhklopper and the R markdown files are available at github.com/juanklopper/R_statistics
Please remember to like this video. Subscribe and leave a comment.
Problem 1.1 - 00:00:37
Problem 1.2 - 00:04:27
Problem 1.3 - 00:08:57
Problem 1.4 - 00:15:40
Problem 1.5 - 00:20:22
Problem 1.6 - 00:22:43
Problem 2.1 - 00:34:18
Problem 2.2 - 00:41:06
Problem 2.3 - 00:49:17
Problem 2.4 - 00:54:28
Problem 2.5 - 01:01:25
Problem 2.6 - 01:05:31
Problem 2.7 - 01:12:19
Problem 2.8 - 01:17:21
Problem 2.9 - 01:21:04
Problem 2.10 - 01:26:23
If you want to get the questions in PDF format to try them yourself, visit github.com/juanklopper/Vector-calculus . There is also a PDF files containing notes on the calculus of polar coordinates, as well as all the other files in the series. Remember to check out the Wolfram Language code to try it yourself.
The problem sets for this series are at github.com/juanklopper/Vector-calculus and the one specific to this video is at github.com/juanklopper/Vector-calculus/blob/main/04%20Polar%20coordinates.pdf
The time codes for all the problems are listed below.
Problem 1.1 – 00:00:14
Problem 1.2 – 00:02:21
Problem 1.3 – 00:03:43
Problem 1.4 – 00:13:16
Problem 1.5 – 00:16:05
Problem 1.6 – 00:18:02
Problem 1.7 – 00:19:57
Problem 2.1 – 00:21:34
Problem 2.2 – 00:23:36
Problem 2.3 – 00:24:32
Problem 2.4 – 00:26:57
Problem 2.5 – 00:27:43
Problem 2.6 – 00:29:41
Problem 2.7 – 00:31:38
Problem 2.8 – 00:35:31
Problem 2.9 – 00:38:05
Problem 2.10 – 00:41:32
Problem 2.11 – 00:42:03
Problem 3.1 – 00:42:42
Problem 3.2 – 00:44:46
Problem 3.3 – 00:46:33
Problem 3.4 – 00:49:12
Problem 3.5 – 00:50:28
Problem 3.6 – 00:52:01
Problem 3.7 – 00:53:35
Problem 3.8 – 00:56:10
Problem 3.9 – 00:59:00
Problem 4.1- 01:00:55
Problem 4.2 – 01:06:30
The time codes for the problems are listed below.
Problem 1 – 0:55
Problem 2 – 13:17
Problem 3 – 16:23
Problem 4 – 20:15
Problem 5 – 25:12
The time code for the problems are listed below.
Problem 1.1 - 0:00:29
Problem 1.2 – 0:04:07
Problem 1.3 – 0:07:48
Problem 1.4 – 0:10:14
Problem 1.5 – 0:16:16
Problem 1.6 – 0:17:30
Problem 1.7 – 0:23:28
Problem 1.8 – 0:24:39
Problem 1.9 – 0:27:27
Problem 1.10 – 0:32:20
Problem 1.11 – 0:34:22
Problem 1.12 – 0:36:39
Problem 1.13 – 0:39:24
Problem 1.14 – 0:47:59
Problem 2.1 – 0:54:48
Problem 2.2 – 0:58:05
Problem 2.3 – 1:04:17
Problem 2.4 – 1:09:25
Problem 2.5 – 1:14:10
Problem 2.6 – 1:16:24
I do some of the graphing using the Wolfram Language. Code along for free on the eb by creating an account at wolframcloud.com
To learn how to set up a Julia environment and use it in a Pluto notebook watch this: youtube.com/watch?v=6ewFgLR1LLY&t=35s
It is much easier to do using Julia, though!
To set up a Julia environment and use it in Pluto notebooks, watch this: youtube.com/watch?v=6ewFgLR1LLY&t=35s
The first video was on vectors. Since there is so much to learn about matrices, this second section will be split into nine videos.
This first video simply shows you what a matrix is and how we denote it.
To learn how to set up a Julia environment and to use it in a Pluto notebook, watch this video: youtube.com/watch?v=6ewFgLR1LLY&t=35s
I look at data specific to South Africa and contrast it to data from Germany and the United Kingdom. Since South Africa is behind these countries in COVID-19, we can use data from these nation in helping to predict what will happen in South Africa at the start of 2021.
I state, though, that it is probably better to use distribution-independent (non-parametric) tests.
In the video, we generate data that not normally distributed and use the log and square root transformations to transform it.
The file is available at github.com/juanklopper/Coursera-Doing-clinical-research and at wolframcloud.com/obj/juan.klopper/Published/Data%20transformation%20for%20statistical%20analysis.nb


