library(readr) br2 <- read_delim("br2.csv", delim = ";", escape_double = FALSE, trim_ws = TRUE) # select only traditional houses table(br2$Traditional) # sub data with traditional style br2_traditional <-subset(br2, Traditional==1) # lm price vs sqft for traditional styple houses mod1<-lm(price ~ sqft , data=br2_traditional) coef(mod1) # (Intercept) sqft # -28407.55866 73.77195 summary(mod1) confint(mod1, level= 0.95) # Ho: beta2=0 # H1: beta2>=0 (unilateral test with 1 rej area on the right) # compare p-value with alpha=0.01 # p.value=0.00000 # alpha=0.01 # p-value we reject the null hyp (coef is sign and positive ) # linear regression model PRICE=b1+b2Traditional mod2<-lm(price ~ Traditional, data = br2 ) coef(mod2) # b2=-24706.88 (price of houses in traditional style is -24706.88 less than the houses in not trad style) # [-39.000; + 10000] --> coeff NOT sign # [-39.000; - 10000] --> coeff IS Sign # [+ 10000; + 39000] --> coeff IS sign # if 0 value is included in the bound, then the coeff (var x ) is NOT significant in explaing the variable y confint(mod2, level=0.95) summary(mod2) # hipotesis test # Ho: beta2=0 # H1 beta2>=0 # plvalue=0.00097 # alpha=0.01 # conclusion: reject null Hyp # ci interpretation = price differencial betw trad and non trad houses range from -39 tousand dollars to - 10 tousand dollars (more or less)