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, 0.366613128009007, 0.43335584150401,
0.516691111726999, 0.383459543097199, 0.783127987777988, 0.283220203865,
0.416811581253, 0.400114583392991, 0.416630167609981, 0.500080141967999,
0.466509864102989, 0.183366330894984, 0.69996205708, 0.833361757822985,
0.516727937792041, 0.38330197583997, 0.416698386385008, 0.46657234767099,
0.433382404566999, 0.416618697195986, 0.399949469809997, 0.733300000000042,
0.416799999999967, 0.36669999999998, 0.433299999999974, 0.616399999999999,
0.398599999999988, 0.249961740134204, 0.466699999999946, 0.466800000000035,
0.7166, 0.483280000000001, 0.383409999999998, 0.399969999999996,
0.699960000000004, 0.61666, 0.582999999999998, 0.4495, 0.367099999999994,
0.416699999999992, 0.399999999999977, 0.583399999999983, 0.516499999999979,
0.449899999999985, 0.383399999999995, 0.282800000000009, 0.566699999999997,
0.466700000000003, 0.483299999999986, 0.533299999999997, 0.433199999999999,
0.61650000000003, 0.550000000000011, 0.683300000000031, 0.38330000000002,
0.449999999999989, 0.433400000000006, 0.449999999999989, 0.399799999999999,
0.583399999999997, 0.383279999999999, 0.450000000000003, 0.383200000000002,
0.383399999999995, 0.549999999999983, 0.383299999999991, 0.716399999999993,
0.566499999999991, 0.400000000000006, 0.616600000000005, 0.733399999999989,
0.449899999999985, 0.566699999999997, 0.5, 0.600099999999998,
0.5, 0.483439999999998, 0.483400000000017, 0.54989999999998,
0.666699999999992, 0.716499999999996, 0.583300000000001, 0.433199999999999,
0.633299999999963, 0.516599999999983, 0.499859999999998, 0.483400000000017,
0.500099999999975, 0.416699999999992, 0.333399999999983, 0.483300000000042,
0.550000000000011, 0.383319999999998, 0.599970000000001, 0.5,
0.399969999999996, 0.483379999999997, 0.399969999999996, 0.683300000000003,
0.599999999999994, 0.583400000000012, 0.566699999999997, 0.516099999999994,
0.38330000000002, 0.383399999999995, 0.466100000000012, 0.800000000000011,
0.616700000000009, 0.16670000000002, 0.599999999999994, 0.533299999999997,
0.550100000000043, 0.38330000000002, 0.400000000000034, 0.466700000000003,
0.666799999999967, 0.583399999999983, 0.716600000000028, 0.599899999999991,
0.466600000000028, 0.599999999999966, 0.5, 0.449900000000014,
0.550099999999986, 0.5, 0.583329999999997, 0.333350000000003,
0.39996, 0.433340000000001, 0.450100000000006, 0.466790000000003,
0.566599999999994, 0.666700000000006, 0.566099999999992, 0.383399999999995,
0.433290000000003, 0.41640000000001, 0.350100000000026, 0.566699999999997,
0.316900000000032, 0.400109999999998, 0.399900000000002, 0.333300000000008,
0.45010000000002, 0.566800000000001, 0.433499999999981, 0.483299999999986,
0.366199999999992, 0.433399999999949, 0.699999999999989, 0.45010000000002,
0.333499999999958, 0.38344, 0.266697979166521, 0.566645063859099,
0.483681528935506, 0.516593159768306, 0.499657544687992, 0.566733809440009,
0.533366376472998, 0.549978704078995, 0.700037822520983, 0.616626333711991,
0.416589265829003, 0.466635434660986, 0.549884525094996, 0.400077758033007,
1.70000789965499, 0.600099999999998, 0.599900000000019, 0.4666,
0.583300000000008, 0.483400000000017, 0.483400000000017, 0.516699999999958,
0.433400000000006, 0.566800000000001, 0.483400000000017, 0.533299999999997,
0.566700000000026, 0.500099999999975, 0.533400000000029, 0.566700000000026,
0.466700000000003, 0.666700000000048, 0.61669999999998, 0.44997,
0.5167, 0.732889999999998, 0.516690000000001, 0.516800000000003,
0.700000000000003, 0.433400000000006, 0.4161, 0.666599999999988,
0.583300000000008, 0.466699999999999, 0.433300000000003, 0.433500000000009,
0.466499999999996, 0.483399999999989, 0.516600000000011, 0.516899999999993,
0.61669999999998, 0.599999999999994, 0.533500000000004, 0.399999999999999,
0.550000000000011, 0.550099999999986, 0.566700000000026, 0.5,
0.566800000000001, 0.816599999999994, 0.516599999999983, 0.399499999999989,
0.532940000000004, 0.583300000000008, 0.5, 0.466599999999971,
0.5, 0.650000000000034, 0.383309999999994, 0.533330000000007,
0.483360000000005, 0.616789999999995, 0.5, 0.400099999999995,
0.5501, 0.599599999999995, 0.433199999999999, 0.483400000000017,
0.800000000000011, 0.616669999999999, 0.316700000000026, 0.549800000000005,
0.450000000000017, 0.383400000000023, 0.4666, 0.4666, 0.35004,
0.4666, 0.483400000000017, 0.499900000000025, 0.416679999999999,
0.533400000000029, 0.416800000000023, 0.566599999999994, 0.450000000000045,
0.516599999999983, 0.550000000000011, 0.816700000000026, 0.400010000000002,
0.316699999999969, 0.516399999999976, 0.433259999999997, 0.733278,
0.55003, 0.483340000000013, 0.783349999999999, 0.533460000000005,
0.566699999999997, 0.716700000000003, 0.716700000000003, 0.516599999999983,
0.433399999999978, 0.533299999999997, 0.666699999999992, 0.433299999999974,
0.516699999999986, 0.466639999999998, 0.650000000000006, 0.566300000000012,
0.416699999999992, 0.416600000000017, 0.349899999999991, 0.449999999999989,
0.483290000000004, 0.733200000000011, 0.466700000000003, 0.583300000000008,
0.38330000000002, 0.483299999999986, 0.816600000000001, 0.433400000000006,
0.550000000000011, 0.616100000000017, 0.483299999999986, 0.583330000000004,
0.449950000000001, 0.566629999999989, 0.483359999999999, 0.816699999999997,
0.783299999999997, 0.5334, 0.299900000000008, 0.400100000000009,
0.600099999999998, 0.500100000000003, 0.449900000000014, 0.63330000000002,
0.533199999999994, 0.683399999999978, 0.516799999999989, 0.566599999999994,
0.650100000000009, 0.883369999999999, 0.399999999999977, 0.433300000000031,
0.54989999999998, 0.45010000000002, 0.466600000000028, 0.383399999999995,
0.63330000000002, 0.549909999999997, 0.233300000000042, 0.633299999999963,
0.466700000000003, 0.632779999999997, 0.48338460869733, 0.583214904951404,
0.466673227015406, 0.416451543573601, 0.36661533093141, 0.583078163940002,
0.616621669918999, 0.533258553406995, 0.500063088017015, 0.433389619515992,
0.549822629098003, 0.449958223055006, 0.516826992736014, 0.532235259741014,
0.48334687662998, 0.483007589880998, 0.599507007900996, 0.549939447577998,
0.400010323494001, 0.83332719558399, 0.466675340011989, 0.516813107334997,
0.833300000000008, 0.533299999999997, 0.550099999999986, 0.516699999999958,
0.466599999999971, 0.533299999999997, 0.498899999999992, 0.483300000000042,
0.600000000000023, 0.466600000000028, 0.483399999999961, 0.466700000000003,
0.683299999999974, 0.333349, 0.416550000000001, 0.516599999999997,
0.566729999999993, 0.416650000000004, 0.583269999999999, 0.54965,
0.399899999999988, 0.500099999999989, 0.682200000000009, 0.29989999999998,
0.46669, 0.633499999999998, 0.316800000000001, 0.449999999999989,
0.350070000000002, 0.683399999999978, 0.4666, 0.5, 0.616800000000012,
0.449999999999989, 0.483399999999961, 0.683399999999949, 0.649999999999977,
0.433199999999999, 0.583300000000008, 0.599899999999991, 0.516599999999983,
0.449999999999989, 0.833399999999983, 0.599899999999991, 0.61562,
0.600099999999998, 0.433499999999981, 0.433400000000006, 0.466679999999997,
0.516559999999998, 0.516640000000002, 0.566780000000008, 0.533420000000007,
0.51671, 0.4833, 0.465599999999995, 0.416700000000006, 0.449949999999998,
0.650099999999981, 0.383299999999991, 0.416600000000017, 0.399999999999999,
0.566800000000001, 0.800000000000011, 0.350099999999998, 0.5822,
0.550000000000011, 0.433400000000006, 0.483200000000011, 0.366700000000037,
0.316699999999969, 0.45010000000002, 0.45010000000002, 0.649999999999977,
0.466769999999997, 0.516599999999983, 0.600099999999998, 0.499899999999968,
0.549800000000005, 0.583300000000008, 0.400009999999995, 0.49995,
0.48319, 0.516689999999997, 0.432280000000006, 0.400030000000001,
0.500020000000006, 0.38336000000001, 0.53308, 0.533500000000004,
0.666600000000017, 0.516700000000014, 0.366700000000009, 0.650020000000001,
0.38330000000002, 0.616700000000009, 0.483399999999989, 0.45010000000002,
0.66670000000002, 0.449900000000014, 0.483299999999986, 0.783299999999997,
0.399999999999977, 0.366669999999999, 0.400100000000009, 0.800000000000011,
0.38349999999997, 0.433369999999996, 0.399900000000002, 0.383299999999998,
0.350099999999998, 0.450099999999964, 0.366499999999974, 0.550099999999986,
0.416600000000017, 0.450049999999997, 0.516333, 0.449950000000001,
0.550070000000005, 0.400019999999998, 0.383349999999993, 0.516569999999987,
0.599890000000002, 0.533349999999999, 0.549999999999997, 0.482399999999998,
0.416799999999995, 0.649100000000004, 0.449999999999989, 0.5334,
0.450000000000017, 0.383399999999995, 0.515500000000003, 0.733500000000021,
0.41670000000002, 0.75, 0.649999999999977, 0.633399999999995,
0.51662, 0.36669999999998, 0.483299999999986, 0.466700000000003,
0.483100000000007, 0.45010000000002, 0.416600000000017, 0.399999999999977,
0.533299999999997, 0.533299999999997, 0.382300000000001, 0.533299999999997,
0.516600000000039, 0.448603033908896, 0.349815655656002, 0.383307041550012,
0.399893806548988, 0.383485741159006), pNum = c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L
)), row.names = c(NA, 500L), class = "data.frame")
I've read online many ways to fit a quadratic regression. Some examples include:
m1 <- glmer(formula = FirstSteeringTime ~ stats::poly(startingpos, 2) + (1 |pNum),
family = Gamma(link = "identity"),
data = dat)
m2 <- glmer(formula = FirstSteeringTime ~ startingpos^2 + (1 | pNum),
family = Gamma(link = "identity"),
data = dat)
However I am yet to find a consensus. Are these 2 models equivalent? The output I get is very similar so I imagine they are doing very similar things?
Also side note: when I run a summary on the first model (m1) I get the following output:
AIC BIC logLik deviance df.resid
-777.2 -756.1 393.6 -787.2 495
Scaled residuals:
Min 1Q Median 3Q Max
-2.7497 -0.6122 -0.1233 0.5585 10.3273
Random effects:
Groups Name Variance Std.Dev.
pNum (Intercept) 0.0003794 0.01948
Residual 0.0547070 0.23390
Number of obs: 500, groups: pNum, 4
Fixed effects:
Estimate Std. Error t value Pr(>|z|)
(Intercept) 0.49196 0.03562 13.810 < 2e-16 ***
stats::poly(startingpos, 2)1 -0.79182 0.11437 -6.923 4.41e-12 ***
stats::poly(startingpos, 2)2 0.35565 0.10966 3.243 0.00118 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) s::(,2)1
stts::(,2)1 -0.018
stts::(,2)2 0.058 -0.103
What is the difference between stats::poly(startingpos, 2)1 and stats::poly(startingpos, 2)2?
Any help is most appreciated, thank you!