setwd('D:/Rml')
library('BMA')
## Loading required package: survival
## Loading required package: leaps
## Loading required package: robustbase
## 
## Attaching package: 'robustbase'
## The following object is masked from 'package:survival':
## 
##     heart
## Loading required package: inline
## Loading required package: rrcov
## Scalable Robust Estimators with High Breakdown Point (version 1.5-2)
q = read.csv('diamonds.csv')
head(q)
##   X carat       cut color clarity depth table price    x    y    z
## 1 1  0.23     Ideal     E     SI2  61.5    55   326 3.95 3.98 2.43
## 2 2  0.21   Premium     E     SI1  59.8    61   326 3.89 3.84 2.31
## 3 3  0.23      Good     E     VS1  56.9    65   327 4.05 4.07 2.31
## 4 4  0.29   Premium     I     VS2  62.4    58   334 4.20 4.23 2.63
## 5 5  0.31      Good     J     SI2  63.3    58   335 4.34 4.35 2.75
## 6 6  0.24 Very Good     J    VVS2  62.8    57   336 3.94 3.96 2.48
attach(q)
t = cbind(carat,cut,color,clarity,depth,table,x,y,z)
p = price
s = bicreg(t,p, strict=FALSE, OR=20)
## Warning in model.matrix.default(formula(cdf), data = cdf): the response appeared
## on the right-hand side and was dropped
## Warning in model.matrix.default(formula(cdf), data = cdf): problem with term 8
## in model.matrix: no columns are assigned
summary(s)
## 
## Call:
## bicreg(x = t, y = p, strict = FALSE, OR = 20)
## 
## 
##   1  models were selected
##  Best  1  models (cumulative posterior probability =  1 ): 
## 
##            p!=0   EV       SD       model 1    
## Intercept  100   15948.10  386.849    15948.10 
## carat      100   10982.14   57.559    10982.14 
## cut        100      70.99    5.810       70.99 
## color      100    -266.47    3.590     -266.47 
## clarity    100     287.88    3.488      287.88 
## depth      100    -154.70    4.456     -154.70 
## table      100     -93.55    2.805      -93.55 
## x          100   -1140.54   24.245    -1140.54 
## z            0       0.00    0.000       .     
##                                                
## nVar                                        7  
## r2                                        0.885
## BIC                                 -116614.56 
## post prob                                 1

Select model 1

=> model1: price = 15948.1 + 10982.14.carat + 70.99.cut - 266.47.color + 287.88.clarity - 154.7.depth - 93.55.table - 1140.54.x

With the first observation, we have: price = 141.1092

CONCLUSION: