Skip to contents

Two scales are available. With structural = TRUE (the default) these are the residuals of y = alpha_i + x'beta + z'delta + e on the original rows; with structural = FALSE they are the residuals of the FOD-transformed model on the transformed rows, i.e. the ones the likelihood treats as N(0, sigma^2).

Usage

# S3 method for class 'copregpanel'
residuals(object, structural = TRUE, ...)

Arguments

object

A fitted "copregpanel" object.

structural

Logical; TRUE (the default) for the residuals of the structural model, FALSE for the residuals of the FOD-transformed model.

...

Currently unused.

Value

A named numeric vector of residuals.

Examples

# \donttest{
set.seed(1)
N <- 30L; Time <- 6L
d <- data.frame(id = rep(seq_len(N), each = Time),
                 year = rep(seq_len(Time), times = N))
alpha <- rep(rnorm(N), each = Time)
e <- rnorm(N * Time)
d$x <- exp(rnorm(N * Time) + 0.5 * e)   # endogenous: correlated with e
d$z <- rnorm(N * Time)                  # exogenous
d$y <- alpha + 0.5 * d$x + d$z + e
fit <- CopRegPANEL(y ~ x | z, data = d, index = c("id", "year"),
                    nboots = 15, verbose = FALSE)
residuals(fit)
#>             1             2             3             4             5 
#>  1.4475540650 -0.0585834682  0.4426332250 -0.0560671715 -1.3753237448 
#>             6             7             8             9            10 
#> -0.4002129055 -0.5276841881 -0.2861528292  0.9051908428  0.6091600061 
#>            11            12            13            14            15 
#> -0.3373347404 -0.3631790912  0.5096459172  0.3855896955 -0.8787914759 
#>            16            17            18            19            20 
#> -0.7963049269  0.1929446503  0.5869161398  0.0002037294  0.8968694262 
#>            21            22            23            24            25 
#>  0.3925564760 -0.5702770419  0.4232603724 -1.1426129621  0.9917509586 
#>            26            27            28            29            30 
#>  1.6086264016 -0.7357850852 -1.5140636044  0.1278759915 -0.4784046620 
#>            31            32            33            34            35 
#>  2.1578302477 -0.4991104004  0.2411612753 -0.5470769895 -1.1459938853 
#>            36            37            38            39            40 
#> -0.2068102478 -2.1882029637  1.1634032949 -0.1583456873  2.0379517638 
#>            41            42            43            44            45 
#>  0.1002696652 -0.9550760728  0.8139016549 -0.6667686116 -0.9379219385 
#>            46            47            48            49            50 
#>  0.6264522002 -0.1355554760  0.2998921710  0.2876193863 -0.3298790380 
#>            51            52            53            54            55 
#> -0.3328453150  0.1902360178  1.4223522313 -1.2374832823  0.4159409155 
#>            56            57            58            59            60 
#> -0.1687033353  0.6415116974 -0.6947018442  0.0307627657 -0.2248101992 
#>            61            62            63            64            65 
#> -1.3486340062  0.3673906837  0.2638843877  0.2327536626  0.6962835382 
#>            66            67            68            69            70 
#> -0.2116782660 -0.5788754019  0.0178108780 -0.6082170823  0.2730035002 
#>            71            72            73            74            75 
#>  0.0496734677  0.8466046382 -1.1704409693 -0.1826787780 -1.0311697866 
#>            76            77            78            79            80 
#>  1.4177666390  0.3089753006  0.6575475942  0.1640752646  1.5496550143 
#>            81            82            83            84            85 
#> -1.0162283404 -0.8703356208  1.1426058221 -0.9697721398  0.0785029288 
#>            86            87            88            89            90 
#> -0.3621207347 -0.1745094009 -0.1303598474  0.6703900777 -0.0819030236 
#>            91            92            93            94            95 
#> -0.7635205906  1.0121968461 -0.3693858351 -0.4686421906 -0.1328594263 
#>            96            97            98            99           100 
#>  0.7222111965  0.1982761875  0.2025395443 -0.5289574263 -0.0116911847 
#>           101           102           103           104           105 
#>  0.3270577746 -0.1872248954  0.9807684503 -1.0284439135  1.0223506651 
#>           106           107           108           109           110 
#> -1.0866876777  0.2068637278 -0.0948512520 -0.0650475594  0.4969569978 
#>           111           112           113           114           115 
#> -1.3122738429  1.9204833564 -1.1432121337  0.1030931818 -0.6252556947 
#>           116           117           118           119           120 
#> -0.2230444486  2.4734618844  0.4461370273 -0.8036630258 -1.2676357426 
#>           121           122           123           124           125 
#>  0.9143796881  0.5164787863  0.2246632644 -0.2848039589 -0.9197569169 
#>           126           127           128           129           130 
#> -0.4509608630  0.8630560478 -0.8003765576 -1.6138215981  1.7539369073 
#>           131           132           133           134           135 
#>  0.2301062224 -0.4329010217  0.7391930304  0.6028197919 -0.9436866448 
#>           136           137           138           139           140 
#>  1.8074814285 -0.5327280843 -1.6730795216 -0.6501418475 -0.1992716932 
#>           141           142           143           144           145 
#>  1.9872679007 -0.3730535867 -0.0878676929 -0.6769330804 -0.9993473491 
#>           146           147           148           149           150 
#> -0.8899860604 -0.0408793570  1.3487236587  0.2101466109  0.3713424969 
#>           151           152           153           154           155 
#> -1.1206864889  1.2854473517  0.3955142915 -1.3258186898  0.7534168249 
#>           156           157           158           159           160 
#>  0.0121267106  1.5808943904 -0.6524311954 -0.4861287714 -0.8460319893 
#>           161           162           163           164           165 
#> -0.0799657191  0.4836632848 -0.4985894389  1.1305983512 -0.8309789645 
#>           166           167           168           169           170 
#> -0.7872668013  1.6571210370 -0.6708841835 -0.2058856512 -0.9068388920 
#>           171           172           173           174           175 
#> -0.2089538738  1.2452048576  1.0310800118 -0.9546064525 -2.6455752378 
#>           176           177           178           179           180 
#>  2.2873195291  0.3058109828  0.2262089447 -0.3959838228  0.2222196040 
residuals(fit, structural = FALSE)
#>             1             2             3             4             5 
#>  1.5857160292  0.2581846205  0.9120700972  0.6790811484 -0.6895074869 
#>             7             8             9            10            11 
#> -0.5780490661 -0.4379223606  0.8102898430  0.7833606364  0.0182747157 
#>            13            14            15            16            17 
#>  0.5582891304  0.5450626768 -0.7563087293 -0.9685570845 -0.2785799119 
#>            19            20            21            22            23 
#>  0.0002231743  1.0027760573  0.7122478881 -0.1719547899  1.1072396533 
#>            25            26            27            28            29 
#>  1.0864087429  2.0202612482 -0.0989471496 -1.0931250259  0.4287051614 
#>            31            32            33            34            35 
#>  2.3637846038 -0.0755168800  0.7573002295  0.1055934833 -0.6641031189 
#>            37            38            39            40            41 
#> -2.3970562473  0.8114273688 -0.4786760328  2.0129539018  0.7462421278 
#>            43            44            45            46            47 
#>  0.8915845920 -0.5634760277 -1.0405453162  0.4444059048 -0.3079079840 
#>            49            50            51            52            53 
#>  0.3150712517 -0.3045023267 -0.3965359751  0.0798546258  1.8807877285 
#>            55            56            57            58            59 
#>  0.4556404440 -0.0956088467  0.8121252441 -0.4880021475  0.1807173766 
#>            61            62            63            64            65 
#> -1.4773545340  0.1091915401  0.0214468964 -0.0077967042  0.6420259488 
#>            67            68            69            70            71 
#> -0.6341262312 -0.1095273079 -0.8642739693 -0.1429975800 -0.5635154348 
#>            73            74            75            76            77 
#> -1.2821538422 -0.4659596399 -1.5813043329  0.7630202938 -0.2464778326 
#>            79            80            81            82            83 
#>  0.1797354471  1.7692553214 -0.6787280929 -0.7811851140  1.4936767813 
#>            85            86            87            88            89 
#>  0.0859956499 -0.3873095008 -0.2833795074 -0.3466872035  0.5319515534 
#>            91            92            93            94            95 
#> -0.8363949012  0.9609420829 -0.3547433711 -0.6232465990 -0.6046262358 
#>            97            98            99           100           101 
#>  0.2172006810  0.2707819980 -0.4950818895 -0.0666323462  0.3636527635 
#>           103           104           105           106           107 
#>  1.0743780078 -0.9305287583  1.1667461427 -0.9330056752  0.2133447082 
#>           109           110           111           112           113 
#> -0.0712560312  0.5410697380 -1.3906017976  1.9926948782 -0.8812709400 
#>           115           116           117           118           119 
#> -0.6849332964 -0.3891826982  2.6112246115  1.2098735386  0.3280782543 
#>           121           122           123           124           125 
#>  1.0016527626  0.7819023515  0.6724720550  0.3270517317 -0.3314888687 
#>           127           128           129           130           131 
#>  0.9454305315 -0.7018629961 -1.8453866580  1.5148741181  0.4688169183 
#>           133           134           135           136           137 
#>  0.8097453942  0.8392616028 -0.7022697448  2.3763195907  0.8063502342 
#>           139           140           141           142           143 
#> -0.7121947109 -0.3681686625  2.0494947467  0.0076316302  0.4165321301 
#>           145           146           147           148           149 
#> -1.0947301718 -1.2184955256 -0.5926069918  0.8638363217 -0.1139827041 
#>           151           152           153           154           155 
#> -1.2276505397  1.1865807129  0.5042629296 -1.3950582668  0.5241712667 
#>           157           158           159           160           161 
#>  1.7317830373 -0.3759415196 -0.2933089163 -0.8555910677 -0.3985458908 
#>           163           164           165           166           167 
#> -0.5461773652  1.1525593964 -0.7770865999 -1.0454301610  1.6461482780 
#>           169           170           171           172           173 
#> -0.2255364309 -1.0599141347 -0.5624950578  0.9854853089  1.4040923642 
#>           175           176           177           178           179 
#> -2.8980824707  1.9657323695  0.2497005916  0.2556377752 -0.4371358352 
# }