Calculation of Akaike Information Criterion - r

My data file is given below.
Expt. (Col 1:2) Fit1 (Col 3:4) Fit2 (Col 5:6)
x_expt. y_expt x_fit y_fit x_fit y_fit
2.89394 3.04606 2.95515 3.14485 2.96485 3.16485
2.90727 3.22788 2.96788 3.31939 2.97758 3.34061
2.92788 3.42545 2.98242 3.50303 2.99212 3.52606
2.97576 3.62303 2.99818 3.69758 3.00788 3.72182
2.97394 3.84182 3.01576 3.90182 3.02545 3.92848
3.00061 4.06364 3.03515 4.11818 3.04485 4.14606
3.02788 4.29939 3.05636 4.34545 3.06606 4.37515
3.05758 4.54848 3.08 4.58545 3.0897 4.61697
3.09455 4.80424 3.10606 4.83818 3.11576 4.87212
3.12909 5.07818 3.13515 5.10424 3.14485 5.14061
3.1697 5.37152 3.16667 5.38485 3.17758 5.42364
3.20727 5.65333 3.20182 5.68061 3.21273 5.72182
3.25394 5.98 3.24061 5.99152 3.25212 6.03576
3.30061 6.30909 3.28364 6.32121 3.29576 6.36364
3.35697 6.66061 3.33091 6.66667 3.34364 6.71515
3.41212 7.0303 3.38242 7.02424 3.39636 7.07879
3.47273 7.41818 3.44 7.40606 3.45455 7.46667
3.54606 7.82424 3.50303 7.81212 3.51818 7.87273
3.62242 8.24848 3.57212 8.2303 3.58909 8.29697
3.69939 8.69697 3.64788 8.67879 3.66667 8.74545
3.79212 9.16364 3.73152 9.14545 3.75212 9.21212
3.8903 9.66061 3.82364 9.6303 3.84545 9.70909
4.00242 10.1818 3.92424 10.1455 3.94848 10.2242
4.13212 10.6909 4.03455 10.6849 4.06121 10.7697
4.29697 11.2667 4.15576 11.2546 4.18485 11.3394
4.39273 11.8909 4.28788 11.8485 4.32061 11.9394
4.5503 12.5091 4.43273 12.4727 4.46848 12.5636
4.72061 13.2 4.59152 13.1212 4.63091 13.2242
4.89152 13.8424 4.76424 13.8061 4.80788 13.9091
5.07818 14.5636 4.95333 14.5212 5.00061 14.6303
5.30303 15.3212 5.15879 15.2667 5.21091 15.3818
5.54606 16.0788 5.38303 16.0485 5.44 16.1636
5.79212 16.8909 5.62667 16.8667 5.68848 16.9879
6.07273 17.7273 5.89212 17.7212 5.95939 17.8424
6.35152 18.6303 6.18182 18.6121 6.25455 18.7333
6.67879 19.5394 6.49091 19.5394 6.5697 19.6667
6.99394 20.4727 6.8303 20.503 6.91515 20.6364
7.42424 21.4485 7.19394 21.5091 7.28485 21.6424
7.73939 22.497 7.59394 22.5515 7.69091 22.6909
8.17576 23.5879 8.01818 23.6424 8.12121 23.7758
8.64242 24.7091 8.47879 24.7697 8.58788 24.903
9.12727 25.8242 8.97576 25.9394 9.09091 26.0788
9.59394 27.0727 9.50909 27.1515 9.6303 27.2909
10.1636 28.297 10.0788 28.4061 10.2061 28.5455
10.6909 29.5212 10.6909 29.7091 10.8242 29.8424
11.3939 31.0121 11.3455 31.0485 11.4909 31.1818
12.1152 32.4121 12.0485 32.4364 12.1939 32.5697
12.903 33.8667 12.8 33.8667 12.9455 34
13.6364 35.3515 13.5939 35.3455 13.7515 35.4667
14.4303 36.8546 14.4485 36.8606 14.6 36.9818
15.2849 38.5515 15.3515 38.4242 15.503 38.5394
16.2606 40.1939 16.3091 40.0303 16.4606 40.1455
17.2364 41.8909 17.3212 41.6788 17.4788 41.7879
18.3212 43.7091 18.3939 43.3697 18.5455 43.4727
19.4667 45.5576 19.5273 45.103 19.6788 45.2061
20.5152 46.8849 20.7212 46.8788 20.8667 46.9758
22.0606 49.1758 21.9818 48.6909 22.1152 48.7939
23.3152 51.1879 23.303 50.5515 23.4303 50.6485
24.7212 53.1576 24.6909 52.4485 24.8061 52.5455
26.2121 55.4727 26.1455 54.3879 26.2485 54.4849
a). Col 1:2 represent experimental data.
b). Col 3:4 is fitted data using non-linear least squares fitting using 4 adjustable parameters.
c). Col 5:6 is fitted data using non-linear least squares fitting using 5 adjustable parameters with one parameter fixed to 0.
I wish to calculate AIC for both the fits and conclude which fit is better. Can anybody suggest how to solve this problem in R or Excel?

Related

I don't know how to read the output when using ranef against the output of gamm in the mgcv package

id:268 levels
group:10 levels
Fitted a mixed-effects model using gamm in the mgcv package. Fitted a generalized additive model for age and bmi, but could not read the output of the random effect using ranef
model:
ilrgamm1 <-gamm(y~z1+z2+z3+s(age)+sex+s(bmi)+time,random=list(id=~1+time,group=~1),data=data,method = "REML")
At this time, there are mysterious things like g and g.0 in the output of ranef
names(ranef(ilrgamm1$lme))
[1] "g" "g.0" "id" "group"
ranef(ilrgamm1$lme)[1:2]
$g
Xr1 Xr2 Xr3 Xr4 Xr5 Xr6 Xr7 Xr8
1 0.1130164 0.6108163 -0.1332607 0.4076337 -0.04366085 2.503919 -0.9792176 -0.5911858
$g.0
Xr.01 Xr.02 Xr.03 Xr.04 Xr.05 Xr.06 Xr.07 Xr.08
1/1 0.1983299 0.2758039 -1.100218 -0.4742126 -0.5449821 1.477916 -0.6329114 1.053759
What is Xr1 or Xr2?
Furthermore, there are 268 random effects in group, not 10.
$group
(Intercept)
1/1/102/1 0.0172579674
1/1/103/1 0.0201196786
1/1/104/1 -0.0281116571
1/1/105/1 -0.0217217446
1/1/106/1 0.0124654493
1/1/108/1 -0.0282589006
1/1/109/1 -0.0499878886
1/1/110/1 0.0492600500
1/1/111/1 0.0507119068
1/1/113/1 0.0546332994
1/1/114/1 0.0393550975
1/1/115/1 -0.0148861329
1/1/116/1 0.0375339571
1/1/117/1 0.0148069805
1/1/118/1 -0.0351320894
1/1/119/1 -0.1195068445
1/1/120/1 -0.1160370216
1/1/121/1 0.0473366382
1/1/122/1 -0.0111156856
1/1/123/1 0.0076577605
1/1/124/1 -0.0042122818
1/1/125/1 0.0249031339
1/1/126/1 -0.1207996724
1/1/127/1 0.0275137051
1/1/128/1 -0.0004621387
1/1/130/1 -0.0080189325
1/1/132/1 -0.0147162203
1/1/133/1 0.0019108355
1/1/134/1 0.0048134559
1/1/135/1 -0.0275929191
1/1/136/1 0.0024070977
1/1/138/1 -0.0364971159
1/1/139/1 -0.0250644476
1/1/140/1 -0.0161684667
1/1/143/1 0.0097684438
1/1/144/1 -0.0254024942
1/1/145/1 -0.0308170535
1/1/146/1 -0.0314913020
1/1/147/1 0.0047849092
1/1/148/1 0.0398563674
1/1/149/1 -0.0328543231
1/1/201/2 -0.0386289339
1/1/202/2 -0.0164038050
1/1/203/2 -0.0310222871
1/1/204/2 -0.0465893084
1/1/206/2 -0.0639166021
1/1/207/2 0.0178124681
1/1/208/2 -0.0215777533
1/1/209/2 -0.0008097909
1/1/211/2 -0.0276369553
1/1/218/2 -0.0233586483
1/1/219/2 -0.0381510950
1/1/220/2 -0.0245044572
1/1/221/2 0.0257439303
1/1/222/2 -0.0526194229
1/1/223/2 -0.0598638388
1/1/224/2 -0.0564427102
1/1/226/2 -0.0682312455
1/1/227/2 0.0025178471
1/1/228/2 0.0050413163
1/1/229/2 0.0006566180
1/1/230/2 -0.0394159991
1/1/233/2 -0.0339136266
1/1/234/2 -0.0355879691
1/1/235/2 0.0264388355
1/1/236/2 -0.0190059575
1/1/237/2 -0.0466046545
1/1/238/2 -0.0103843873
1/1/239/2 0.0030630609
1/1/242/2 -0.0385347399
1/1/246/2 -0.0233604289
1/1/247/2 -0.0549077802
1/1/249/2 -0.0309410264
1/1/250/2 -0.0138412118
1/1/251/2 -0.0236995292
1/1/252/2 -0.0263367786
1/1/253/2 -0.0158340565
1/1/254/2 -0.0003306973
1/1/255/2 -0.0106150344
1/1/256/2 -0.0223922258
1/1/258/2 0.0042958519
1/1/301/3 0.1100838962
1/1/302/3 0.0240153141
1/1/303/3 0.0403893185
1/1/306/3 0.0483381436
1/1/307/3 -0.0129870303
1/1/309/3 0.0173975588
1/1/310/3 -0.0189250961
1/1/313/3 0.0357035256
1/1/315/3 0.0012214394
1/1/316/3 0.0325373842
1/1/317/3 -0.0085589305
1/1/319/3 0.0524899049
1/1/321/3 0.0416124283
1/1/322/3 0.0095534385
1/1/325/3 0.0321591953
1/1/326/3 -0.0054073693
1/1/327/3 0.0050364482
1/1/328/3 0.0531385640
1/1/331/3 0.0232251446
1/1/332/3 0.0189221949
1/1/333/3 -0.0181158192
1/1/334/3 -0.0359340965
1/1/335/3 0.0083524511
1/1/336/3 -0.0118781160
1/1/337/3 -0.0085829648
1/1/338/3 0.0095829746
1/1/401/4 -0.0512378233
1/1/402/4 -0.0219261499
1/1/403/4 -0.0160446585
1/1/407/4 0.0017872369
1/1/408/4 -0.0371254332
1/1/409/4 0.0303154843
1/1/411/4 -0.0026150821
1/1/412/4 0.1418719283
1/1/414/4 -0.0556019328
1/1/415/4 0.0073027068
1/1/416/4 -0.0122557311
1/1/417/4 0.0367134933
1/1/418/4 -0.0253763258
1/1/419/4 -0.0203686506
1/1/421/4 -0.0187932155
1/1/422/4 -0.0189659510
1/1/423/4 -0.0306159126
1/1/424/4 0.0273308724
1/1/425/4 0.0040657657
1/1/426/4 0.0312199779
1/1/429/4 0.0036135869
1/1/430/4 -0.0256442792
1/1/433/4 0.0438767257
1/1/434/4 0.0150299855
1/1/435/4 -0.0058240553
1/1/436/4 0.0028309330
1/1/437/4 -0.0023443246
1/1/438/4 0.0115472464
1/1/439/4 -0.0071635162
1/1/441/4 -0.0187692003
1/1/442/4 -0.0301687031
1/1/443/4 -0.0054707553
1/1/501/5 0.0233900218
1/1/502/5 0.0270437356
1/1/503/5 -0.0505494678
1/1/504/5 -0.0555547708
1/1/506/5 -0.0232974224
1/1/508/5 -0.0316901016
1/1/510/5 0.0498275109
1/1/511/5 0.0140125034
1/1/513/5 -0.1284098189
1/1/514/5 0.0336408919
1/1/515/5 -0.0328592365
1/1/516/5 -0.0264024730
1/1/601/6 -0.0064048726
1/1/602/6 0.0136098007
1/1/603/6 0.0437196138
1/1/604/6 0.0685239133
1/1/605/6 -0.0141230573
1/1/606/6 0.0555226687
1/1/607/6 -0.0411745650
1/1/608/6 0.0219745785
1/1/609/6 -0.0045706685
1/1/610/6 -0.0176662070
1/1/611/6 0.0408741543
1/1/612/6 0.0187626096
1/1/613/6 0.0561545743
1/1/614/6 0.0284241671
1/1/615/6 0.0157012751
1/1/616/6 0.0496079608
1/1/701/7 -0.0398327297
1/1/702/7 -0.0140910866
1/1/705/7 0.0286548362
1/1/706/7 0.0369761615
1/1/708/7 0.0116733825
1/1/709/7 0.0001330362
1/1/710/7 0.0274371733
1/1/711/7 0.0090225922
1/1/712/7 0.0765875063
1/1/713/7 0.0148952419
1/1/714/7 -0.0054933850
1/1/716/7 0.0043641233
1/1/717/7 -0.0119174808
1/1/719/7 0.0010953154
1/1/723/7 -0.0371240564
1/1/801/8 0.0636698316
1/1/803/8 0.0246677751
1/1/804/8 -0.0445965919
1/1/806/8 -0.0289816619
1/1/807/8 0.0076561215
1/1/808/8 0.0237686430
1/1/809/8 0.0450896739
1/1/810/8 0.0149585857
1/1/811/8 0.0075693911
1/1/812/8 0.0085475577
1/1/813/8 -0.0136763527
1/1/814/8 0.0117384418
1/1/815/8 0.0067855948
1/1/816/8 0.0140344652
1/1/817/8 0.0103800524
1/1/818/8 -0.0361848876
1/1/819/8 0.0449431626
1/1/820/8 -0.0092320086
1/1/822/8 -0.0404730405
1/1/823/8 -0.0494073578
1/1/824/8 -0.0029941736
1/1/825/8 -0.0145742585
1/1/826/8 -0.0314564014
1/1/828/8 0.0183565957
1/1/829/8 0.0288121410
1/1/830/8 0.0286684412
1/1/831/8 0.0059331890
1/1/832/8 0.0341139486
1/1/833/8 0.0386864016
1/1/834/8 0.0147205534
1/1/835/8 -0.0031409478
1/1/901/9 0.0660687434
1/1/902/9 0.0564001190
1/1/903/9 0.0756466936
1/1/904/9 0.0096398307
1/1/905/9 0.0221015690
1/1/906/9 0.0046220720
1/1/907/9 0.0412366347
1/1/908/9 0.0284303878
1/1/909/9 0.0452359853
1/1/910/9 -0.0195940019
1/1/911/9 -0.0154676475
1/1/912/9 0.0184574647
1/1/913/9 0.0460445032
1/1/914/9 -0.0067133484
1/1/915/9 -0.0087355534
1/1/916/9 -0.0043938763
1/1/917/9 -0.0470434649
1/1/919/9 0.0794927553
1/1/920/9 0.0555903561
1/1/921/9 -0.0036186615
1/1/922/9 0.0078238313
1/1/923/9 0.0143975055
1/1/924/9 0.0731162776
1/1/925/9 -0.0065668921
1/1/926/9 0.0549429919
1/1/927/9 0.0368946293
1/1/928/9 0.0247474240
1/1/929/9 -0.0404517417
1/1/930/9 -0.0076552298
1/1/1001/10 0.0117082112
1/1/1002/10 0.0068444544
1/1/1003/10 0.0327977955
1/1/1004/10 0.0071551344
1/1/1005/10 -0.0052717304
1/1/1006/10 0.0483668189
1/1/1007/10 -0.0167403419
1/1/1008/10 -0.0364566907
1/1/1009/10 -0.0254350538
1/1/1010/10 0.0504571167
1/1/1011/10 -0.0039537094
1/1/1012/10 -0.0054692797
1/1/1013/10 0.0224140597
1/1/1014/10 -0.0310392331
1/1/1015/10 -0.0498130767
1/1/1016/10 -0.0223939677
1/1/1017/10 0.0041103780
1/1/1018/10 0.0880528857
1/1/1019/10 -0.0467056887
1/1/1022/10 -0.0769873686
1/1/1025/10 -0.0229126779
1/1/1028/10 -0.0340772236
1/1/1029/10 -0.0251866535
1/1/1030/10 0.0307034344
1/1/1031/10 -0.0369165146
1/1/1035/10 -0.0056637857
Why not 10 types, which is the number of levels in group?
Is there a reason you're using gamm() instead of gam()? Also, why list time as both a fixed and random effect?
If there aren't reasons for these choices, then one possible solution could be to fit your model as ilrgamm1 <- gam(y~z1+z2+z3+s(age)+sex+s(bmi)+s(time, bs="re"), data=data, method = "REML") - the s(time, bs="re") is indicating that time is a random effect.
Then you can use summary(ilrgamm1) to look at your results, and partial effects plots in plot.gam() or with ggpredict to visualize trends in your smoothed variables.

How to get a probability density function from vector?

I have a vector that I want to transform into a probability density function. The mean is 1. How do I plot this?
The vector:
x <-
c(0.7601401, 0.8607037, 0.8748152, 0.885415, 0.8904619, 0.899021,
0.9034128, 0.9050411, 0.9093876, 0.9141021, 0.9172803, 0.9209636,
0.9238607, 0.9268591, 0.9293789, 0.9313833, 0.9335163, 0.9360798,
0.9406245, 0.9427261, 0.9441703, 0.9473808, 0.9502454, 0.9518683,
0.9540568, 0.955987, 0.9580035, 0.9617511, 0.9635325, 0.964507,
0.9674928, 0.9692979, 0.9705296, 0.9732977, 0.9754498, 0.977204,
0.9793093, 0.9821249, 0.9841156, 0.9864521, 0.9873941, 0.9883275,
0.9904071, 0.9920552, 0.9946789, 0.9967097, 0.997695, 0.9992215,
1.001643, 1.0038606, 1.006269, 1.0077312, 1.0091087, 1.0100767,
1.0113615, 1.0124576, 1.0154025, 1.017386, 1.0189122, 1.021932,
1.0238598, 1.0258631, 1.0273012, 1.0294901, 1.031085, 1.0336801,
1.0371085, 1.0387533, 1.0406862, 1.0436292, 1.0453442, 1.0471563,
1.0514885, 1.0531803, 1.055339, 1.059578, 1.0643068, 1.0668389,
1.0694237, 1.073174, 1.0759322, 1.0786821, 1.0846407, 1.0904819,
1.0968733, 1.1039872, 1.1081845, 1.1144191, 1.124116, 1.1378536,
1.1631801, 0.8238456, 0.8621417, 0.8750536, 0.8864652, 0.8913426,
0.899054, 0.9034444, 0.9052496, 0.9096515, 0.9141042, 0.9174039,
0.9215185, 0.9240734, 0.9272829, 0.9294991, 0.9315397, 0.9335967,
0.9370766, 0.9408574, 0.9427551, 0.9444246, 0.9474299, 0.9503871,
0.9520593, 0.9541102, 0.9560759, 0.9586173, 0.9618885, 0.9636027,
0.9653304, 0.9677295, 0.9693085, 0.9706549, 0.9735909, 0.9757686,
0.9772445, 0.9795081, 0.9823502, 0.9843492, 0.9866112, 0.9874782,
0.9883432, 0.9904612, 0.99227, 0.9948917, 0.9968164, 0.9979785,
0.999409, 1.0017522, 1.0038956, 1.0064009, 1.007936, 1.0092714,
1.0101577, 1.0113745, 1.0124722, 1.015455, 1.0174442, 1.0190047,
1.0221244, 1.0241163, 1.0262672, 1.0274717, 1.0295358, 1.0311976,
1.0337105, 1.0376287, 1.0391993, 1.0412049, 1.043784, 1.0458161,
1.0471989, 1.0515136, 1.0532311, 1.0553901, 1.0598511, 1.0647286,
1.0674053, 1.0695112, 1.0731966, 1.0765993, 1.0804314, 1.0846581,
1.0915069, 1.0983415, 1.1041094, 1.1087707, 1.1153954, 1.1244647,
1.1387218, 1.1631806, 0.8268138, 0.8625675, 0.8751377, 0.886809,
0.8920388, 0.8991269, 0.9034886, 0.9060083, 0.9102798, 0.9143602,
0.9178468, 0.9221248, 0.9241217, 0.9273233, 0.929575, 0.9316477,
0.9337809, 0.9374138, 0.9410309, 0.9429906, 0.9455161, 0.9475521,
0.9506105, 0.9522978, 0.9541801, 0.9567138, 0.9588403, 0.961889,
0.9637248, 0.9658144, 0.9678051, 0.9694083, 0.9708232, 0.9737623,
0.9757794, 0.9772462, 0.9799384, 0.9826819, 0.9844438, 0.9866957,
0.9875501, 0.9884927, 0.9905356, 0.992504, 0.9952807, 0.9970651,
0.9979877, 0.9996339, 1.0018148, 1.0039266, 1.0064778, 1.0080148,
1.0093728, 1.0101958, 1.0115577, 1.0128605, 1.0155767, 1.0176005,
1.0191159, 1.0222069, 1.0241286, 1.0263724, 1.0275547, 1.0298965,
1.0314567, 1.0347959, 1.0377489, 1.0392566, 1.0413151, 1.043814,
1.0462065, 1.0472742, 1.0516567, 1.0533239, 1.0556568, 1.0599784,
1.0648656, 1.0674582, 1.0695187, 1.0737822, 1.0767733, 1.0805175,
1.085116, 1.0919541, 1.0987864, 1.1045691, 1.1090898, 1.1155974,
1.1244743, 1.1403648, 1.1653051, 0.8287487, 0.8632563, 0.8783957,
0.8872595, 0.8921496, 0.8991388, 0.9038431, 0.9063199, 0.9106785,
0.9144, 0.9189027, 0.9223262, 0.924352, 0.9275484, 0.9296723,
0.932303, 0.9340644, 0.9375086, 0.9410767, 0.9431117, 0.9455282,
0.9476748, 0.9506839, 0.9524355, 0.9542676, 0.9570338, 0.9591047,
0.9620121, 0.9638592, 0.9660401, 0.9678991, 0.9695856, 0.9710773,
0.9740787, 0.9760428, 0.9773099, 0.9800677, 0.9830478, 0.9845491,
0.9868047, 0.9876641, 0.9885819, 0.990765, 0.9929082, 0.9953852,
0.9972524, 0.9980094, 0.999655, 1.0019781, 1.0041123, 1.0065022,
1.0080436, 1.0093745, 1.0102597, 1.011591, 1.0133388, 1.0160004,
1.0177403, 1.0197461, 1.0223301, 1.0243601, 1.0264419, 1.0277154,
1.0300746, 1.0315714, 1.0348406, 1.0377535, 1.0396123, 1.0416248,
1.0438679, 1.0463796, 1.0473053, 1.0518621, 1.0535013, 1.0566508,
1.0602571, 1.0649945, 1.0675837, 1.0696383, 1.0737915, 1.0768286,
1.0807683, 1.0866947, 1.0922428, 1.0993173, 1.1053873, 1.1097462,
1.1160662, 1.1245894, 1.1439087, 1.1653756, 0.8336881, 0.8641065,
0.8801013, 0.8873061, 0.892528, 0.8992721, 0.9040462, 0.9064932,
0.9118009, 0.9147806, 0.9194353, 0.922346, 0.924704, 0.9279243,
0.9298283, 0.9325862, 0.9345334, 0.9376213, 0.9413217, 0.9435098,
0.9457126, 0.948086, 0.9507289, 0.9526298, 0.9544503, 0.9570495,
0.9594515, 0.9622223, 0.9639176, 0.9664818, 0.9681109, 0.9697204,
0.9715772, 0.974512, 0.9761773, 0.9774122, 0.9801115, 0.9830508,
0.9848412, 0.9868423, 0.987876, 0.9886175, 0.9911154, 0.9930527,
0.995429, 0.9972859, 0.9980303, 1.000341, 1.0023467, 1.0041273,
1.0066877, 1.0081464, 1.0094208, 1.0103294, 1.0117416, 1.0134278,
1.0162053, 1.0179561, 1.0202328, 1.0227929, 1.0244661, 1.0266619,
1.0278932, 1.0301724, 1.0318422, 1.034844, 1.0378449, 1.0396893,
1.0416388, 1.0441611, 1.0464143, 1.0485936, 1.0520624, 1.0535133,
1.0568916, 1.0602833, 1.0652996, 1.0678024, 1.0700347, 1.0739087,
1.0768747, 1.0811584, 1.08706, 1.092342, 1.0994397, 1.1057555,
1.1101622, 1.1197734, 1.1260845, 1.144113, 1.1656149, 0.8364483,
0.8665228, 0.8801799, 0.8876104, 0.8951142, 0.9004983, 0.9041605,
0.9067967, 0.9123546, 0.9151016, 0.9195613, 0.9224414, 0.9250538,
0.9280133, 0.9299708, 0.9326035, 0.9346515, 0.9380998, 0.9414107,
0.9435515, 0.9461568, 0.9482194, 0.9508463, 0.9527514, 0.9546165,
0.9571445, 0.9596505, 0.9624602, 0.963954, 0.9665085, 0.9682382,
0.9699198, 0.9716006, 0.974844, 0.9761914, 0.9775793, 0.9801981,
0.9835029, 0.9848844, 0.9869101, 0.9878904, 0.988621, 0.9913567,
0.9933158, 0.9955091, 0.9973969, 0.9982784, 1.0004438, 1.0024634,
1.0043027, 1.006941, 1.0081515, 1.0094608, 1.0103653, 1.0117473,
1.0142556, 1.0165854, 1.0181703, 1.0205428, 1.022822, 1.0245166,
1.02681, 1.0278956, 1.0302434, 1.032, 1.0355287, 1.037906, 1.0401162,
1.041886, 1.0442367, 1.0464702, 1.0486031, 1.0521055, 1.0540157,
1.0570109, 1.0605447, 1.0654882, 1.0679469, 1.0700915, 1.0746908,
1.076962, 1.0811779, 1.0880499, 1.0925217, 1.1000415, 1.1068352,
1.1103446, 1.1198258, 1.1278557, 1.144615, 1.1659478, 0.8428518,
0.8685433, 0.8806388, 0.8878492, 0.8957898, 0.9008499, 0.9041908,
0.907718, 0.9124535, 0.9154017, 0.9195873, 0.9228693, 0.9252186,
0.9280587, 0.9302431, 0.9327066, 0.9346733, 0.9382416, 0.9415437,
0.943858, 0.9463773, 0.9482644, 0.9510351, 0.9529947, 0.9548508,
0.9571599, 0.9597816, 0.9632479, 0.9640826, 0.9667552, 0.9688842,
0.9699332, 0.972455, 0.9748674, 0.9765135, 0.9782475, 0.9804558,
0.9835081, 0.9849378, 0.9869651, 0.9879891, 0.9886996, 0.9913707,
0.9933895, 0.9958194, 0.9974753, 0.9984636, 1.0005798, 1.0027019,
1.0043733, 1.007001, 1.008266, 1.0097909, 1.0104785, 1.0119673,
1.0145991, 1.0166569, 1.0182844, 1.0211453, 1.0231898, 1.0245254,
1.0268803, 1.0279336, 1.0304433, 1.0322581, 1.035589, 1.0382374,
1.0401349, 1.0422173, 1.0444101, 1.0465514, 1.0486237, 1.0521174,
1.054423, 1.057825, 1.0606672, 1.0656468, 1.0684325, 1.0709319,
1.0749488, 1.0770775, 1.0820547, 1.0881332, 1.0925439, 1.1000816,
1.1069162, 1.1106217, 1.120701, 1.1302275, 1.1459233, 1.168602,
0.8488214, 0.8702316, 0.8809238, 0.8890422, 0.8958309, 0.9019966,
0.9042307, 0.9079107, 0.9132285, 0.9154252, 0.9198471, 0.9230071,
0.9253286, 0.9283751, 0.9304839, 0.9327088, 0.9348709, 0.9382659,
0.9417193, 0.943864, 0.9466926, 0.9485074, 0.9511567, 0.9532046,
0.9554877, 0.9574181, 0.9600951, 0.963362, 0.9643226, 0.9667904,
0.9689357, 0.9699377, 0.9726418, 0.9749534, 0.9766888, 0.9786503,
0.9816446, 0.9836604, 0.9850502, 0.9869678, 0.9880833, 0.9894534,
0.9914227, 0.9937725, 0.9962026, 0.9975144, 0.9987734, 1.0006365,
1.0029989, 1.0047337, 1.0071024, 1.0086273, 1.0098207, 1.0110381,
1.0119714, 1.01463, 1.0166717, 1.0183924, 1.0212439, 1.0234931,
1.0245751, 1.0269182, 1.0286172, 1.0306589, 1.0322592, 1.0359487,
1.038269, 1.0402549, 1.0422949, 1.0445157, 1.0466529, 1.0487325,
1.0523088, 1.0546675, 1.0584369, 1.0618338, 1.0658283, 1.0687319,
1.0712981, 1.0750357, 1.0777228, 1.082814, 1.0896652, 1.092878,
1.1002284, 1.1072211, 1.1112157, 1.1210507, 1.1331503, 1.1510694,
1.1729349, 0.8533762, 0.8705291, 0.882901, 0.8898704, 0.8964921,
0.9026909, 0.9043496, 0.9082536, 0.9132482, 0.9167392, 0.9200439,
0.923801, 0.9257428, 0.9287926, 0.9310369, 0.9327569, 0.935825,
0.9396949, 0.9418288, 0.9439139, 0.9468012, 0.9487367, 0.9513136,
0.9534568, 0.9557201, 0.9577258, 0.9606246, 0.9634036, 0.9644277,
0.9668756, 0.9689947, 0.9699737, 0.9726901, 0.9749863, 0.9768128,
0.9790117, 0.9817103, 0.9837448, 0.9853122, 0.98713, 0.9881006,
0.9896077, 0.9918675, 0.9939561, 0.9962435, 0.9975984, 0.9988964,
1.0007611, 1.0032765, 1.0052762, 1.0072548, 1.008838, 1.0098927,
1.011057, 1.0120007, 1.0153072, 1.0167114, 1.0183976, 1.0217836,
1.0235315, 1.0250021, 1.0270587, 1.0287792, 1.0308106, 1.032815,
1.0363681, 1.0384448, 1.0403337, 1.0423298, 1.0446048, 1.046717,
1.0487547, 1.0527611, 1.0548012, 1.0586172, 1.0622363, 1.0665121,
1.0690857, 1.0720846, 1.0755489, 1.0784088, 1.0840459, 1.089944,
1.093356, 1.1004089, 1.1073085, 1.1124143, 1.1211267, 1.1339292,
1.1517573, 1.198363, 0.8571564, 0.8726188, 0.8845936, 0.8898835,
0.8980876, 0.9028112, 0.9044216, 0.9086289, 0.9133134, 0.9168552,
0.9203877, 0.9238087, 0.926413, 0.929035, 0.9313117, 0.9330642,
0.9358536, 0.9400013, 0.9420459, 0.9439535, 0.9469293, 0.9491097,
0.9513609, 0.9535177, 0.9557438, 0.9577505, 0.9608692, 0.9634749,
0.9644502, 0.9669999, 0.9690555, 0.9703173, 0.9727357, 0.9750629,
0.9769616, 0.9790537, 0.9817755, 0.9837511, 0.9856411, 0.9872352,
0.9882029, 0.990218, 0.9919514, 0.9941591, 0.9965548, 0.9976154,
0.9990174, 1.0010466, 1.003395, 1.0055957, 1.007304, 1.0089384,
1.0099392, 1.0112263, 1.012146, 1.0153451, 1.0171438, 1.0186295,
1.0217893, 1.0236026, 1.0256126, 1.0271073, 1.0289151, 1.0309176,
1.033115, 1.036525, 1.0385212, 1.0406626, 1.0429921, 1.0447711,
1.0468007, 1.0501243, 1.0527771, 1.0549067, 1.0590568, 1.0635208,
1.066646, 1.0691815, 1.0725159, 1.0756145, 1.0784323, 1.0844119,
1.0900761, 1.0937593, 1.1018746, 1.1080635, 1.112721, 1.1223554,
1.1342245, 1.1589387, 1.3267105, 0.8593686, 0.8738442, 0.8847164,
0.8900729, 0.8985823, 0.9030722, 0.9047745, 0.9089145, 0.9133781,
0.9170319, 0.9205633, 0.9238323, 0.92677, 0.929173, 0.931353,
0.933437, 0.9359658, 0.9403774, 0.9424343, 0.9441537, 0.9472636,
0.9497636, 0.9514515, 0.9539961, 0.955913, 0.9577903, 0.9613333,
0.9635, 0.9644766, 0.9672279, 0.9690912, 0.9704478, 0.9730493,
0.975256, 0.9771195, 0.9792525, 0.982091, 0.9839065, 0.9862609,
0.9872484, 0.9882653, 0.9902789, 0.9919861, 0.9944648, 0.996593,
0.9976709, 0.9992019, 1.0012796, 1.0036569, 1.0061553, 1.0075918,
1.0089733, 1.0100455, 1.0112892, 1.0124005, 1.0153452, 1.0172939,
1.0186304, 1.0218203, 1.0238237, 1.0256419, 1.0272337, 1.0289253,
1.0310775, 1.0333971, 1.0365301, 1.0386841, 1.0406816, 1.04333,
1.0448819, 1.0471028, 1.0501926, 1.0528722, 1.0551719, 1.059271,
1.0638416, 1.0667384, 1.0691885, 1.0729292, 1.0756769, 1.0786645,
1.0844603, 1.0902495, 1.0940123, 1.1037544, 1.1080977, 1.1140658,
1.1234296, 1.1354923, 1.1600791)
You can get a nonparametric estimate by using the ?density function to compute the kernel density estimate, with default Gaussian kernel.
x <- density(vector)
plot(x)
Note that you can also generate an empirical cdf with the base ecdf function. That allows you to calculate F(x) for any x. E.g.
x <- rnorm(1000)
cdf <- ecdf(x)
plot(cdf)
f <- cdf(0.5)
f
[1] 0.692

