Skip to contents

As with residuals.copreg, two flavours are available: type = "structural" gives mu + P alpha + W beta (the causal model without the copula terms), type = "augmented" adds the copula control functions, C gamma, back in.

Usage

# S3 method for class 'copreg'
fitted(object, type = c("structural", "augmented"), ...)

Arguments

object

a fitted model of class "copreg".

type

"structural" (the default) or "augmented".

...

currently unused.

Value

A numeric vector of fitted values, named by the row names of the model frame.

References

Qian, Y., A. Koschmann, and H. Xie (2025). A practical guide to endogeneity correction using copulas. Journal of Marketing.

Examples

set.seed(1)
n  <- 150
w  <- rnorm(n)
p  <- 0.4 * w + rt(n, df = 3)
xi <- 0.5 * p + rnorm(n)
y  <- 1 + 2 * p + 1.5 * w + xi
dat <- data.frame(y = y, p = p, w = w)

fit <- endogCopula:::.copreg_fit(
  formula = y ~ p | w, data = dat,
  ctor = endogCopula:::.ctor_twostage(TRUE),
  method = "2sCOPE", cdf = "rank.n", ties = "max",
  nboots = 25, verbose = FALSE)

fitted(fit)
#>            1            2            3            4            5            6 
#>   0.85068540   7.04895584  -2.81162664  -2.04848540   3.18540066   1.32313294 
#>            7            8            9           10           11           12 
#>   1.10405874  -0.31002028   0.54931481  -3.69243248   4.43303094  -4.02853276 
#>           13           14           15           16           17           18 
#>   1.51118406  -7.67205027   6.63327181   0.47069046  -2.01427158  -0.23424496 
#>           19           20           21           22           23           24 
#>  13.84469473  -6.42280274   3.31077683   1.78387825   4.34309493  -5.03384945 
#>           25           26           27           28           29           30 
#>   2.74239239  -2.45514135   6.72623640  12.79649600  -6.36820854  -0.69218543 
#>           31           32           33           34           35           36 
#>  -1.16748437  -4.46693794   3.05051984   1.67358862  -4.05530450  -0.20050702 
#>           37           38           39           40           41           42 
#>   3.10023466  -1.20625234  -5.85835504   2.48948123  -4.00150677   0.98452465 
#>           43           44           45           46           47           48 
#>   6.12052918   2.08515675  -3.81972778   0.02508309  -0.46536734   3.93194441 
#>           49           50           51           52           53           54 
#>  -8.72992559   0.96632525   9.50402986   7.85172606   3.51676879  -4.97661479 
#>           55           56           57           58           59           60 
#>   6.05993621  12.63915717   2.63625388   2.54105987  -4.70102603   6.32479163 
#>           61           62           63           64           65           66 
#>   8.83875047   0.56942491   6.46083181   8.80851428   4.01932801   5.40518030 
#>           67           68           69           70           71           72 
#> -12.87024635   2.28732060   7.67943700   5.25789060   4.13811114   0.90652967 
#>           73           74           75           76           77           78 
#>  -0.30742924   1.30502623  -1.35360496  -0.77523598  -0.07174603  -0.78742603 
#>           79           80           81           82           83           84 
#>   6.55936883  -0.57825607  -3.94039407   0.05643882   7.67717968  -1.05133558 
#>           85           86           87           88           89           90 
#>   2.02627600   6.74816817   2.33871459  -5.34174629  -0.98808690  -3.77956205 
#>           91           92           93           94           95           96 
#>  -8.26467599  -1.90764388   1.36247908  -1.40301204  -2.02221435   6.74884502 
#>           97           98           99          100          101          102 
#>   4.78043114   1.05590645  -0.89631569  -0.80339379   8.15651091   0.51858941 
#>          103          104          105          106          107          108 
#>  -2.17082349   0.06873905  -0.62668323  14.84571598   4.89528709  10.90939674 
#>          109          110          111          112          113          114 
#>   2.18863783  -2.35065035   0.45355978  -3.37032919   4.65889826  -1.01144688 
#>          115          116          117          118          119          120 
#>   4.40767377   3.01175228  -0.12534950   3.54845838   4.37386410  -0.22679330 
#>          121          122          123          124          125          126 
#>  -0.78431716   2.74664688  -0.10360041  -5.53774736   2.28165444   0.66515976 
#>          127          128          129          130          131          132 
#>  -1.28543167  -4.59754148   2.42571020   0.22834597  -3.53879026   5.22045623 
#>          133          134          135          136          137          138 
#>  -0.67617643  26.71565565  -0.42919612  -5.98140876  -2.42170387   0.09698808 
#>          139          140          141          142          143          144 
#>  -0.75033783   6.69653763 -20.55494277   7.47989237  -2.37242821  -3.23579033 
#>          145          146          147          148          149          150 
#>  -8.98783718  -3.83464718   6.16761899  -1.91485820  -4.38562185  -6.94723040 
fitted(fit, type = "augmented")
#>             1             2             3             4             5 
#>   0.632386995   6.361715838  -2.595246478  -1.268003083   2.934708444 
#>             6             7             8             9            10 
#>   0.987559279   1.175310338   0.042024335   0.760934526  -3.237055516 
#>            11            12            13            14            15 
#>   4.366179661  -3.308692163   1.221750307  -7.254725508   6.280093435 
#>            16            17            18            19            20 
#>   0.470607688  -1.673725991   0.166922575  12.810322016  -5.501501326 
#>            21            22            23            24            25 
#>   3.211706011   1.841638297   3.925889279  -4.867239687   2.641501457 
#>            26            27            28            29            30 
#>  -2.079076564   5.978952030  11.407850943  -5.588817183  -0.384072086 
#>            31            32            33            34            35 
#>  -0.580487133  -3.870776691   2.838989336   1.516016903  -3.830519699 
#>            36            37            38            39            40 
#>  -0.208570466   2.697640445  -0.984531752  -4.814550144   2.438906990 
#>            41            42            43            44            45 
#>  -3.476179964   0.846790270   5.704503927   2.033155420  -3.454588944 
#>            46            47            48            49            50 
#>  -0.138392475  -0.214469250   3.724664159  -7.687815325   1.218514357 
#>            51            52            53            54            55 
#>   8.698670939   7.003232426   3.249101087  -4.589358179   5.785735283 
#>            56            57            58            59            60 
#>  11.847481594   2.290402567   2.013419054  -3.846216423   5.667047437 
#>            61            62            63            64            65 
#>   8.548627428   0.553821635   6.000317247   8.004489009   3.457332757 
#>            66            67            68            69            70 
#>   4.928578251 -11.909078133   2.511383679   6.940217857   5.278052590 
#>            71            72            73            74            75 
#>   3.841809393   0.634538133   0.001364126   0.932050590  -1.457311208 
#>            76            77            78            79            80 
#>  -0.494645162  -0.124043877  -0.590432753   5.947760388  -0.581997831 
#>            81            82            83            84            85 
#>  -3.523571007   0.109438233   7.218065150  -1.284106736   1.992192618 
#>            86            87            88            89            90 
#>   6.170206800   2.394705790  -4.624915240  -0.658835655  -3.182621034 
#>            91            92            93            94            95 
#>  -7.328255372  -1.261064638   1.642963113  -0.942543422  -1.282246814 
#>            96            97            98            99           100 
#>   6.244540024   3.992109558   0.822256201  -1.081890721  -0.714781390 
#>           101           102           103           104           105 
#>   7.206308944   0.537605766  -2.063321739   0.233224926  -0.655269508 
#>           106           107           108           109           110 
#>  13.981188901   4.584935847  10.074712406   2.086110516  -1.462814518 
#>           111           112           113           114           115 
#>   0.259758479  -2.990748060   4.529737420  -0.958094529   3.939975884 
#>           116           117           118           119           120 
#>   2.621810019  -0.116708248   3.124625311   4.047999435  -0.143954611 
#>           121           122           123           124           125 
#>  -0.716701037   2.816705184  -0.051260733  -4.786231475   2.042874324 
#>           126           127           128           129           130 
#>   0.919363729  -1.055847460  -3.933531582   2.014184310   0.158716791 
#>           131           132           133           134           135 
#>  -3.011872944   4.569163189  -0.341612310  25.320958933  -0.203086211 
#>           136           137           138           139           140 
#>  -5.575785357  -2.104217455  -0.016953732  -0.733857548   6.007129016 
#>           141           142           143           144           145 
#> -19.473174020   7.048986380  -2.428159350  -2.869693506  -8.198542982 
#>           146           147           148           149           150 
#>  -3.491400439   6.046905173  -1.581684316  -4.112266497  -6.404945015