#———————————————– # F test by using linearHypothesis() #———————————————– # H0 : b2/b1 = Nelson-Siegel slope factor # b3/b1 = Nelson-Siegel curvature factor #———————————————– NS_slope – (1–exp(–lambda*tau))/(lambda*tau) NS_curvature – NS_slope – exp(–lambda*tau) H0 – c(paste0(“slope_can=”,NS_slope,“*level_can”), paste0(“curvature_can=”,NS_curvature,“*level_can”)) # F test for coefficients restrictions linearHypothesis(reg.U, H0) #———————————————– # F test by mannual calculation #———————————————– # H0 : b2/b1 = Nelson-Siegel slope factor # b3/b1 = Nelson-Siegel curvature factor #———————————————– # restricted regression model reg.R – lm(exr_can3 ~ I(level_can + NS_slope*slope_can + NS_curvature*curvature_can), data = df.data, na.action = na.omit) # input variables for F-test T – length(reg.U$residuals) # # of observations K – length(reg.U$coefficients) # # of parameters J – 2 # # of restrictions # residual sum of squares RSSU – sum(reg.U$residuals^2) RSSR – sum(reg.R$residuals^2) # calculated F-test statistic F_test – ((RSSR – RSSU)/J)/(RSSU/(T–K)) # 95% critical value and p-value qf(.95, df1=J, df2=(T–K)) # 95% critical value 1 – pf(F_test, df1=J, df2=(T–K)) # p-value Favorite