Bootstrap p value contradicts p value for likelihood ratio test

I have the same problem as the one posted by #soapsuds here. I did not want to ask a duplicate question but when I tried to edit the original question to provide the reproducible example that was missing in the original post my edits got rejected. Since the reproducible example has a lot of elements, I could not write it as a comment to the original question either, so I provide my code and my reproducible data here, as a separate question.
I am trying to compare two models using the likelihood ratio test. From bootstrapping I get a set of 1000 p-values. Here are the numbers I get:
chi2 <- c(41.83803376, 69.23970174, 42.5479637, 50.90208302, 39.18366824, 78.88589665, 28.88469406, 34.99980796, 85.80860848, 66.01750186, 29.06286, 46.43221576, 46.50523792, 59.87362884, 46.17274808, 77.97429928, 48.04404216, 12.88592623, 43.1883816, 33.24251471, 53.27310465, 56.92595147, 47.99838583, 46.0718587, 49.0760042, 29.70866297, 66.80696553, 66.61091741, 37.82375112, 50.19760846, 30.99961864, 27.17687828, 37.46944206, 66.36226432, 48.30737714, 43.64410333, 23.78480451, 42.52842793, 60.49309556, 46.29154, 26.96744296, 32.21561396, 48.20316788, 38.73153704, 67.80328765, 55.00664931, 36.74645735, 23.3647159, 56.35290442, 38.11055268, 58.3316501, 36.00500638, 41.36949956, 49.09067881, 64.42712507, 23.97787069, 54.5394799, 87.02114296, 26.01402166, 50.47426712, 38.58006084, 48.47626864, 22.28809699, 58.87590487, 17.59264288, 33.32650413, 67.77868338, 60.95427815, 37.19931376, 36.23280256, 53.54379697, 70.06479334, 41.3482703, 34.54099647, 55.99585144, 30.60500406, 32.02745276, 37.92670127, 44.23450124, 40.38607671, 44.02263294, 40.89874789, 62.74174279, 50.95137406, 47.12851204, 26.03848394, 36.6202765, 61.06296311, 50.17094183, 35.93242228, 41.8913277, 35.19089913, 38.88574534, 66.075866, 26.34296242, 49.99887059, 42.97123036, 34.89006324, 66.5460019, 67.61855859, 48.52166614, 41.41324193, 46.76294302, 14.87650733, 24.11661382, 62.28747719, 43.94865019, 44.20328393, 41.17756328, 43.74055584, 49.46236395, 38.59558107, 42.85073398, 49.81046036, 36.60331917, 39.85328124, 59.31376822, 61.36038822, 52.56707689, 29.19196892, 46.473958, 39.12904163, 38.75057931, 36.32493909, 49.61088785, 33.42904297, 34.73661836, 33.97736002, 37.44094284, 57.73605417, 43.14773064, 42.78707831, 26.84112684, 48.47832871, 45.94043053, 71.13563773, 46.28614795, 42.33386157, 59.31216832, 46.72946806, 47.76027545, 52.45174304, 49.99459367, 59.00971014, 24.03299408, 17.09453132, 37.44112252, 46.6352525, 60.42442286, 39.35194465, 46.57121135, 56.28622077, 59.20354176, 57.72511864, 41.97053375, 27.97077407, 29.70497125, 46.63976021, 40.24305901, 24.84335714, 36.08600444, 61.619572, 69.31377401, 86.91496878, 44.47955842, 44.1230351, 46.12514671, 43.97381958, 71.99269072, 47.01277643, 50.08167664, 27.01076954, 31.32586466, 40.96782215, 19.07024825, 53.00009679, 43.15397869, 42.49652848, 53.47325607, 43.45891027, 42.57719313, 39.40459925, 42.15077856, 52.23784844, 33.07947933, 45.02462309, 59.187763, 51.9198527, 48.3179841, 76.10501177, 34.95091433, 40.75545034, 31.27034043, 39.83209227, 47.87278051, 46.25057806, 62.84591205, 41.24656655, 68.14749236, 53.11576938, 39.20515676, 61.96116013, 35.64665684, 72.52689101, 54.64239536, 34.14169048, 34.32282338, 49.60786171, 50.32976034, 43.83560386, 57.49367366, 81.65759842, 61.59398941, 37.77960776, 30.74484476, 34.72859511, 32.46631033, 37.41725027, 34.04569722, 54.11932007, 34.62264522, 28.36753913, 30.95379445, 84.06354755, 29.32445434, 56.7720931, 33.23951864, 48.61860157, 39.3563214, 32.44713462, 61.25078174, 32.49661836, 40.38508488, 26.73565294, 58.16191656, 61.12461262, 23.701462, 22.14004554, 57.80213129, 57.15936762, 31.51238062, 44.60223083, 30.60135802, 46.96637333, 42.79517081, 56.85541543, 48.79421654, 29.72862307, 41.61735121, 43.37983393, 41.16802781, 61.69637392, 37.29991153, 39.0936012, 57.39158494, 57.55033901, 50.72878897, 34.82491685, 42.66486539, 34.54565803, 55.04161695, 44.56687339, 53.46745359, 57.22210412, 34.8578696, 28.81098073, 51.4033337, 51.9568532, 60.98717632, 62.98817996, 44.1335128, 33.38418814, 59.71059054, 45.82016411, 29.47178401, 30.64995791, 28.52106318, 53.98066153, 64.22209517, 58.29438562, 39.18280924, 38.1302144, 41.90062316, 28.68650929, 69.42769639, 33.79539164, 26.08549507, 55.29167497, 97.25975259, 63.07957724, 56.59002373, 51.40088678, 71.33491023, 46.24955174, 33.90101761, 38.0669817, 52.50993176, 51.84637529, 39.93642798, 61.9268346, 30.25561485, 49.57396856, 44.70170977, 57.00286149, 40.39009586, 63.23642634, 59.23643766, 55.80521902, 68.58421775, 24.04456631, 51.64338572, 61.14103174, 59.29371792, 46.51493959, 43.48297587, 39.99164284, 44.62589755, 58.89385062, 60.96824416, 54.02310453, 43.54420281, 44.24628098, 47.0991445, 58.9015349, 60.54157696, 34.86277089, 33.79969585, 34.57183642, 47.21383117, 55.3529805, 36.49813553, 44.94388291, 29.43134497, 43.41469037, 43.033338, 63.37329389, 38.22029171, 43.2894392, 23.42769168, 55.18117532, 19.39227876, 28.29656641, 28.56075122, 39.57260362, 65.48606054, 31.05339648, 24.87488959, 61.6027878, 59.56983406, 37.53918879, 28.67095839, 36.51499868, 44.43350204, 53.35842664, 48.30182354, 31.03494822, 45.68689659, 46.11113306, 53.89204524, 29.75548276, 35.60906482, 53.35195594, 56.28657675, 44.77245145, 60.20671942, 41.62253735, 40.34528594, 38.48551456, 27.39317425, 51.05414332, 38.41986986, 75.05074423, 34.16773046, 52.18497954, 49.63059496, 28.7365636, 10.59466471, 38.1033901, 52.20531405, 47.031987, 47.45955635, 44.64312012, 50.32229588, 62.40798968, 37.7455721, 31.97746406, 51.17250147, 45.91231295, 66.58450378, 32.68956686, 34.35845347, 70.34703042, 41.47493453, 53.67684859, 35.66735299, 19.76630329, 35.69026569, 76.57475236, 62.11269107, 37.06632602, 57.91686258, 33.95869501, 55.18034702, 66.09725866, 46.80608564, 46.75623531, 55.49605214, 45.7813294, 22.37612777, 62.40414132, 50.51745906, 46.86535062, 54.4172637, 35.44713601, 45.40918234, 43.83215257, 57.14754799, 24.20941074, 44.8145542, 50.79673435, 42.14561269, 32.73720673, 28.51047028, 32.14753623, 28.43006627, 39.50188334, 58.51806717, 37.96898151, 73.14656287, 48.23605238, 75.31273481, 29.57608972, 43.62952257, 30.47534709, 43.24927262, 43.61475563, 53.48883918, 53.85263136, 41.91477406, 56.16405384, 46.21202327, 55.52602904, 49.88481191, 46.31478116, 72.29722834, 40.48187205, 35.31368051, 40.57713079, 34.15725967, 65.85738596, 32.16093944, 32.07117679, 46.44579516, 53.3243447, 69.35531671, 21.70205174, 44.30678622, 40.13349937, 51.7431728, 43.03690121, 26.53566586, 18.74773427, 25.97768442, 66.68668827, 42.97352559, 31.61567696, 61.57362103, 55.07104736, 25.05950764, 53.04884067, 30.47176616, 43.33249885, 44.48360752, 40.59006165, 44.29759954, 69.71063388, 47.70186943, 51.12166943, 40.15048072, 44.96459746, 56.31842906, 57.79593771, 49.19795057, 33.58506451, 42.67650993, 47.96512915, 57.98722437, 42.08107371, 66.85903821, 45.30286487, 38.39187118, 48.02442004, 35.97047743, 56.71378254, 40.51082047, 43.78022461, 60.33208664, 35.78159098, 40.98937317, 36.20547787, 45.2382906, 47.81497885, 20.44519563, 16.68817267, 38.31035896, 38.60590267, 70.75756511, 31.73001452, 45.85476281, 47.11473565, 31.40248172, 42.94971714, 39.34376633, 21.09018956, 31.45915941, 53.82696054, 73.59824534, 31.5694168, 39.02189966, 46.91790827, 60.66603832, 59.81148782, 20.46813743, 54.95108785, 66.71844123, 49.48461319, 25.10459028, 60.26169536, 21.90344297, 63.56310687, 38.70295559, 58.19794152, 25.68981924, 61.4804908, 41.97067608, 22.77156359, 48.51789441, 50.31845297, 42.36456456, 43.35814281, 41.32891651, 35.17106573, 48.45296117, 30.55292595, 55.26758567, 71.25929921, 34.62580089, 43.89804598, 46.06384675, 30.74209253, 47.99143497, 34.02715801, 37.95367551, 45.14366438, 40.73655716, 45.32116105, 48.17651965, 63.54774876, 16.32237452, 54.22730144, 46.02331286, 45.44633826, 53.56976595, 53.96781286, 19.79116777, 42.05820938, 45.48852278, 37.34932167, 45.134461, 49.60637239, 29.99017683, 35.2785614, 71.54855053, 61.55744768, 55.7627296, 37.72455372, 62.51288842, 48.17063649, 65.26648616, 48.4831201, 33.49833137, 32.10986243, 15.42586026, 41.95660905, 30.07072484, 42.33604863, 53.20660203, 48.27036556, 32.92677161, 33.59521848, 44.04333058, 59.30038922, 48.84064622, 63.31815488, 36.01169023, 44.42967033, 23.14247159, 53.6314237, 42.43225997, 28.18151375, 44.0733306, 55.93530003, 30.86515779, 34.10702034, 59.38495522, 57.79906004, 64.86160093, 56.70670687, 43.24880707, 40.00049219, 44.08430336, 17.50391283, 72.81320114, 41.55481964, 63.461066, 50.81938548, 58.7427594, 35.27822458, 33.5188344, 46.13196979, 56.94022883, 66.96258461, 39.19601268, 21.95750575, 51.67252792, 46.51047909, 30.42289547, 46.47496475, 41.6440483, 42.36900563, 68.29398345, 30.14059255, 38.90124252, 40.87014585, 51.33635945, 51.72908337, 50.8177621, 31.65411733, 56.75197699, 47.76885318, 34.18305356, 52.52137441, 48.39806899, 18.34609209, 32.5461584, 60.15104883, 36.29250847, 39.02418361, 34.68801402, 48.02453889, 31.36738248, 42.44522981, 71.79176852, 34.25588794, 38.46866138, 45.01393624, 63.38509325, 32.44823195, 64.59346474, 53.80793998, 41.2889141, 28.86534461, 34.85039051, 37.04622686, 31.83207726, 36.65410743, 27.66293315, 23.11203257, 41.61059067, 19.97321534, 59.879676, 39.84187157, 47.324581, 38.24903991, 41.0234849, 62.30809429, 48.47191326, 23.26696808, 29.91547934, 78.39181209, 41.86240014, 33.53717515, 39.63756903, 74.86377649, 56.30173648, 40.29403413, 59.12602764, 47.23561802, 51.32370456, 45.44426051, 55.54666292, 58.85362888, 38.30516953, 46.11300177, 37.96931091, 41.01315149, 63.09345867, 26.74145771, 31.37447907, 39.26896396, 65.35880308, 60.0670218, 45.48057201, 29.76683425, 51.39638136, 46.12180705, 60.72093818, 45.01613513, 37.04611291, 31.32979098, 57.82548455, 29.89919764, 38.77980495, 55.71511912, 66.9872235, 48.74616069, 32.87503301, 56.10335632, 28.72445387, 41.00675821, 55.22238115, 38.56391412, 21.82487917, 51.87394855, 41.62740713, 72.32943223, 49.85456187, 41.76869194, 55.686196, 46.18471338, 52.57455653, 23.03383172, 51.460223, 45.88045256, 47.91709836, 53.09464847, 65.17159616, 48.0076358, 42.50038253, 50.57143193, 22.05776575, 25.5770314, 57.41889173, 37.07408252, 69.83286794, 53.31690771, 36.14562381, 35.3626014, 70.74448842, 30.01870438, 41.95755074, 64.41141845, 48.12704663, 29.33183678, 47.45391445, 35.76760392, 17.57864013, 42.66918162, 27.84884911, 37.83419437, 56.38203205, 32.93395446, 19.45549279, 48.49557175, 63.74692618, 48.36501421, 38.45370018, 63.77499738, 43.40984685, 61.28735474, 47.00513455, 31.82012086, 40.85624032, 32.79590137, 43.79441893, 47.93350586, 26.44410209, 22.71480768, 41.74097624, 29.7828174, 35.24077319, 37.1436077, 63.62150539, 35.27952907, 30.9258966, 35.22384343, 45.0069715, 47.38652625, 60.86474384, 53.19528479, 37.61239521, 64.78497877, 39.50008676, 43.11733875, 34.67761458, 55.21401193, 57.22836509, 30.10411603, 30.03903287, 53.62027996, 40.63516283, 50.229386, 39.59707517, 55.53993024, 62.31160356, 48.65142538, 59.51279601, 51.46268896, 36.70086545, 45.73324953, 39.82026282, 51.51657943, 39.9507342, 26.65847555, 18.11032673, 41.57393548, 37.24804734, 59.78878572, 42.18870686, 57.73556775, 29.83442692, 24.27687775, 44.54663257, 48.40426261, 34.13830576, 64.47843419, 53.82888778, 45.77073351, 41.95910655, 56.25654343, 42.44938602, 18.92651056, 62.89841562, 42.28210051, 60.01632343, 56.38799965, 53.56842386, 71.059581, 59.21196097, 72.29678294, 40.0820475, 74.53163756, 46.35508897, 48.65592196, 36.69711286, 54.84914739, 57.62299813, 63.0750109, 25.53592874, 19.43203054, 63.18532427, 54.79806194, 28.75123602, 47.68037559, 36.06887062, 48.53619627, 42.05208952, 14.47366507, 26.25183654, 57.37741978, 24.92962789, 47.85306044, 35.55674275, 43.62606531, 51.98445971, 57.10441923, 45.20539557, 43.22417529, 48.20941756, 37.12416781, 39.54238987, 45.31000358, 24.59001204, 32.61256929, 31.61553515, 55.76617515, 57.82479513, 34.12465645, 52.1634834, 50.140277, 34.5334757, 70.76112738, 47.22161503, 35.44101995, 54.50312705, 47.74706989, 21.04494842, 42.42698916, 57.8551517, 49.67127478, 67.6702045, 30.64335682, 31.87819093, 45.79096976, 42.72129981, 56.22043416, 22.12571532, 31.93377902, 31.9561172, 60.28281847, 37.49005649, 30.63141229, 22.82707918, 29.55804713, 55.79929136, 39.64043613, 31.79538118, 61.92391469, 19.30462724, 37.00041938, 61.26446455, 47.10048686, 34.70929308, 33.34157984, 49.28331646, 39.9565451, 48.80158593, 29.25279435, 49.96980394, 68.7766356, 49.61949286, 18.80600378, 52.93721773, 24.29791779, 67.69568275, 54.22725318, 35.67531845, 58.05037476, 70.54029077, 55.59508174, 42.07974012, 61.62117032, 44.47174079, 40.13197612, 61.19863058, 35.16748823, 54.79320966, 46.40640448, 41.99222891, 53.33216862, 19.04146695, 29.60278169, 38.43089591, 61.22497978, 32.04678119, 30.77915985, 38.02625789, 74.25140223, 30.44626923, 42.69951906, 28.99988779, 49.76041564, 30.86941271, 58.65788956, 62.64967161, 23.5689175, 42.21941421, 54.88455829, 38.10115824, 24.12341961, 32.84464782, 81.72102673, 42.42771851, 37.75191241, 32.05927543, 43.55812503, 64.79161154, 61.05179286, 53.24693267, 36.29056269, 61.49030629, 53.68500702, 65.93501988, 50.7243041, 51.72139759, 64.80610623, 58.2860023, 33.16444766, 42.7872046, 55.14190562, 39.14341079, 36.05577261, 30.03351742, 24.16526837, 47.94163599, 52.55045103, 56.60625705, 61.6878126, 23.13212844, 50.50369148, 47.79873905, 47.01238239, 35.9159739, 53.18067189, 48.42928497, 67.48879213, 37.37609292, 19.7749038, 47.87115046, 48.90378974)
p.values <- c(9.92E-11, 8.72E-17, 6.90E-11, 9.71E-13, 3.86E-10, 6.58E-19, 7.68E-08, 3.30E-09, 1.98E-20, 4.47E-16, 7.01E-08, 9.48E-12, 9.14E-12, 1.01E-14, 1.08E-11, 1.04E-18, 4.17E-12, 0.000331062, 4.97E-11, 8.14E-09, 2.90E-13, 4.53E-14, 4.27E-12, 1.14E-11, 2.46E-12, 5.02E-08, 2.99E-16, 3.31E-16, 7.74E-10, 1.39E-12, 2.58E-08, 1.86E-07, 9.29E-10, 3.75E-16, 3.64E-12, 3.94E-11, 1.08E-06, 6.97E-11, 7.38E-15, 1.02E-11, 2.07E-07, 1.38E-08, 3.84E-12, 4.86E-10, 1.81E-16, 1.20E-13, 1.35E-09, 1.34E-06, 6.06E-14, 6.68E-10, 2.21E-14, 1.97E-09, 1.26E-10, 2.44E-12, 1.00E-15, 9.74E-07, 1.52E-13, 1.07E-20, 3.39E-07, 1.21E-12, 5.26E-10, 3.34E-12, 2.35E-06, 1.68E-14, 2.74E-05, 7.79E-09, 1.83E-16, 5.84E-15, 1.07E-09, 1.75E-09, 2.53E-13, 5.74E-17, 1.27E-10, 4.17E-09, 7.26E-14, 3.16E-08, 1.52E-08, 7.35E-10, 2.91E-11, 2.08E-10, 3.25E-11, 1.60E-10, 2.36E-15, 9.47E-13, 6.65E-12, 3.35E-07, 1.44E-09, 5.53E-15, 1.41E-12, 2.04E-09, 9.65E-11, 2.99E-09, 4.49E-10, 4.34E-16, 2.86E-07, 1.54E-12, 5.56E-11, 3.49E-09, 3.42E-16, 1.98E-16, 3.27E-12, 1.23E-10, 8.01E-12, 0.000114784, 9.07E-07, 2.97E-15, 3.37E-11, 2.96E-11, 1.39E-10, 3.75E-11, 2.02E-12, 5.21E-10, 5.91E-11, 1.69E-12, 1.45E-09, 2.74E-10, 1.34E-14, 4.75E-15, 4.16E-13, 6.56E-08, 9.28E-12, 3.97E-10, 4.82E-10, 1.67E-09, 1.87E-12, 7.39E-09, 3.77E-09, 5.58E-09, 9.42E-10, 3.00E-14, 5.08E-11, 6.10E-11, 2.21E-07, 3.34E-12, 1.22E-11, 3.33E-17, 1.02E-11, 7.69E-11, 1.35E-14, 8.15E-12, 4.82E-12, 4.41E-13, 1.54E-12, 1.57E-14, 9.47E-07, 3.56E-05, 9.42E-10, 8.55E-12, 7.65E-15, 3.54E-10, 8.83E-12, 6.27E-14, 1.42E-14, 3.01E-14, 9.27E-11, 1.23E-07, 5.03E-08, 8.53E-12, 2.24E-10, 6.22E-07, 1.89E-09, 4.17E-15, 8.40E-17, 1.13E-20, 2.57E-11, 3.08E-11, 1.11E-11, 3.33E-11, 2.16E-17, 7.05E-12, 1.47E-12, 2.02E-07, 2.18E-08, 1.55E-10, 1.26E-05, 3.34E-13, 5.06E-11, 7.08E-11, 2.62E-13, 4.33E-11, 6.79E-11, 3.44E-10, 8.45E-11, 4.92E-13, 8.85E-09, 1.95E-11, 1.43E-14, 5.78E-13, 3.62E-12, 2.69E-18, 3.38E-09, 1.73E-10, 2.24E-08, 2.77E-10, 4.55E-12, 1.04E-11, 2.24E-15, 1.34E-10, 1.52E-16, 3.14E-13, 3.82E-10, 3.50E-15, 2.37E-09, 1.65E-17, 1.45E-13, 5.12E-09, 4.67E-09, 1.88E-12, 1.30E-12, 3.57E-11, 3.39E-14, 1.62E-19, 4.22E-15, 7.92E-10, 2.94E-08, 3.79E-09, 1.21E-08, 9.54E-10, 5.38E-09, 1.89E-13, 4.00E-09, 1.00E-07, 2.64E-08, 4.79E-20, 6.12E-08, 4.89E-14, 8.15E-09, 3.11E-12, 3.53E-10, 1.22E-08, 5.02E-15, 1.19E-08, 2.09E-10, 2.33E-07, 2.41E-14, 5.36E-15, 1.12E-06, 2.53E-06, 2.90E-14, 4.02E-14, 1.98E-08, 2.41E-11, 3.17E-08, 7.22E-12, 6.08E-11, 4.69E-14, 2.84E-12, 4.97E-08, 1.11E-10, 4.51E-11, 1.40E-10, 4.01E-15, 1.01E-09, 4.04E-10, 3.57E-14, 3.29E-14, 1.06E-12, 3.61E-09, 6.50E-11, 4.16E-09, 1.18E-13, 2.46E-11, 2.63E-13, 3.89E-14, 3.55E-09, 7.98E-08, 7.52E-13, 5.67E-13, 5.74E-15, 2.08E-15, 3.07E-11, 7.56E-09, 1.10E-14, 1.30E-11, 5.67E-08, 3.09E-08, 9.27E-08, 2.02E-13, 1.11E-15, 2.26E-14, 3.86E-10, 6.62E-10, 9.60E-11, 8.51E-08, 7.93E-17, 6.12E-09, 3.27E-07, 1.04E-13, 6.08E-23, 1.99E-15, 5.37E-14, 7.53E-13, 3.01E-17, 1.04E-11, 5.80E-09, 6.84E-10, 4.28E-13, 6.00E-13, 2.62E-10, 3.56E-15, 3.79E-08, 1.91E-12, 2.29E-11, 4.35E-14, 2.08E-10, 1.83E-15, 1.40E-14, 8.00E-14, 1.22E-16, 9.41E-07, 6.66E-13, 5.31E-15, 1.36E-14, 9.09E-12, 4.28E-11, 2.55E-10, 2.39E-11, 1.66E-14, 5.80E-15, 1.98E-13, 4.14E-11, 2.90E-11, 6.75E-12, 1.66E-14, 7.20E-15, 3.54E-09, 6.11E-09, 4.11E-09, 6.36E-12, 1.01E-13, 1.53E-09, 2.03E-11, 5.79E-08, 4.43E-11, 5.38E-11, 1.71E-15, 6.32E-10, 4.72E-11, 1.30E-06, 1.10E-13, 1.06E-05, 1.04E-07, 9.08E-08, 3.16E-10, 5.85E-16, 2.51E-08, 6.12E-07, 4.20E-15, 1.18E-14, 8.96E-10, 8.58E-08, 1.51E-09, 2.63E-11, 2.78E-13, 3.65E-12, 2.53E-08, 1.39E-11, 1.12E-11, 2.12E-13, 4.90E-08, 2.41E-09, 2.79E-13, 6.26E-14, 2.21E-11, 8.54E-15, 1.11E-10, 2.13E-10, 5.52E-10, 1.66E-07, 8.99E-13, 5.70E-10, 4.59E-18, 5.06E-09, 5.05E-13, 1.86E-12, 8.29E-08, 0.001134145, 6.71E-10, 5.00E-13, 6.98E-12, 5.62E-12, 2.36E-11, 1.30E-12, 2.79E-15, 8.06E-10, 1.56E-08, 8.46E-13, 1.24E-11, 3.35E-16, 1.08E-08, 4.58E-09, 4.97E-17, 1.19E-10, 2.36E-13, 2.34E-09, 8.75E-06, 2.31E-09, 2.12E-18, 3.24E-15, 1.14E-09, 2.73E-14, 5.63E-09, 1.10E-13, 4.29E-16, 7.84E-12, 8.04E-12, 9.36E-14, 1.32E-11, 2.24E-06, 2.80E-15, 1.18E-12, 7.60E-12, 1.62E-13, 2.62E-09, 1.60E-11, 3.58E-11, 4.04E-14, 8.64E-07, 2.17E-11, 1.02E-12, 8.47E-11, 1.05E-08, 9.32E-08, 1.43E-08, 9.71E-08, 3.28E-10, 2.01E-14, 7.19E-10, 1.20E-17, 3.78E-12, 4.02E-18, 5.38E-08, 3.97E-11, 3.38E-08, 4.82E-11, 4.00E-11, 2.60E-13, 2.16E-13, 9.53E-11, 6.67E-14, 1.06E-11, 9.22E-14, 1.63E-12, 1.01E-11, 1.85E-17, 1.98E-10, 2.81E-09, 1.89E-10, 5.08E-09, 4.85E-16, 1.42E-08, 1.49E-08, 9.42E-12, 2.83E-13, 8.22E-17, 3.18E-06, 2.81E-11, 2.37E-10, 6.33E-13, 5.37E-11, 2.59E-07, 1.49E-05, 3.45E-07, 3.18E-16, 5.55E-11, 1.88E-08, 4.26E-15, 1.16E-13, 5.56E-07, 3.25E-13, 3.39E-08, 4.62E-11, 2.56E-11, 1.88E-10, 2.82E-11, 6.87E-17, 4.96E-12, 8.68E-13, 2.35E-10, 2.01E-11, 6.16E-14, 2.91E-14, 2.31E-12, 6.82E-09, 6.46E-11, 4.34E-12, 2.64E-14, 8.76E-11, 2.92E-16, 1.69E-11, 5.79E-10, 4.21E-12, 2.00E-09, 5.04E-14, 1.96E-10, 3.67E-11, 8.01E-15, 2.21E-09, 1.53E-10, 1.78E-09, 1.74E-11, 4.68E-12, 6.14E-06, 4.41E-05, 6.03E-10, 5.19E-10, 4.04E-17, 1.77E-08, 1.27E-11, 6.70E-12, 2.10E-08, 5.62E-11, 3.55E-10, 4.38E-06, 2.04E-08, 2.19E-13, 9.57E-18, 1.92E-08, 4.19E-10, 7.40E-12, 6.76E-15, 1.04E-14, 6.06E-06, 1.24E-13, 3.13E-16, 2.00E-12, 5.43E-07, 8.30E-15, 2.87E-06, 1.55E-15, 4.93E-10, 2.37E-14, 4.01E-07, 4.47E-15, 9.27E-11, 1.82E-06, 3.27E-12, 1.31E-12, 7.58E-11, 4.56E-11, 1.29E-10, 3.02E-09, 3.38E-12, 3.25E-08, 1.05E-13, 3.13E-17, 4.00E-09, 3.46E-11, 1.14E-11, 2.95E-08, 4.28E-12, 5.43E-09, 7.24E-10, 1.83E-11, 1.74E-10, 1.67E-11, 3.90E-12, 1.57E-15, 5.34E-05, 1.79E-13, 1.17E-11, 1.57E-11, 2.50E-13, 2.04E-13, 8.64E-06, 8.86E-11, 1.54E-11, 9.88E-10, 1.84E-11, 1.88E-12, 4.34E-08, 2.86E-09, 2.71E-17, 4.30E-15, 8.18E-14, 8.15E-10, 2.65E-15, 3.91E-12, 6.54E-16, 3.33E-12, 7.13E-09, 1.46E-08, 8.58E-05, 9.33E-11, 4.17E-08, 7.69E-11, 3.00E-13, 3.71E-12, 9.57E-09, 6.79E-09, 3.21E-11, 1.35E-14, 2.78E-12, 1.76E-15, 1.96E-09, 2.64E-11, 1.50E-06, 2.42E-13, 7.32E-11, 1.10E-07, 3.16E-11, 7.49E-14, 2.77E-08, 5.22E-09, 1.30E-14, 2.90E-14, 8.03E-16, 5.06E-14, 4.82E-11, 2.54E-10, 3.15E-11, 2.87E-05, 1.43E-17, 1.15E-10, 1.64E-15, 1.01E-12, 1.80E-14, 2.86E-09, 7.06E-09, 1.11E-11, 4.49E-14, 2.77E-16, 3.83E-10, 2.79E-06, 6.56E-13, 9.11E-12, 3.47E-08, 9.28E-12, 1.09E-10, 7.56E-11, 1.41E-16, 4.02E-08, 4.46E-10, 1.63E-10, 7.78E-13, 6.37E-13, 1.01E-12, 1.84E-08, 4.94E-14, 4.80E-12, 5.02E-09, 4.26E-13, 3.48E-12, 1.84E-05, 1.16E-08, 8.79E-15, 1.70E-09, 4.19E-10, 3.87E-09, 4.21E-12, 2.14E-08, 7.27E-11, 2.39E-17, 4.83E-09, 5.56E-10, 1.96E-11, 1.70E-15, 1.22E-08, 9.21E-16, 2.21E-13, 1.31E-10, 7.76E-08, 3.56E-09, 1.15E-09, 1.68E-08, 1.41E-09, 1.44E-07, 1.53E-06, 1.11E-10, 7.85E-06, 1.01E-14, 2.75E-10, 6.02E-12, 6.23E-10, 1.50E-10, 2.94E-15, 3.35E-12, 1.41E-06, 4.51E-08, 8.45E-19, 9.79E-11, 6.99E-09, 3.06E-10, 5.04E-18, 6.22E-14, 2.18E-10, 1.48E-14, 6.29E-12, 7.83E-13, 1.57E-11, 9.13E-14, 1.70E-14, 6.05E-10, 1.12E-11, 7.19E-10, 1.51E-10, 1.97E-15, 2.33E-07, 2.13E-08, 3.69E-10, 6.24E-16, 9.17E-15, 1.54E-11, 4.87E-08, 7.55E-13, 1.11E-11, 6.58E-15, 1.95E-11, 1.15E-09, 2.18E-08, 2.86E-14, 4.55E-08, 4.74E-10, 8.38E-14, 2.73E-16, 2.91E-12, 9.83E-09, 6.88E-14, 8.34E-08, 1.52E-10, 1.08E-13, 5.30E-10, 2.99E-06, 5.92E-13, 1.10E-10, 1.82E-17, 1.66E-12, 1.03E-10, 8.50E-14, 1.08E-11, 4.14E-13, 1.59E-06, 7.31E-13, 1.26E-11, 4.45E-12, 3.18E-13, 6.87E-16, 4.25E-12, 7.07E-11, 1.15E-12, 2.65E-06, 4.25E-07, 3.52E-14, 1.14E-09, 6.45E-17, 2.84E-13, 1.83E-09, 2.74E-09, 4.07E-17, 4.28E-08, 9.33E-11, 1.01E-15, 3.99E-12, 6.10E-08, 5.63E-12, 2.22E-09, 2.76E-05, 6.48E-11, 1.31E-07, 7.70E-10, 5.97E-14, 9.53E-09, 1.03E-05, 3.31E-12, 1.41E-15, 3.54E-12, 5.61E-10, 1.39E-15, 4.44E-11, 4.93E-15, 7.08E-12, 1.69E-08, 1.64E-10, 1.02E-08, 3.65E-11, 4.41E-12, 2.71E-07, 1.88E-06, 1.04E-10, 4.83E-08, 2.91E-09, 1.10E-09, 1.51E-15, 2.86E-09, 2.68E-08, 2.94E-09, 1.96E-11, 5.83E-12, 6.11E-15, 3.02E-13, 8.63E-10, 8.35E-16, 3.28E-10, 5.16E-11, 3.89E-09, 1.08E-13, 3.88E-14, 4.09E-08, 4.23E-08, 2.43E-13, 1.83E-10, 1.37E-12, 3.12E-10, 9.16E-14, 2.93E-15, 3.06E-12, 1.22E-14, 7.30E-13, 1.38E-09, 1.36E-11, 2.78E-10, 7.10E-13, 2.60E-10, 2.43E-07, 2.08E-05, 1.13E-10, 1.04E-09, 1.06E-14, 8.29E-11, 3.00E-14, 4.71E-08, 8.34E-07, 2.48E-11, 3.47E-12, 5.13E-09, 9.76E-16, 2.19E-13, 1.33E-11, 9.32E-11, 6.36E-14, 7.25E-11, 1.36E-05, 2.18E-15, 7.90E-11, 9.41E-15, 5.95E-14, 2.50E-13, 3.47E-17, 1.42E-14, 1.85E-17, 2.44E-10, 5.97E-18, 9.87E-12, 3.05E-12, 1.38E-09, 1.30E-13, 3.17E-14, 1.99E-15, 4.34E-07, 1.04E-05, 1.88E-15, 1.34E-13, 8.23E-08, 5.02E-12, 1.90E-09, 3.24E-12, 8.89E-11, 0.000142133, 3.00E-07, 3.60E-14, 5.95E-07, 4.59E-12, 2.48E-09, 3.98E-11, 5.59E-13, 4.13E-14, 1.77E-11, 4.88E-11, 3.83E-12, 1.11E-09, 3.21E-10, 1.68E-11, 7.09E-07, 1.12E-08, 1.88E-08, 8.16E-14, 2.87E-14, 5.17E-09, 5.11E-13, 1.43E-12, 4.19E-09, 4.03E-17, 6.34E-12, 2.63E-09, 1.55E-13, 4.85E-12, 4.49E-06, 7.34E-11, 2.82E-14, 1.82E-12, 1.93E-16, 3.10E-08, 1.64E-08, 1.32E-11, 6.31E-11, 6.48E-14, 2.55E-06, 1.60E-08, 1.58E-08, 8.22E-15, 9.19E-10, 3.12E-08, 1.77E-06, 5.43E-08, 8.03E-14, 3.05E-10, 1.71E-08, 3.57E-15, 1.11E-05, 1.18E-09, 4.99E-15, 6.74E-12, 3.83E-09, 7.73E-09, 2.22E-12, 2.60E-10, 2.83E-12, 6.35E-08, 1.56E-12, 1.10E-16, 1.87E-12, 1.45E-05, 3.44E-13, 8.25E-07, 1.91E-16, 1.79E-13, 2.33E-09, 2.55E-14, 4.51E-17, 8.90E-14, 8.76E-11, 4.16E-15, 2.58E-11, 2.37E-10, 5.16E-15, 3.03E-09, 1.34E-13, 9.61E-12, 9.16E-11, 2.82E-13, 1.28E-05, 5.30E-08, 5.67E-10, 5.09E-15, 1.51E-08, 2.89E-08, 6.98E-10, 6.88E-18, 3.43E-08, 6.38E-11, 7.24E-08, 1.74E-12, 2.76E-08, 1.88E-14, 2.47E-15, 1.21E-06, 8.16E-11, 1.28E-13, 6.72E-10, 9.04E-07, 9.98E-09, 1.57E-19, 7.33E-11, 8.03E-10, 1.50E-08, 4.12E-11, 8.33E-16, 5.56E-15, 2.94E-13, 1.70E-09, 4.45E-15, 2.35E-13, 4.66E-16, 1.06E-12, 6.40E-13, 8.26E-16, 2.27E-14, 8.47E-09, 6.10E-11, 1.12E-13, 3.94E-10, 1.92E-09, 4.25E-08, 8.84E-07, 4.39E-12, 4.19E-13, 5.32E-14, 4.02E-15, 1.51E-06, 1.19E-12, 4.72E-12, 7.05E-12, 2.06E-09, 3.04E-13, 3.42E-12, 2.12E-16, 9.74E-10, 8.71E-06, 4.55E-12, 2.69E-12)
While p-values range from 6.08038E-23 to 0.001134145, the bootstrapped p-value I get is 0.4995005 and I don't understand why. I am using the following function to find the bootstrapped p-value:
(1+sum(logit.boot$t[,2] > logit.boot$t0[2]))/(1+logit.boot$R)
where logit.boot$t[,2] takes on values from the p.values vector, logit.boot$t0[2] equals 2.664684e-11 and logit.boot$R = 1000.
EDIT
Here is the code I used for bootstrapping:
logit.bootstrap <- function(data, indices){
d <- data[indices, ]
Mf1 <- glm(Y ~ A + B + C, data = d, family = "binomial")
data.setM1 <- na.omit(d[, all.vars(formula(Mf1))])
M1.io <- glm(Y ~ A + B, data = data.setM1, family = "binomial")
my.test <- lrtest(Mf1, M1.io)
return(c(my.test$"Chisq"[2], my.test$"Pr(>Chisq)"[2]))
}
logit.boot <- boot(data=my.data, statistic=logit.bootstrap, R=1000) # 10'000 samples
In the result of the boot function, t0 should the p value on the original data, and t is some p values which are generated from random resampling/permutation on the original data.
And in your case, you shouldn't use
(1+sum(logit.boot$t[,2] > logit.boot$t0[2]))/(1+logit.boot$R)
to get information from your bootstrapped p values, you may use
quantile(logit.boot$t[,2], c(0.025,0.975))
or something like this to obtain a bootstrapped 95% confidence interval on your p value. This is not very meaningful, since the meaning of p value is already a probability (confidence level), why do you bother to obtain a confidence interval for p value? And the validness of the bootstrap method relies on the correctness of your parametric model. So if you want to use non-parametric approach toward this problem, I think you need to find some other approaches instead of this one.

