In R, package mgcv has logLik.gam that gives a generalized additive model's loglikelihood value as well as df. However, I could not take the df value only.
For example,
dt= gamSim(1,50)
x= dt$x0
y=dt$x1
model= gam(y~s(x))
logLik.gam(model)
[1] 'log Lik.' -1.560092 (df=3.612741)
From this I can only take -1.560092 . But to use the value of df (that is 3.612741), is there any way to take this from the output? The output here is numeric which is actually a sentence. So is there any way to cutting this output line and taking only the last value?
Yes. If you first assign the result to an output variable name you can then work with it. There is a print method for objects of that class: