I've heard that the t-test and F-test we use to get the significance of our regression results are derived from the likelihood ratio test, but I'm having trouble replicating the p-value of the t/F tests with a likelihood ratio test on the regression likelihoods
Using the dataset at bottom, running these three regressions in R:
withCov<-lm(Y~X)
logLik(withCov) # 'log Lik.' -61.98043 (df=3)
withInt<-lm(Y~1)
logLik(withInt) # 'log Lik.' -63.18456 (df=2)
withNone<-lm(Y~0)
logLik(withNone) # 'log Lik.' -65.32909 (df=1)
When I do a likelihood ratio test for the significance of beta_1 for example I get
1-pchisq(2*(logLik(withCov)-logLik(withInt)),df = 1)
# 0.1206958
# compare to
summary(withCov)
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-1.98508 -0.44415 -0.02294 0.59907 1.66593
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.2568 0.1206 -2.129 0.0384 *
X -0.2045 0.1329 -1.539 0.1304
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.8531 on 48 degrees of freedom
Multiple R-squared: 0.04702, Adjusted R-squared: 0.02717
F-statistic: 2.369 on 1 and 48 DF, p-value: 0.1304
While the values are close, 0.1304 is clearly not the same as 0.1206958.
And for all 6 combinations of likelihood ratio tests I cannot recover any of the p-values from lm
.
What am I doing wrong? thank you!
The below R code sets up the X and Y variables:
X<-c(0.147462983739098,-0.552822250273655,0.0791413008277721,1.64705442993914,0.68248797132517,-0.315633973636888,1.40047872456033,0.776033233883272,-0.343689753439294,-0.526351059575156,0.275611183793461,1.7751174954305,-0.932913434395753,0.163895795533468,-1.00807323166609,-0.434797856886559,0.112072003876197,-0.319445372479459,1.6989373340732,0.639738727242407,0.02980494131095,0.564230726111237,1.61191604859755,-0.474733281647485,-1.46213462226689,-1.33823497263023,0.0771907623203949,-0.698998017227839,-0.775816444324552,1.46468840793603,-0.0940659257837727,-1.85718512842644,0.109762500597346,0.293088069440979,-1.33774986808507,0.804321505460817,1.24638780351287,-1.66909878637454,-0.107871283787089,-0.286526054190293,-1.30268476505327,0.241186917275982,0.0941940655245403,0.426156461908492,-0.951908401332523,-0.782389908678191,0.436387212517629,0.491981905432585,0.863964246361868,-0.715853080383197)
Y<-c(0.123592053622774,-0.156626343170975,-1.00704515111936,-0.333485064105835,0.539121555715671,0.0827543989201612,-1.38138102448818,-0.510996824863877,1.40679987755037,-0.289587787513398,-1.00983646108717,0.20397559183913,-1.53795623798144,-0.374138120013244,0.753381985793875,-0.195106670583694,-0.395410227522805,0.314058948313302,-0.567075906102368,-0.823999734395967,0.334195737940288,-0.382748868492066,-1.1924589353617,-2.14478307786596,0.198528331051895,0.616636192164357,-1.66623239116232,0.906880778089087,0.663909698659448,-0.96026161021686,-0.0289513529973109,0.103477089026045,-0.517840007699842,-1.42770065687853,-1.18735568345121,0.441872906307648,-0.814014579874374,-0.96658546843308,0.474244931448731,-0.975319336891573,-0.0672523439350411,-0.743286641930158,0.788159757412595,1.23723123779866,-0.508581741865352,0.220065470600985,0.822051420773978,-0.383737198032438,-2.04890944754108,1.5555393999865)