{"id":159277,"date":"2022-09-28T12:48:07","date_gmt":"2022-09-28T16:48:07","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=159277"},"modified":"2023-03-13T13:12:15","modified_gmt":"2023-03-13T17:12:15","slug":"understanding-logistic-regression","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/","title":{"rendered":"Understanding Logistic Regression"},"content":{"rendered":"\n<p>This post explains the logistic regression and implements R code for the estimation of its parameters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-introduction\">Introduction<\/h3>\n\n\n\n<p>Logistic Regression is a benchmark machine learning model. This model have a binary response variable (<em>Y<\/em>) which takes on 0 or 1. We can find lots of this kind of variables, among them are success\/failure, bankruptcy\/solvency, exit\/stay. To understand logistic regression model, we should know PMF(probability mass function) of the binomial distribution since its log likelihood function is constructed using this PMF. Given this log likelihood function, we can estimate its parameters by maximizing the log likelihood function by MLE (maximum likelihood estimation).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-pmf-for-the-binomial-distribution\">PMF for the binomial distribution<\/h3>\n\n\n\n<p>Given success probability&nbsp;<em>p<\/em>&nbsp;and the number of trials&nbsp;<em>n<\/em>, binomial distribution produces the probability of occurring&nbsp;<em>x(\u2264n)<\/em>&nbsp;success as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"550\" height=\"70\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-1.png\" alt=\"binomial distribution produces the probability of occurring\u00a0x(\u2264n)\u00a0success as follows\" class=\"wp-image-159294 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-1.png 550w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-1-300x38.png 300w\" data-sizes=\"(max-width: 550px) 100vw, 550px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 550px; aspect-ratio: 550\/70;\" \/><\/figure>\n\n\n\n<p>From the above equation for&nbsp;P(X=x;n,p),&nbsp;<img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-3.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">&nbsp;&nbsp;denotes the case when the number of success is&nbsp;<em>x<\/em>&nbsp;from&nbsp;<em>n<\/em>&nbsp;Bernoulli trials. Let&#8217;s take an example: suppose&nbsp;n = 3, x = 1.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"532\" height=\"133\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-2.png\" alt=\"Let's take an example: suppose\u00a0n = 3, x = 1\" class=\"wp-image-159298 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-2.png 532w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-2-300x75.png 300w\" data-sizes=\"(max-width: 532px) 100vw, 532px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 532px; aspect-ratio: 532\/133;\" \/><\/figure>\n\n\n\n<p><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-11.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"> denotes the probability of&nbsp;<img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-3.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">. This probability of the above example (n = 3, x = 1) is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-5.png\" alt=\"this probability of the above example (n = 3, x = 1) is as follows.\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"><\/figure>\n\n\n\n<p>It is worth noticing that since&nbsp;<em>P(X=x;n,p)<\/em>&nbsp;have one&nbsp;<em>p<\/em>, the symbol of combination is used. This logic is similar to that of calculating one weighted average.<\/p>\n\n\n\n<p>Standard linear regression is used for the calculation of the conditional mean, which is varying with the realization of covariates (<em>X<\/em>). This means that in addition to the unconditional mean, additional information from covariates are useful for the improvement of forecast performance. This story is also applied to logistic regression. Assuming&nbsp;<em>p<\/em>&nbsp;is neither a fixed nor an unconditional probability, we can estimate the conditional probability using explanatory variables (<em>X<\/em>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Logit transformation<\/h3>\n\n\n\n<p>Since explanatory variables<em>&nbsp;X<\/em>&nbsp;have useful information for explaining variation of a binary variable&nbsp;<em>Y<\/em>, we can set up a linear regression model for this binary response variable. But output from a standard linear regression can be of less than zero or more than one. This is, therefore, not appropriate because&nbsp;<em>Y<\/em>&nbsp;is the binary variable which have a range from 0 and 1. From this reason, we need the following logit transformation which converts 0~1 binary variable to&nbsp;\u2212\u221e~\u221e&nbsp;real number.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"561\" height=\"131\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-12.png\" alt=\"we need the following logit transformation which converts 0~1 binary variable to\u00a0\u2212\u221e~\u221e\u00a0real number.\" class=\"wp-image-159357 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-12.png 561w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-12-300x70.png 300w\" data-sizes=\"(max-width: 561px) 100vw, 561px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 561px; aspect-ratio: 561\/131;\" \/><\/figure>\n\n\n\n<p>Using this transformation, we can obtain the logistic regression model in the following way.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"530\" height=\"137\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-6.png\" alt=\"we can obtain the logistic regression model in the following way.\" class=\"wp-image-159312 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-6.png 530w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-6-300x78.png 300w\" data-sizes=\"(max-width: 530px) 100vw, 530px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 530px; aspect-ratio: 530\/137;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Log-likelihood function<\/h3>\n\n\n\n<p>Since each <img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-7.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"> &nbsp;is different with covariates, likelihood function of logistic regression as successive Bernoulli trials, has the following form.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"541\" height=\"92\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-8.png\" alt=\"likelihood function of logistic regression as successive Bernoulli trials, has the following form\" class=\"wp-image-159325 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-8.png 541w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-8-300x51.png 300w\" data-sizes=\"(max-width: 541px) 100vw, 541px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 541px; aspect-ratio: 541\/92;\" \/><\/figure>\n\n\n\n<p>We can find that there is no term like <img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-3.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">  in the likelihood function. The reason is that <img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-7.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"> is different with covariates as mentioned previously. Combination is used only when occurrence probability are fixed and all the same. In particular, to facilitate a numerical optimization, we use the following log likelihood function.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large img-twothird\"><img decoding=\"async\" width=\"564\" height=\"89\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-9.png\" alt=\"facilitate a numerical optimization, we use the following log likelihood function\" class=\"wp-image-159327 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-9.png 564w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-9-300x47.png 300w\" data-sizes=\"(max-width: 564px) 100vw, 564px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 564px; aspect-ratio: 564\/89;\" \/><\/figure>\n\n\n\n<p>It is typical to estimate parameters using MLE by calling numerical optimization. But for ready-made models like linear regression, logistic regression, etc, it is convenient to use glm() R package which performs optimization automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">R code for Logistic Regression<\/h3>\n\n\n\n<p>The following R code shows how to implement logistic regression using R. We provide two-method: the one uses glm() conveniently and the other maximize log likelihood function by numerical MLE directly. To check for the accuracy of estimation, we assume population parameters as&nbsp;<img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic-regression-10.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">. It is, therefore, expected that two methods produce the same results.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#=========================================================================#\n# Financial Econometrics &amp; Derivatives, ML\/DL using R, Python, Tensorflow  \n# by Sang-Heon Lee \n#-------------------------------------------------------------------------#\n# Logistic Regression\n#=========================================================================#\n \ngraphics.off()  # clear all graphs\nrm(list = ls()) # remove all files from your workspace\n \n#-----------------------------------------------------\n# Simulated data\n#-----------------------------------------------------\n \n    # number of observation\n    nobs &lt;- 10000\n    \n    # parameters assumed\n    beta &lt;- c(0.3, 0.5, -0.2)\n    \n    # simulated x\n    x1 &lt;- rnorm(n = nobs)\n    x2 &lt;- rnorm(n = nobs)\n    \n    bx = beta&#91;1] + beta&#91;2]*x1 + beta&#91;3]*x2\n    p = 1 \/ (1 + exp(-bx))\n    \n    # simulated y\n    y &lt;- rbinom(n = nobs, size = 1, prob = p)\n    \n    # simulated y and x\n    df.yx &lt;- data.frame(y, x1, x2)      \n    \n#-----------------------------------------------------\n# Estimation by glm\n#-----------------------------------------------------\n \n    fit_glm = glm(y ~ ., data = df.yx, family = binomial)\n    summary(fit_glm)\n    \n#-----------------------------------------------------\n# Estimation by optimization\n#-----------------------------------------------------\n    \n    # objective function = negative log-likelihood\n    obj.func &lt;- function(b0, df.yx) {\n        \n        beta &lt;- b0\n        y &lt;- df.yx&#91;,1]\n        x &lt;- as.matrix(cbind(1,df.yx&#91;,-1]))\n        \n        bx = x%*%beta\n        p = 1 \/ (1 + exp(-bx)) \n        \n        # we can calculate log-likelihood\n        # using one of the two below\n        \n        # 1. vector operation\n        #\n        loglike &lt;- sum(y*log(p) + (1-y)*log(1-p))\n \n        # 2. loop operation\n        #\n        # loglike &lt;- 0\n        # for(i in 1:nrow(df.yx)) {\n        #    loglike &lt;- loglike + y&#91;i]*log(p&#91;i]) + \n        #               (1-y&#91;i])*log(1-p&#91;i])\n        # }\n \n        return(-1*loglike)\n    }\n    \n    # run optimization\n    m&lt;-optim(c(0.1,0.1,0.1), obj.func,\n             control = list(maxit=5000, trace=2),\n             method=c(\"Nelder-Mead\"),df.yx=df.yx)\n    \n#-----------------------------------------------------\n# Comparison of results\n#-----------------------------------------------------\n    beta\n    m$par\n    coef(fit_glm)<\/code><\/pre>\n\n\n\n<p>The above R program delivers the parameter estimates from two approaches.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"540\" height=\"658\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic_results-sh-fintech.png\" alt=\"R program delivers the parameter estimates from two approaches\" class=\"wp-image-159378 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic_results-sh-fintech.png 540w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/09\/logistic_results-sh-fintech-300x366.png 300w\" data-sizes=\"(max-width: 540px) 100vw, 540px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 540px; aspect-ratio: 540\/658;\" \/><\/figure>\n\n\n\n<p>From the estimation output, we can find that two approaches show the same results. Numerical optimziation for MLE is used only for educational purpose. It is, therefore, recommended to use glm() function.<\/p>\n\n\n\n<p><em>For additional insight on this topic and to download the R script, visit <a href=\"https:\/\/kiandlee.blogspot.com\/2021\/05\/understanding-logistic-regression.html\">https:\/\/kiandlee.blogspot.com\/2021\/05\/understanding-logistic-regression.html<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post explains the logistic regression and implements R code for the estimation of its parameters.<\/p>\n","protected":false},"author":662,"featured_media":96704,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,338,350,341,351,352,344,2197,342],"tags":[806,4922,1006,865,4405,852,487],"contributors-categories":[13728],"class_list":{"0":"post-159277","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-ibkr-quant-news","10":"category-quant-asia-pacific","11":"category-quant-development","12":"category-quant-europe","13":"category-quant-north-america","14":"category-quant-regions","15":"category-quant-south-america","16":"category-r-development","17":"tag-data-science","18":"tag-econometrics","19":"tag-fintech","20":"tag-github","21":"tag-logistic-regression","22":"tag-machine-learning","23":"tag-r","24":"contributors-categories-sh-fintech-modeling"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Understanding Logistic Regression | IBKR Quant<\/title>\n<meta name=\"description\" content=\"This post explains the logistic regression and implements R code for the estimation of its parameters.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/159277\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Logistic Regression | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"This post explains the logistic regression and implements R code for the estimation of its parameters.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-28T16:48:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-13T17:12:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sang-Heon Lee\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sang-Heon Lee\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Sang-Heon Lee\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\"\n\t            },\n\t            \"headline\": \"Understanding Logistic Regression\",\n\t            \"datePublished\": \"2022-09-28T16:48:07+00:00\",\n\t            \"dateModified\": \"2023-03-13T17:12:15+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/\"\n\t            },\n\t            \"wordCount\": 630,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"Econometrics\",\n\t                \"fintech\",\n\t                \"GitHub\",\n\t                \"Logistic Regression\",\n\t                \"Machine Learning\",\n\t                \"R\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Quant\",\n\t                \"Quant Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant Europe\",\n\t                \"Quant North America\",\n\t                \"Quant Regions\",\n\t                \"Quant South America\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/\",\n\t            \"name\": \"Understanding Logistic Regression | IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"datePublished\": \"2022-09-28T16:48:07+00:00\",\n\t            \"dateModified\": \"2023-03-13T17:12:15+00:00\",\n\t            \"description\": \"This post explains the logistic regression and implements R code for the estimation of its parameters.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/understanding-logistic-regression\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Quant\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\",\n\t            \"name\": \"Sang-Heon Lee\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/sang-heonlee\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Understanding Logistic Regression | IBKR Quant","description":"This post explains the logistic regression and implements R code for the estimation of its parameters.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/159277\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Logistic Regression | IBKR Quant Blog","og_description":"This post explains the logistic regression and implements R code for the estimation of its parameters.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/","og_site_name":"IBKR Campus US","article_published_time":"2022-09-28T16:48:07+00:00","article_modified_time":"2023-03-13T17:12:15+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","type":"image\/jpeg"}],"author":"Sang-Heon Lee","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sang-Heon Lee","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/"},"author":{"name":"Sang-Heon Lee","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200"},"headline":"Understanding Logistic Regression","datePublished":"2022-09-28T16:48:07+00:00","dateModified":"2023-03-13T17:12:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/"},"wordCount":630,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","keywords":["Data Science","Econometrics","fintech","GitHub","Logistic Regression","Machine Learning","R"],"articleSection":["Data Science","Programming Languages","Quant","Quant Asia Pacific","Quant Development","Quant Europe","Quant North America","Quant Regions","Quant South America","R Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/","name":"Understanding Logistic Regression | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","datePublished":"2022-09-28T16:48:07+00:00","dateModified":"2023-03-13T17:12:15+00:00","description":"This post explains the logistic regression and implements R code for the estimation of its parameters.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/understanding-logistic-regression\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","width":1000,"height":563,"caption":"Quant"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200","name":"Sang-Heon Lee","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/sang-heonlee\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/159277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/662"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=159277"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/159277\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/96704"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=159277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=159277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=159277"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=159277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}