Bayesian Regression Model

The mathematical formula for our Bayesian model is:

[ _i = _0 + _1 _i + _2 _i + _i ]

Where:

  • (_i) is the income level of individual (i),
  • (_i) and (_i) are the predictor variables for race and sex,
  • (_0) is the intercept,
  • (_1) and (_2) are the coefficients associated with race and sex, respectively,
  • (_i) represents the error term.

Model Fitting in R

Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using SDK: ‘MacOSX13.3.sdk’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c foo.c -o foo.o
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Core:19:
/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: 'cmath' file not found
#include <cmath>
         ^~~~~~~
1 error generated.
make: *** [foo.o] Error 1
Table of Parameter Estimates
Parameter Estimate Est..Error X95..CI.Lower X95..CI.Upper
Intercept Intercept 0.00 0.02 -0.05 0.05
raceAsianMPacMIslander raceAsianMPacMIslander 0.14 0.03 0.09 0.19
raceBlack raceBlack 0.03 0.02 -0.02 0.08
raceOther raceOther -0.02 0.04 -0.09 0.05
raceWhite raceWhite 0.13 0.02 0.08 0.18
sexMale sexMale 0.19 0.00 0.18 0.20
Rows: 32,561
Columns: 15
$ age            <int> 90, 82, 66, 54, 41, 34, 38, 74, 68, 41, 45, 38, 52, 32,…
$ workclass      <chr> "?", "Private", "?", "Private", "Private", "Private", "…
$ fnlwgt         <int> 77053, 132870, 186061, 140359, 264663, 216864, 150601, …
$ education      <chr> "HS-grad", "HS-grad", "Some-college", "7th-8th", "Some-…
$ education.num  <int> 9, 9, 10, 4, 10, 9, 6, 16, 9, 10, 16, 15, 13, 14, 16, 1…
$ marital.status <chr> "Widowed", "Widowed", "Widowed", "Divorced", "Separated…
$ occupation     <chr> "?", "Exec-managerial", "?", "Machine-op-inspct", "Prof…
$ relationship   <chr> "Not-in-family", "Not-in-family", "Unmarried", "Unmarri…
$ race           <chr> "White", "White", "Black", "White", "White", "White", "…
$ sex            <chr> "Female", "Female", "Female", "Female", "Female", "Fema…
$ capital.gain   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ capital.loss   <int> 4356, 4356, 4356, 3900, 3900, 3770, 3770, 3683, 3683, 3…
$ hours.per.week <int> 40, 18, 40, 40, 40, 45, 40, 20, 40, 60, 35, 45, 20, 55,…
$ native.country <chr> "United-States", "United-States", "United-States", "Uni…
$ income         <chr> "<=50K", "<=50K", "<=50K", "<=50K", "<=50K", "<=50K", "…