{"id":1290,"date":"2022-02-14T13:00:24","date_gmt":"2022-02-14T12:00:24","guid":{"rendered":"https:\/\/microdata.spirehost.no\/?post_type=eksempel&#038;p=1290"},"modified":"2023-08-18T13:31:06","modified_gmt":"2023-08-18T12:31:06","slug":"using-instrument-variables-in-regression-analysis","status":"publish","type":"eksempel","link":"https:\/\/www.microdata.no\/en\/eksempel\/using-instrument-variables-in-regression-analysis\/","title":{"rendered":"Using instrument variables in regression analysis"},"content":{"rendered":"\n<p>The command <code>ivregress<\/code> can be used to specify instrument variables. This is applicable if you have a hypothesis that multicollinearity exists (correlation between at least two of the independent variables). You define instrument variables inside the parenthesis expression. In the example below, the instrument variable <em>wealth_high<\/em> is used, and the instrument <em>age<\/em>. But you can use as many instruments as you like. E.g. if you think that place of residence (= Oslo) also affects the amount of wealth, you can use the parenthetical expression(<code>wealth_high = age oslo<\/code>). But in principle, <code>ivregress<\/code> treats all independent variables as instruments, except for the instrument variable.<\/p>\n\n\n<div id=\"rose-block_f6e2046fc10dc0ad548007cbf4a71ac0\" class=\"rose-code codeblock-wrapper\">\n<pre tabindex=\"0\" class=\"codeblock\"><code>require no.ssb.fdb:23 as db\r\n\r\ncreate-dataset ivtest\r\n\r\nimport db\/INNTEKT_WLONN 2021-12-31 as wage\r\nimport db\/BEFOLKNING_FOEDSELS_AAR_MND as birth_year_month\r\n\r\ngenerate age = 2020 - int(birth_year_month \/100)\r\ndrop if age < 18 | age > 60\r\n\r\nimport db\/BEFOLKNING_KJOENN as gender\r\ngenerate male = 0\r\nreplace male = 1 if gender == '1'\r\n\r\nimport db\/INNTEKT_BRUTTOFORM 2020-12-31 as wealth\r\ngenerate wealth_high = 0\r\nreplace wealth_high = 1 if wealth > 1500000\r\n\r\n\/\/First run a regular linear regression\r\nregress wage age male wealth_high\r\n\r\n\/\/Suspects a correlation between age and wealth. Use a model with a instrument variable (wealth_high)\r\nivregress wage male (wealth_high = age)\r\n\r\n\/\/In addition to comparing the two results, a check is performed for multicollinearity and normaldistributed residuals\r\ncorrelate wealth_high age\r\nregress-predict wage age male wealth_high, residuals(res1)\r\nivregress-predict wage male (wealth_high = age), residuals(res2)\r\n\r\nhistogram res1\r\nhistogram res2<\/code><\/pre>\n<\/div>","protected":false},"parent":0,"menu_order":118,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":""},"class_list":["post-1290","eksempel","type-eksempel","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using instrument variables in regression analysis - microdata.no<\/title>\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.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using instrument variables in regression analysis - microdata.no\" \/>\n<meta property=\"og:description\" content=\"The command ivregress can be used to specify instrument variables. This is applicable if you have a hypothesis that multicollinearity exists (correlation between at least two of the independent variables). You define instrument variables inside the parenthesis expression. In the example below, the instrument variable wealth_high is used, and the instrument age. But you can...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/\" \/>\n<meta property=\"og:site_name\" content=\"microdata.no\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-18T12:31:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/bruk-av-instrumentvariabel-i-regresjonsanalyse\\\/\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/bruk-av-instrumentvariabel-i-regresjonsanalyse\\\/\",\"name\":\"Using instrument variables in regression analysis - microdata.no\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\"},\"datePublished\":\"2022-02-14T12:00:24+00:00\",\"dateModified\":\"2023-08-18T12:31:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/bruk-av-instrumentvariabel-i-regresjonsanalyse\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/bruk-av-instrumentvariabel-i-regresjonsanalyse\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/bruk-av-instrumentvariabel-i-regresjonsanalyse\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using instrument variables in regression analysis\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/\",\"name\":\"microdata.no\",\"description\":\"Gj\u00f8r det enklere \u00e5 analysere registerdata\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.microdata.no\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using instrument variables in regression analysis - microdata.no","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.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/","og_locale":"en_US","og_type":"article","og_title":"Using instrument variables in regression analysis - microdata.no","og_description":"The command ivregress can be used to specify instrument variables. This is applicable if you have a hypothesis that multicollinearity exists (correlation between at least two of the independent variables). You define instrument variables inside the parenthesis expression. In the example below, the instrument variable wealth_high is used, and the instrument age. But you can...","og_url":"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/","og_site_name":"microdata.no","article_modified_time":"2023-08-18T12:31:06+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/","url":"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/","name":"Using instrument variables in regression analysis - microdata.no","isPartOf":{"@id":"https:\/\/www.microdata.no\/#website"},"datePublished":"2022-02-14T12:00:24+00:00","dateModified":"2023-08-18T12:31:06+00:00","breadcrumb":{"@id":"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microdata.no\/eksempel\/bruk-av-instrumentvariabel-i-regresjonsanalyse\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hjem","item":"https:\/\/www.microdata.no\/en\/"},{"@type":"ListItem","position":2,"name":"Using instrument variables in regression analysis"}]},{"@type":"WebSite","@id":"https:\/\/www.microdata.no\/#website","url":"https:\/\/www.microdata.no\/","name":"microdata.no","description":"Gj\u00f8r det enklere \u00e5 analysere registerdata","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microdata.no\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"taxonomy_info":[],"featured_image_src_large":[],"author_info":[],"comment_info":"","_links":{"self":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/eksempel\/1290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/eksempel"}],"about":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/types\/eksempel"}],"wp:attachment":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/media?parent=1290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}