R confint method very slow

Here is the code sample
cq = c(15.5193589369923,15.6082097993496,15.3048276641115,15.887944383963,15.3813224284544,14.9723432922121,14.8742353464212,15.0448020475332,15.1584221729435,15.3692219904727,15.2369219681739,15.0804950645883,15.0836397511495,14.8821059462034,14.6827696388115,14.5701385743889,14.8506248103639,14.8475325690146,14.7377458445001,14.6258765734272,15.3585770134881,15.2994209401567,15.5178103826596,15.2411668198437,15.3413307248142,15.3645926457095,15.2241340874265,15.7516405898009,15.7683360263607,15.5852354340738,14.7451372367313,14.650625258402,14.7596201108925,15.0504977144055,15.0178091754821,15.100874342289,14.5156700740607,15.0530667717479,14.754595621435,15.5879633065185,15.3449828894141,15.3112460363113,15.232600495493,15.4378070492087,15.1621663266126,16.0120124580213,16.2104534293435,16.2765899877946,17.1446379330444,17.1717364140053,17.0155350105157,15.5218922723681,15.4543443324508,15.5282690363252,15.0202919978723,15.0410524376083,15.1169661551775,15.335220483258,15.3191814464955,15.0679651604846,14.7270263787123,14.70717761566,14.7907442084919,15.8468089268423,15.6714073529734,15.5478017041242,14.6949593095613,14.7537769900696,14.830942214569,15.0820225358985,15.3454125813989,15.304399073517,15.4159319040107,16.1250033895004,15.5359407225865,15.3251900155103,15.1571914994646,15.412721442436,15.913112918988,15.9852823695227,16.0912887332562,15.4897399161851,15.0710262650299,15.3517226832146,17.0001128578501,17.1040579605654,16.9578316599788,15.8842918497549,15.7016383123704,15.8513519332371,16.9420990886101,17.0793832045434,16.9288868492911,14.9127628979216,14.7689529893246,15.0534122173222,15.3185448628303,15.5507864243439,15.3737185073511,15.4350799532271,15.2414612478027,15.361320770232,15.7401140808761,15.8582795450189,15.7634036480016,15.5797995263497,15.9126261329496,15.9256641722586,15.1308493265056,15.2450158090279,15.0699176510971,15.0368959001792,14.8828877909216,14.8852035927172,15.8253506435753,15.8938440960183,15.888311876759,15.4872886586516,15.5492199156675,15.7313291529313,16.5365758222542,16.8386981731158,16.7239280992675,15.9356391540897,15.7383049532238,15.9409000309973,15.2005952554035,15.0390142751348,15.154888655127,14.6373767323354,14.3087397097081,14.3970067065903,14.6453627024929,14.8109205614192,14.6266778290643,15.5170574352528,15.359943766027,15.5869322081508,15.5246550838727,15.4670382654415,15.4211907882731,16.9534561402918,17.4848334482537,17.3182067272327,15.7804318020053,15.86794322314,15.6532944587946,16.543432367992,16.6848617423114,16.8344939905775,15.5212254647114,15.8348559815603,15.6592827767612,15.3027400892518,15.5498124465958,15.8362202772445,14.8415823671167,15.7307379811374,14.8529575353737,16.6466266958983,16.1687733596343,16.0342973266029,14.5976161739123,14.776507726931,14.6780484406283,15.3927619991024,15.3106866267163,15.2920260038624,15.9666798099925,16.2595244266754,16.1035265916681,16.018233002759,15.8460056716414,16.0722176294152,16.2763177549617,16.364250121284,16.2995041975045,16.3975912697976,16.182759197402,16.1164022801451,16.5026752161837,16.2401540005223,16.3715573563274,18.4119769797938,18.1208386122385,18.0068316479116,17.1455993749728,17.0558275544137,16.9150038143768)
sample = c("CD4 LM","CD4 LM","CD4 JC","CD4 JC","CD4 JC","CD4 BM","CD4 BM","CD4 BM","CD4 MC","CD4 MC","CD4 MC","CD4 TM","CD4 TM","CD4 TM","CD4 MM","CD4 MM","CD4 MM","CD4 SRits","CD4 SRits","CD4 SRits","CD4 GV","CD4 GV","CD4 GV","CD4 WW","CD4 WW","CD4 WW","CD4 CH","CD4 CH","CD4 FJ","CD4 FJ","CD4 KS","CD4 KS","CD4 KS","CD4 NG","CD4 NG","CD4 NG","CD4 CG","CD4 CG","CD4 CG","CD4 CSR","CD4 CSR","CD4 CSR","CD4 JM","CD4 JM","CD4 JM","CD4 DF","CD4 DF","CD4 DF","CD4 AM","CD4 AM","CD4 AM","CD4 BP","CD4 BP","CD4 BP","CD4 ER","CD4 ER","CD4 ER","CD4 SRusse","CD4 SRusse","CD4 SRusse","CD4 DS","CD4 DS","CD4 DS","CD4 KJ","CD4 KJ","CD4 KJ","CD4 GD","CD4 GD","CD4 GD","CD4 KG","CD4 KG","CD4 KG","CD4 KR","CD4 KR","CD4 KR","CD4 FN","CD4 FN","CD4 FN","CD4 RM","CD4 RM","CD4 RM","CD4 LA","CD4 LA","CD4 LA","CD4 EC","CD4 EC","CD4 EC","CD4 KW","CD4 KW","CD4 KW","CD4 HB","CD4 HB","CD4 HB","CD8 LM","CD8 LM","CD8 LM","CD8 JC","CD8 JC","CD8 JC","CD8 BM","CD8 BM","CD8 BM","CD8 MC","CD8 MC","CD8 MC","CD8 TM","CD8 TM","CD8 TM","CD8 MM","CD8 MM","CD8 MM","CD8 SRits","CD8 SRits","CD8 SRits","CD8 GV","CD8 GV","CD8 GV","CD8 WW","CD8 WW","CD8 WW","CD8 CH","CD8 CH","CD8 CH","CD8 FJ","CD8 FJ","CD8 FJ","CD8 KS","CD8 KS","CD8 KS","CD8 NG","CD8 NG","CD8 NG","CD8 CG","CD8 CG","CD8 CG","CD8 CSR","CD8 CSR","CD8 CSR","CD8 JM","CD8 JM","CD8 JM","CD8 DF","CD8 DF","CD8 DF","CD8 AM","CD8 AM","CD8 AM","CD8 BP","CD8 BP","CD8 BP","CD8 ER","CD8 ER","CD8 ER","CD8 SRusse","CD8 SRusse","CD8 SRusse","CD8 DS","CD8 DS","CD8 DS","CD8 KJ","CD8 KJ","CD8 KJ","CD8 GD","CD8 GD","CD8 GD","CD8 KG","CD8 KG","CD8 KG","CD8 KR","CD8 KR","CD8 KR","CD8 FN","CD8 FN","CD8 FN","CD8 RM","CD8 RM","CD8 RM","CD8 LA","CD8 LA","CD8 LA","CD8 EC","CD8 EC","CD8 EC","CD8 KW","CD8 KW","CD8 KW","CD8 HB","CD8 HB","CD8 HB")
df = data.frame(cq, sample)
df.res <- lm(cq~sample, data = df)
require(lsmeans)
t<- pairs(lsmeans(df.res, "sample"))
system.time(tc <- confint(t, level=0.95))
The time taken by the confint function is
user system elapsed
10.58 0.00 10.60
I have tried using confint.default but I get an error
tc <- confint.default(t, level=0.95)
Error: $ operator not defined for this S4 class
It's a bit buried in the documentation, but what's slowing you down is the multiple-comparisons correction computations. There's wide variation in the elapsed time for the available methods. See the Confidence-limit and P-value adjustments section of ?summary.ref.grid for details, and decide which method meets your criteria of being both fast enough and reliable enough for your use case ...
adj <- c("tukey","scheffe","sidak","bonferroni","dunnettx","mvt")
sapply(adj,function(a) system.time(confint(t,adjust=a))["elapsed"])
## tukey.elapsed scheffe.elapsed sidak.elapsed bonferroni.elapsed
9.256 0.195 0.168 0.173
## dunnettx.elapsed mvt.elapsed
14.370 1.821
Here is a fast way:
confint(t,method="Wald")

