Posts

Showing posts with the label regression

Another Logistic Regression from Scratch

Image
 The world doesn't really need another description of how to code logistic regression. A good description of how to implement logistic regression can already be found here . In addition, there are many great packages for logistic regression in Python,  sklearn.linear_model. LogisticRegression ; R glm ; Julia GLM ; and many more.  I started following this course on Udemy. The course began with a brief discussion of logistic regression. I have used logistic regression techniques many times, but I didn't have a clear idea of how to implement it. I thought I might as well try. What follows is a very simple implementation of binary logistic regression . Logistic Regression - Who lives, who dies? Consider the following data. It's from the R package alr4 . It describes the fate of the infamous Donner party . It consists of 91 observations of five variables. The important columns for our purposed are age , y (survival), and sex . We want to know how did age and sex affect s...

Mixed Models Part 2

Image
 In a previous post , we looked at four different linear models for a collection of data where besides x and y values, the data was qualifies by an additional factor called a Group . In those models, we either assumed that the difference in groups had no effect on the model, models 1 and 2, or that the groups were independent, and we could estimate their effects on slope and intercept individually. A compromise between these two approaches is the mixed-effect model , sometimes called a multilevel linear model or a random effects model. The difference is that the groups are assumed to be a random sample from a larger population of groups measuring the same kinds of data. In other words, are the groups we see all the groups we will see or is the data a sample from the world of possible groups? A Linear Model The simplest mixed model is similar to model 2 from the previous post. In this model we expect the Group value to affect the intercept of the linear model.  \[\begin{a...