Description Usage Arguments Details Value See Also Examples
This function is one of the methods for add_ci
, and is
called automatically when add_ci
is used on a fit
of
class lmerMod
. It is recommended that one use parametric
confidence intervals when modeling with a random intercept linear
mixed model (i.e. a fit with a formula such as lmer(y ~ x +
(1|group))
). Otherwise, confidence intervals may be bootstrapped
via lme4::bootMer
.
1 2 3 4 5 6 7 8 9 10 11 12 |
df |
A data frame of new data. |
fit |
An object of class |
alpha |
A real number between 0 and 1. Controls the confidence level of the interval estimates. |
names |
|
yhatName |
A string. Name of the predictions vector. |
type |
A string. Must be |
includeRanef |
A logical. Default is |
nSims |
A positive integer. Controls the number of bootstrap
replicates if |
... |
Additional arguments. |
Bootstrapped intervals are slower to compute, but they are the recommended method when working with any linear mixed models more complicated than the random intercept model.
A dataframe, df
, with predicted values, upper and lower
confidence bounds attached.
add_pi.lmerMod
for prediction intervals
of lmerMod
objects, add_probs.lmerMod
for
conditional probabilities of lmerMod
objects, and
add_quantile.lmerMod
for response quantiles of
lmerMod
objects.
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
dat <- lme4::sleepstudy
# Fit a linear mixed model (random intercept model)
fit <- lme4::lmer(Reaction ~ Days + (1|Subject), data = lme4::sleepstudy)
# Get the fitted values for each observation in dat, and
# append CIs for those fitted values to dat
add_ci(dat, fit, alpha = 0.5)
# Try the parametric bootstrap method, and make prediction at the population level
add_ci(dat, fit, alpha = 0.5, type = "boot", includeRanef = FALSE, nSims = 100)
## End(Not run)
|
ciTools version 0.6.1 (C) Institute for Defense Analyses
Reaction Days Subject pred LCB0.25 UCB0.75
1 249.5600 0 308 289.2678 283.1248 295.4573
2 258.7047 1 308 299.7092 293.6721 305.6818
3 250.8006 2 308 310.2171 304.2840 316.0172
4 321.4398 3 308 320.7969 314.8716 326.5390
5 356.8519 4 308 331.2194 325.1824 336.6276
6 414.6901 5 308 341.6362 336.2246 347.9443
7 382.2038 6 308 351.9924 346.6095 358.4416
8 290.1486 7 308 362.2164 356.5761 369.1494
9 430.5853 8 308 372.5925 366.7214 379.6106
10 466.3535 9 308 383.1775 377.4736 390.2985
11 222.7339 0 309 177.8551 171.4135 185.5225
12 205.2658 1 309 188.3567 182.1316 195.7431
13 202.9778 2 309 199.0163 193.1431 206.2945
14 204.7070 3 309 209.6610 203.6499 216.7201
15 207.7161 4 309 220.1462 214.1147 226.8804
16 215.9618 5 309 230.4414 224.8506 237.1133
17 213.6303 6 309 240.9629 235.3378 247.5267
18 217.7272 7 309 251.4578 245.8656 258.1766
19 224.2957 8 309 261.7217 256.2198 268.7377
20 237.3142 9 309 272.1131 266.6316 279.3964
21 199.0539 0 310 192.2067 185.9449 199.2386
22 194.3322 1 310 202.8421 196.6238 209.5271
23 234.3200 2 310 213.4302 207.0444 219.6554
24 232.8416 3 310 223.9013 217.6611 230.3955
25 229.3074 4 310 234.1446 228.3091 240.9575
26 220.4579 5 310 244.6715 238.6616 251.4680
27 235.4208 6 310 255.1049 249.0655 262.1312
28 255.7511 7 310 265.6904 259.2002 273.0106
29 261.0125 8 310 276.2532 269.4975 283.3771
30 247.5153 9 310 286.9689 279.7617 294.1289
31 321.5426 0 330 254.6814 247.9406 262.1436
32 300.4002 1 330 264.9510 258.5398 272.1878
33 283.8565 2 330 275.7049 269.0879 282.5523
34 285.1330 3 330 286.1368 280.0427 292.7874
35 285.7973 4 330 296.6456 290.5776 303.0740
36 297.5855 5 330 307.2148 301.3441 313.3401
37 280.2396 6 330 318.1292 311.4796 324.0465
38 318.2613 7 330 328.7534 321.9510 334.5757
39 305.3495 8 330 339.3884 332.3431 345.0639
40 354.0487 9 330 349.6279 342.7789 355.7355
41 287.6079 0 331 260.1444 253.7071 266.5578
42 285.0000 1 331 270.5191 264.4807 276.9312
43 301.8206 2 331 281.2868 274.9839 287.5255
44 320.1153 3 331 291.5486 285.5566 297.9239
45 316.2773 4 331 301.8162 296.2504 308.3469
46 293.3187 5 331 312.2543 306.8751 318.6855
47 290.0750 6 331 322.8995 317.0962 328.8926
48 334.8177 7 331 333.0684 327.3393 339.5008
49 293.7469 8 331 343.3660 337.8462 350.1369
50 371.5811 9 331 353.8893 348.2208 360.9518
51 234.8606 0 332 258.4386 252.1851 266.1563
52 242.8118 1 332 269.0858 262.9635 276.3438
53 272.9613 2 332 279.6890 273.4557 286.4644
54 309.7688 3 332 289.9404 284.4897 296.4905
55 317.4629 4 332 300.3647 295.1028 307.0537
56 309.9976 5 332 310.8992 305.4133 317.7552
57 454.1619 6 332 321.6036 315.7282 328.4449
58 346.8311 7 332 332.1329 326.3317 339.0270
59 330.3003 8 332 342.7374 336.2870 349.7977
60 253.8644 9 332 353.2594 346.6700 360.4163
61 283.8424 0 333 266.7434 260.0302 274.2944
62 289.5550 1 333 277.2945 270.6303 284.7103
63 276.7693 2 333 287.6110 281.4719 295.1355
64 299.8097 3 333 298.0270 292.1946 305.4625
65 297.1710 4 333 308.4276 302.4103 315.2564
66 338.1665 5 333 318.7820 312.8254 325.8309
67 332.0265 6 333 329.4885 323.1973 336.4020
68 348.8399 7 333 340.1099 333.6899 346.7872
69 333.3600 8 333 350.9598 343.9853 357.2157
70 362.0428 9 333 361.5191 354.2948 367.9958
71 265.4731 0 334 248.2298 241.9697 255.2659
72 276.2012 1 334 258.4670 252.4375 265.1670
73 243.3647 2 334 268.5396 262.9315 275.2114
74 254.6723 3 334 279.2450 273.8533 285.7815
75 279.0244 4 334 289.6531 284.3893 296.2515
76 284.1912 5 334 299.9993 294.7500 306.7790
77 305.5248 6 334 310.5637 305.2306 317.2005
78 331.5229 7 334 320.9429 315.6149 328.1936
79 335.7469 8 334 331.5124 325.9211 338.5947
80 377.2990 9 334 341.9100 336.4053 349.0994
81 241.6083 0 335 208.8246 202.3026 216.2439
82 273.9472 1 335 219.3703 212.7203 226.1315
83 254.4907 2 335 230.0708 223.1593 236.4106
84 270.8021 3 335 240.4212 233.5042 246.9904
85 251.4519 4 335 250.9265 244.0330 257.4123
86 254.6362 5 335 261.3938 254.4131 268.2363
87 245.4523 6 335 271.8089 264.7755 278.5310
88 235.3110 7 335 282.4291 274.9959 289.2059
89 235.7541 8 335 292.9523 285.4216 299.7593
90 237.2466 9 335 303.7596 295.4639 310.4326
91 312.3666 0 337 318.1266 312.1298 324.5244
92 313.8058 1 337 328.6276 322.5916 334.8685
93 291.6112 2 337 339.2636 333.1118 345.2259
94 346.1222 3 337 349.7879 343.6621 356.0608
95 365.7324 4 337 360.5298 354.4263 366.4977
96 391.8385 5 337 371.2581 364.6000 377.1612
97 404.2601 6 337 381.6474 375.1932 387.8791
98 416.6923 7 337 392.4229 385.4383 398.5790
99 455.8643 8 337 402.9936 395.5870 409.4437
100 458.9167 9 337 413.4305 405.3490 420.1516
101 236.1032 0 349 232.1932 224.7018 238.4395
102 230.3167 1 349 242.5122 235.2059 248.7780
103 238.9256 2 349 253.1684 245.7436 259.3135
104 254.9220 3 349 263.3921 256.2307 269.8082
105 250.7103 4 349 273.8149 266.8768 280.3369
106 269.7744 5 349 284.2771 277.3528 290.8914
107 281.5648 6 349 294.6534 287.7502 301.4577
108 308.1020 7 349 304.8993 298.1462 312.1160
109 336.2806 8 349 315.4128 308.5167 322.5658
110 351.6451 9 349 326.3930 318.8858 333.2235
111 256.2968 0 350 264.8812 258.1747 270.7325
112 243.4543 1 350 275.3979 269.0410 281.0752
113 256.2046 2 350 285.7110 279.7679 291.3610
114 255.5271 3 350 296.2228 290.2334 301.8395
115 268.9165 4 350 306.4352 300.6678 311.9355
116 329.7247 5 350 316.6771 311.0507 322.7460
117 379.4445 6 350 327.1960 321.8484 333.2724
118 362.9184 7 350 337.6469 331.9481 343.7422
119 394.4872 8 350 348.1788 342.1669 354.4067
120 389.0527 9 350 358.5266 352.8671 364.9928
121 250.5265 0 351 244.5941 238.1876 250.7788
122 300.0576 1 351 255.2083 248.6591 261.1451
123 269.8939 2 351 265.7152 259.3737 271.4092
124 280.5891 3 351 276.0632 269.8235 282.1617
125 271.8274 4 351 286.5852 280.2720 292.6353
126 304.6336 5 351 297.0239 290.6922 303.3274
127 287.7466 6 351 307.5290 301.2829 314.1767
128 266.5955 7 351 317.8565 311.8221 324.7872
129 321.5418 8 351 328.3464 321.7592 335.3181
130 347.5655 9 351 339.0232 332.3639 345.9441
131 221.6771 0 352 285.3325 279.2586 291.9019
132 298.1939 1 352 295.4837 289.8796 302.3301
133 326.8785 2 352 306.0606 300.6534 312.3607
134 346.8555 3 352 316.7475 311.0867 322.5634
135 348.7402 4 352 327.0214 321.7525 333.0274
136 352.8287 5 352 337.5398 332.4332 343.4863
137 354.4266 6 352 347.8645 342.7019 353.8501
138 360.4326 7 352 358.3175 352.8176 364.4446
139 375.6406 8 352 369.1185 362.7533 374.9615
140 388.5417 9 352 379.9565 372.9895 385.6145
141 271.9235 0 369 258.4332 251.3092 264.1729
142 268.4369 1 369 269.0236 261.9558 274.7523
143 257.2424 2 369 279.0193 272.4227 285.1875
144 277.6566 3 369 289.5948 283.2098 295.4699
145 314.8222 4 369 300.1534 293.5838 305.7889
146 317.2135 5 369 310.5530 304.1309 316.0357
147 298.1353 6 369 320.7576 314.8179 326.4905
148 348.1229 7 369 331.2463 325.5022 337.1408
149 340.2800 8 369 341.6191 335.8289 347.8233
150 366.5131 9 369 352.1442 345.9868 358.6378
151 225.2640 0 370 245.3301 238.7508 252.3267
152 234.5235 1 370 255.7637 249.3249 263.1909
153 238.9008 2 370 266.2529 259.9771 273.4907
154 240.4730 3 370 277.0493 270.5201 283.7240
155 267.5373 4 370 287.6103 281.2275 294.1309
156 344.1937 5 370 297.9537 291.8134 304.3273
157 281.1481 6 370 308.2526 302.0980 315.3372
158 347.5855 7 370 318.8310 312.3472 326.0458
159 365.1630 8 370 329.4624 322.7346 336.3049
160 372.2288 9 370 340.1088 332.8037 346.9413
161 269.8804 0 371 247.6461 240.3394 253.9678
162 272.4428 1 371 258.1299 251.2291 264.3176
163 277.8989 2 371 268.6032 262.1156 274.7990
164 281.7895 3 371 279.0288 272.7747 285.2247
165 279.1705 4 371 289.3000 283.3841 295.6987
166 284.5120 5 371 299.6474 293.8507 306.0975
167 259.2658 6 371 310.0876 304.4920 316.6305
168 304.6306 7 371 320.4965 315.0950 327.0402
169 350.7807 8 371 331.0530 325.6927 337.9049
170 369.4692 9 371 341.5112 336.0573 348.3466
171 269.4117 0 372 268.5214 262.2912 274.6502
172 273.4740 1 372 278.9957 272.8498 284.9580
173 297.5968 2 372 289.3419 283.0864 295.5726
174 310.6316 3 372 299.7144 293.4572 305.9781
175 287.1726 4 372 310.0917 304.0954 316.2456
176 329.6076 5 372 320.8763 314.5660 326.7115
177 334.4818 6 372 331.5243 325.3691 337.7064
178 343.2199 7 372 341.9861 335.5299 348.1539
179 369.1417 8 372 352.5127 345.8407 358.7223
180 364.1236 9 372 363.1310 356.0240 369.0624
Reaction Days Subject pred LCB0.25 UCB0.75
1 249.5600 0 308 253.5027 245.8242 260.9467
2 258.7047 1 308 263.5685 256.7850 270.7548
3 250.8006 2 308 274.3686 267.8226 280.3737
4 321.4398 3 308 285.6002 278.6498 290.6217
5 356.8519 4 308 296.5267 289.5747 301.0672
6 414.6901 5 308 306.7795 300.2963 311.9968
7 382.2038 6 308 316.9215 310.4144 322.3543
8 290.1486 7 308 326.8623 320.4549 333.8066
9 430.5853 8 308 336.9923 330.6790 344.8616
10 466.3535 9 308 347.1669 340.6084 355.4023
11 222.7339 0 309 253.5027 245.8242 260.9467
12 205.2658 1 309 263.5685 256.7850 270.7548
13 202.9778 2 309 274.3686 267.8226 280.3737
14 204.7070 3 309 285.6002 278.6498 290.6217
15 207.7161 4 309 296.5267 289.5747 301.0672
16 215.9618 5 309 306.7795 300.2963 311.9968
17 213.6303 6 309 316.9215 310.4144 322.3543
18 217.7272 7 309 326.8623 320.4549 333.8066
19 224.2957 8 309 336.9923 330.6790 344.8616
20 237.3142 9 309 347.1669 340.6084 355.4023
21 199.0539 0 310 253.5027 245.8242 260.9467
22 194.3322 1 310 263.5685 256.7850 270.7548
23 234.3200 2 310 274.3686 267.8226 280.3737
24 232.8416 3 310 285.6002 278.6498 290.6217
25 229.3074 4 310 296.5267 289.5747 301.0672
26 220.4579 5 310 306.7795 300.2963 311.9968
27 235.4208 6 310 316.9215 310.4144 322.3543
28 255.7511 7 310 326.8623 320.4549 333.8066
29 261.0125 8 310 336.9923 330.6790 344.8616
30 247.5153 9 310 347.1669 340.6084 355.4023
31 321.5426 0 330 253.5027 245.8242 260.9467
32 300.4002 1 330 263.5685 256.7850 270.7548
33 283.8565 2 330 274.3686 267.8226 280.3737
34 285.1330 3 330 285.6002 278.6498 290.6217
35 285.7973 4 330 296.5267 289.5747 301.0672
36 297.5855 5 330 306.7795 300.2963 311.9968
37 280.2396 6 330 316.9215 310.4144 322.3543
38 318.2613 7 330 326.8623 320.4549 333.8066
39 305.3495 8 330 336.9923 330.6790 344.8616
40 354.0487 9 330 347.1669 340.6084 355.4023
41 287.6079 0 331 253.5027 245.8242 260.9467
42 285.0000 1 331 263.5685 256.7850 270.7548
43 301.8206 2 331 274.3686 267.8226 280.3737
44 320.1153 3 331 285.6002 278.6498 290.6217
45 316.2773 4 331 296.5267 289.5747 301.0672
46 293.3187 5 331 306.7795 300.2963 311.9968
47 290.0750 6 331 316.9215 310.4144 322.3543
48 334.8177 7 331 326.8623 320.4549 333.8066
49 293.7469 8 331 336.9923 330.6790 344.8616
50 371.5811 9 331 347.1669 340.6084 355.4023
51 234.8606 0 332 253.5027 245.8242 260.9467
52 242.8118 1 332 263.5685 256.7850 270.7548
53 272.9613 2 332 274.3686 267.8226 280.3737
54 309.7688 3 332 285.6002 278.6498 290.6217
55 317.4629 4 332 296.5267 289.5747 301.0672
56 309.9976 5 332 306.7795 300.2963 311.9968
57 454.1619 6 332 316.9215 310.4144 322.3543
58 346.8311 7 332 326.8623 320.4549 333.8066
59 330.3003 8 332 336.9923 330.6790 344.8616
60 253.8644 9 332 347.1669 340.6084 355.4023
61 283.8424 0 333 253.5027 245.8242 260.9467
62 289.5550 1 333 263.5685 256.7850 270.7548
63 276.7693 2 333 274.3686 267.8226 280.3737
64 299.8097 3 333 285.6002 278.6498 290.6217
65 297.1710 4 333 296.5267 289.5747 301.0672
66 338.1665 5 333 306.7795 300.2963 311.9968
67 332.0265 6 333 316.9215 310.4144 322.3543
68 348.8399 7 333 326.8623 320.4549 333.8066
69 333.3600 8 333 336.9923 330.6790 344.8616
70 362.0428 9 333 347.1669 340.6084 355.4023
71 265.4731 0 334 253.5027 245.8242 260.9467
72 276.2012 1 334 263.5685 256.7850 270.7548
73 243.3647 2 334 274.3686 267.8226 280.3737
74 254.6723 3 334 285.6002 278.6498 290.6217
75 279.0244 4 334 296.5267 289.5747 301.0672
76 284.1912 5 334 306.7795 300.2963 311.9968
77 305.5248 6 334 316.9215 310.4144 322.3543
78 331.5229 7 334 326.8623 320.4549 333.8066
79 335.7469 8 334 336.9923 330.6790 344.8616
80 377.2990 9 334 347.1669 340.6084 355.4023
81 241.6083 0 335 253.5027 245.8242 260.9467
82 273.9472 1 335 263.5685 256.7850 270.7548
83 254.4907 2 335 274.3686 267.8226 280.3737
84 270.8021 3 335 285.6002 278.6498 290.6217
85 251.4519 4 335 296.5267 289.5747 301.0672
86 254.6362 5 335 306.7795 300.2963 311.9968
87 245.4523 6 335 316.9215 310.4144 322.3543
88 235.3110 7 335 326.8623 320.4549 333.8066
89 235.7541 8 335 336.9923 330.6790 344.8616
90 237.2466 9 335 347.1669 340.6084 355.4023
91 312.3666 0 337 253.5027 245.8242 260.9467
92 313.8058 1 337 263.5685 256.7850 270.7548
93 291.6112 2 337 274.3686 267.8226 280.3737
94 346.1222 3 337 285.6002 278.6498 290.6217
95 365.7324 4 337 296.5267 289.5747 301.0672
96 391.8385 5 337 306.7795 300.2963 311.9968
97 404.2601 6 337 316.9215 310.4144 322.3543
98 416.6923 7 337 326.8623 320.4549 333.8066
99 455.8643 8 337 336.9923 330.6790 344.8616
100 458.9167 9 337 347.1669 340.6084 355.4023
101 236.1032 0 349 253.5027 245.8242 260.9467
102 230.3167 1 349 263.5685 256.7850 270.7548
103 238.9256 2 349 274.3686 267.8226 280.3737
104 254.9220 3 349 285.6002 278.6498 290.6217
105 250.7103 4 349 296.5267 289.5747 301.0672
106 269.7744 5 349 306.7795 300.2963 311.9968
107 281.5648 6 349 316.9215 310.4144 322.3543
108 308.1020 7 349 326.8623 320.4549 333.8066
109 336.2806 8 349 336.9923 330.6790 344.8616
110 351.6451 9 349 347.1669 340.6084 355.4023
111 256.2968 0 350 253.5027 245.8242 260.9467
112 243.4543 1 350 263.5685 256.7850 270.7548
113 256.2046 2 350 274.3686 267.8226 280.3737
114 255.5271 3 350 285.6002 278.6498 290.6217
115 268.9165 4 350 296.5267 289.5747 301.0672
116 329.7247 5 350 306.7795 300.2963 311.9968
117 379.4445 6 350 316.9215 310.4144 322.3543
118 362.9184 7 350 326.8623 320.4549 333.8066
119 394.4872 8 350 336.9923 330.6790 344.8616
120 389.0527 9 350 347.1669 340.6084 355.4023
121 250.5265 0 351 253.5027 245.8242 260.9467
122 300.0576 1 351 263.5685 256.7850 270.7548
123 269.8939 2 351 274.3686 267.8226 280.3737
124 280.5891 3 351 285.6002 278.6498 290.6217
125 271.8274 4 351 296.5267 289.5747 301.0672
126 304.6336 5 351 306.7795 300.2963 311.9968
127 287.7466 6 351 316.9215 310.4144 322.3543
128 266.5955 7 351 326.8623 320.4549 333.8066
129 321.5418 8 351 336.9923 330.6790 344.8616
130 347.5655 9 351 347.1669 340.6084 355.4023
131 221.6771 0 352 253.5027 245.8242 260.9467
132 298.1939 1 352 263.5685 256.7850 270.7548
133 326.8785 2 352 274.3686 267.8226 280.3737
134 346.8555 3 352 285.6002 278.6498 290.6217
135 348.7402 4 352 296.5267 289.5747 301.0672
136 352.8287 5 352 306.7795 300.2963 311.9968
137 354.4266 6 352 316.9215 310.4144 322.3543
138 360.4326 7 352 326.8623 320.4549 333.8066
139 375.6406 8 352 336.9923 330.6790 344.8616
140 388.5417 9 352 347.1669 340.6084 355.4023
141 271.9235 0 369 253.5027 245.8242 260.9467
142 268.4369 1 369 263.5685 256.7850 270.7548
143 257.2424 2 369 274.3686 267.8226 280.3737
144 277.6566 3 369 285.6002 278.6498 290.6217
145 314.8222 4 369 296.5267 289.5747 301.0672
146 317.2135 5 369 306.7795 300.2963 311.9968
147 298.1353 6 369 316.9215 310.4144 322.3543
148 348.1229 7 369 326.8623 320.4549 333.8066
149 340.2800 8 369 336.9923 330.6790 344.8616
150 366.5131 9 369 347.1669 340.6084 355.4023
151 225.2640 0 370 253.5027 245.8242 260.9467
152 234.5235 1 370 263.5685 256.7850 270.7548
153 238.9008 2 370 274.3686 267.8226 280.3737
154 240.4730 3 370 285.6002 278.6498 290.6217
155 267.5373 4 370 296.5267 289.5747 301.0672
156 344.1937 5 370 306.7795 300.2963 311.9968
157 281.1481 6 370 316.9215 310.4144 322.3543
158 347.5855 7 370 326.8623 320.4549 333.8066
159 365.1630 8 370 336.9923 330.6790 344.8616
160 372.2288 9 370 347.1669 340.6084 355.4023
161 269.8804 0 371 253.5027 245.8242 260.9467
162 272.4428 1 371 263.5685 256.7850 270.7548
163 277.8989 2 371 274.3686 267.8226 280.3737
164 281.7895 3 371 285.6002 278.6498 290.6217
165 279.1705 4 371 296.5267 289.5747 301.0672
166 284.5120 5 371 306.7795 300.2963 311.9968
167 259.2658 6 371 316.9215 310.4144 322.3543
168 304.6306 7 371 326.8623 320.4549 333.8066
169 350.7807 8 371 336.9923 330.6790 344.8616
170 369.4692 9 371 347.1669 340.6084 355.4023
171 269.4117 0 372 253.5027 245.8242 260.9467
172 273.4740 1 372 263.5685 256.7850 270.7548
173 297.5968 2 372 274.3686 267.8226 280.3737
174 310.6316 3 372 285.6002 278.6498 290.6217
175 287.1726 4 372 296.5267 289.5747 301.0672
176 329.6076 5 372 306.7795 300.2963 311.9968
177 334.4818 6 372 316.9215 310.4144 322.3543
178 343.2199 7 372 326.8623 320.4549 333.8066
179 369.1417 8 372 336.9923 330.6790 344.8616
180 364.1236 9 372 347.1669 340.6084 355.4023
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.