Suggestion for curve fitting

I have this set of data:
X: Y:
0. 0.
0.001417162 0.0118
0.002352761 0.0128
0.003123252 0.0135
0.003866221 0.0138
0.004045083 0.0147
0.005544762 0.0151
0.006260197 0.0156
0.007195755 0.0157
0.007883656 0.0158
0.008805432 0.0159
0.009314465 0.0165
0.010566391 0.0168
0.011047891 0.0186
0.011666955 0.0177
0.012341036 0.0225
0.013193938 0.0399
0.013854235 0.087
0.014500764 0.1479
0.015381122 0.198
0.015601208 0.2586
0.01638525 0.3111
0.016976706 0.3693
0.017691939 0.42
0.018338382 0.4737
0.018861027 0.5223
0.01963122 0.5691
0.021625353 0.6183
0.020923988 0.6684
0.021377815 0.711
0.021927895 0.7551
0.022574222 0.7938
0.023633053 0.8382
0.023646804 0.8742
0.024279325 0.912
0.025131822 0.9495
0.0256543 0.9891
0.026094271 1.0215
0.026685464 1.0596
0.027345378 1.098
0.028101497 1.1328
0.028513912 1.1739
0.029077528 1.1997
0.029723601 1.2339
0.030355902 1.2741
0.031056901 1.3041
0.031428005 1.3383
0.032087723 1.3665
0.032692438 1.3983
0.033242157 1.4262
0.033846824 1.4589
0.034410239 1.4877
0.035248448 1.5222
0.035729364 1.5534
0.036430096 1.5861
0.037034618 1.6179
0.037694064 1.6536
0.038408425 1.6842
0.039067798 1.7121
0.039521096 1.7427
0.040207877 1.7763
0.04071607 1.8075
0.041279177 1.8381
0.04129291 1.8711
0.042707418 1.9065
0.043366544 1.9332
0.043860863 1.9659
0.044368889 1.9959
0.045055371 2.0202
0.045700624 2.0487
0.04626347 2.0796
0.047059639 2.1105
0.047540055 2.1339
0.048308673 2.1618
0.048857648 2.1849
0.049557546 2.2203
0.050229948 2.2425
0.052082233 2.2716
0.051355084 2.2983
0.051945039 2.3193
0.052466363 2.3475
0.053371748 2.3718
0.053851839 2.3937
0.054647359 2.4189
0.055072521 2.4372
0.055675941 2.4633
0.056306742 2.4882
0.057060898 2.5131
0.057691594 2.5332
0.058582712 2.5527
0.059007671 2.5755
0.059597094 2.5941
0.060172767 2.6115
0.065187502 2.6403
0.06131028 2.6592
0.061968042 2.6808
0.062598344 2.6991
0.063173791 2.7246
0.063790292 2.7441
0.064393043 2.7633
0.065091624 2.7795
0.065502522 2.8011
0.066433804 2.8212
0.066598135 2.8368
0.067351271 2.8545
0.067981104 2.8665
0.068610879 2.8845
0.069309041 2.9046
0.069870256 2.9214
0.070253498 2.9355
0.070828319 2.9499
0.07159467 2.9691
0.072046228 2.9856
0.072620893 2.9982
0.07326391 3.0108
0.073893183 3.0255
0.074467682 3.0387
0.075165218 3.0531
0.075862676 3.0654
0.076395973 3.0735
0.077230012 3.0879
0.077571798 3.0996
0.077968246 3.1116
0.078720058 3.1251
0.079485442 3.1332
0.080168736 3.1473
0.080797297 3.1524
0.081671703 3.1647
0.082518656 3.1761
0.082737205 3.1794
0.083242565 3.1911
0.083843476 3.207
0.084594523 3.2157
0.083993693 3.2217
0.086028058 3.2313
0.086806105 3.2412
0.087515804 3.2475
0.087979788 3.2562
0.089221428 3.2658
0.089289641 3.2727
0.090053572 3.2823
0.090599168 3.285
0.091485638 3.2988
0.092508299 3.3006
0.092794607 3.309
0.093585278 3.3177
0.094443969 3.3255
0.095029975 3.336
0.095752165 3.3381
0.096378886 3.3468
0.097182604 3.3498
0.097781901 3.3573
0.098585385 3.3612
0.099238967 3.3702
0.102192566 3.372
0.100464189 3.3816
0.101226388 3.3879
0.101961246 3.396
0.102519116 3.4038
0.103335387 3.4113
0.103920292 3.4134
0.104777107 3.4206
0.105416212 3.423
0.105932869 3.4308
0.106952407 3.4353
0.107550426 3.4431
0.108284246 3.4479
0.108759804 3.4539
0.109439081 3.4587
0.110118251 3.4662
0.11096027 3.4701
0.111802122 3.4749
0.112182257 3.4857
0.113132445 3.4902
0.113878868 3.4929
0.114530181 3.5028
0.11465229 3.5076
0.116063069 3.513
0.116619106 3.5181
0.117378448 3.5247
0.118246089 3.5295
0.118869589 3.5286
0.119479439 3.5364
0.120292424 3.5451
0.120807227 3.5511
0.121728283 3.5565
0.122283519 3.5625
0.123068837 3.5622
0.123745705 3.5691
0.124544254 3.5775
0.125247919 3.5796
0.125924395 3.5868
0.126614273 3.5892
0.128683133 3.5958
0.127993643 3.5991
0.128602023 3.6057
0.129507645 3.6093
0.130115772 3.6132
0.130669753 3.6156
0.131682911 3.6222
0.132263658 3.6234
0.132911821 3.6288
0.133870342 3.6291
0.136717348 3.6336
0.13504451 3.6396
0.135692157 3.6372
0.13621828 3.6432
0.137068001 3.6465
0.141030546 3.6522
0.138470251 3.6501
0.139009423 3.6567
0.140181824 3.6615
0.140532116 3.6633
0.141124835 3.6588
0.141717448 3.6675
0.14257924 3.6711
0.143319661 3.6741
0.143844585 3.6729
0.144813453 3.6753
0.145243967 3.678
0.1472209 3.6849
0.14672342 3.6879
0.147301565 3.6888
0.147866163 3.6933
0.148403782 3.6927
0.149277216 3.6972
0.149962355 3.7011
0.151922897 3.7077
0.151426165 3.7023
0.152070559 3.7089
0.153251595 3.7107
0.153587034 3.7134
0.15429804 3.7191
0.154861361 3.7191
0.155706144 3.7221
0.157086785 3.7206
0.157086785 3.7272
0.156925966 3.7269
0.158480178 3.7335
0.15912306 3.7272
0.159618519 3.7356
0.160381629 3.7359
0.161171304 3.7386
0.161853731 3.7377
0.162415608 3.7398
0.163151233 3.7437
0.163993625 3.7443
0.165062969 3.7533
0.165330242 3.7509
0.166065112 3.7512
0.166866568 3.7569
0.167494215 3.7635
0.168108371 3.7569
0.168829162 3.7638
0.169536423 3.7626
0.173429745 3.7581
0.171070418 3.7617
0.171803762 3.7653
0.172790131 3.7635
0.172936723 3.7644
0.174029244 3.7695
0.174761783 3.7701
0.175334355 3.7668
0.176173017 3.7704
0.176705362 3.7722
0.177490375 3.7701
0.178261854 3.774
0.178979922 3.7797
0.178793775 3.78
0.180774223 3.7887
0.182394664 3.8301
0.18451827 3.8169
0.186282158 3.8067
0.186772642 3.7731
0.188058046 3.7782
0.188587916 3.7734
0.189395747 3.7749
0.189885613 3.7707
0.190560674 3.7734
0.191447234 3.7752
0.192280569 3.7713
0.193007849 3.7704
0.193946376 3.7701
0.194329613 3.7734
0.195188367 3.7647
0.195716677 3.7644
0.196416507 3.7683
0.197142527 3.7695
0.197709986 3.7596
0.198923623 3.7662
0.199714786 3.7617
0.200189355 3.7626
0.2011382 3.7683
0.201915434 3.7665
0.202310538 3.7599
0.203258508 3.7656
0.204153451 3.7569
0.204903352 3.753
0.205311089 3.7512
0.206192075 3.753
0.207033292 3.7461
0.207966146 3.7539
0.208478393 3.7473
0.209318747 3.7425
0.210119413 3.7455
0.21077548 3.7443
0.21140512 3.7425
0.21234924 3.7443
0.213122589 3.7461
0.213751552 3.7443
0.214498207 3.7422
0.215192234 3.7425
0.216030006 3.7395
0.216762788 3.7437
0.217508397 3.7377
0.218096851 3.7446
0.223098604 3.7383
0.219547672 3.7386
0.220187807 3.7395
0.220906094 3.7386
0.221872127 3.7368
0.222381072 3.7404
0.223111647 3.7374
0.223789808 3.7365
0.224207027 3.7278
0.225288796 3.7359
0.225862032 3.7326
0.226487197 3.7368
0.226396039 3.7302
0.227775995 3.7308
0.228426593 3.7287
0.229115997 3.7278
0.229063975 3.7269
0.230312139 3.726
0.23101389 3.7104
plot(x,y)
Can you please give me suggestions of models (I've tried polynomials and I either get a bad fit or a overfit). Thanks!
Just monkeying around in Python/Numpy for a few minutes, it looks like you want a formula like
Yfit(x) = Ymax * (1 - exp(-(x-x0)/a) )
x0 is where the data starts to take off from zero. Looks like x0 = 0.012 give or take a little. Ymax is the maximum value. The parameter a sets how fast the curve rises, and it look like you want a = 0.007 or so.
Polynomials are bad for any data that levels off and holds steady before or after the interesting parts. Polynomials like to wiggle, like a snake trying to go through lined-up croquet wickets. Even fitting loosely with least-squares or whatever, polynomials don't like flatness. But the shape sure looks like a constant minus a decaying exponential - very common in electronics and physics.
The initial zero values, I take to be meaningless and not needing fitting. The Yfit values you get could be clipped to zero when negative, for plotting and comparison.
If exp(-(x-x0)/a) doesn't work well enough, you could try other functions that quickly fade to zero, such as 1/(1+x^p) for some power p>=2, or use a Gaussian exp(-(x-x0)^2 / a^2)
I actually see a slight curve - the Y values go up to max, and then slightly back down. Maybe add a quadratic term to your model, like:
Y_extra_term(x) = ((x-xmax)/b)^2
where xmax is the x value where y is maximum.
(BTW, I'm no expert on R, so use the correct syntax not whatever I write.)

Resources