Linear regression analysis

Linear regression analysis (OLS) is used to estimate marginal effects/coeffisientvalues for a set of explanatory variables, where the dependent variable takes continuously/metrical values. Through options one can adjust the output (exclude the fixed joint, adjust level of significance etc).

//Start by importing relevant variables

create-dataset demografidata
import BEFOLKNING_KJOENN as kjonn
import BEFOLKNING_FOEDSELS_AAR_MND as faarmnd
import SIVSTANDFDT_SIVSTAND 2000-01-01 as sivstand
import INNTEKT_BRUTTOFORM 2000-01-01 as formue
import INNTEKT_WYRKINNT 2005-01-01 as innt05

//Adapt variables to suit the statistical model

generate mann = 0
replace mann = 1 if kjonn == '1'

generate gift = 0
replace gift = 1 if sivstand == '2'

generate alder = 2000 - int(faarmnd / 100)
drop if alder < 16

generate formuehøy = 0
replace formuehøy = 1 if formue > 600000

//Test for multicollinearity/correlation between selected independent variables 

correlate alder formuehøy

//Regression analysis with the dependent variable listed first (requirement)

regress innt05 mann gift alder formuehøy