As it is written, your function will work for one value tetaand several values xor several values tetaand one value x. Otherwise, you will receive an incorrect value or warning.
Example: llhfor teta=1and teta=2:
> llh(1,x)
[1] -34.88704>
> llh(2,x)
[1] -60.00497
- this is not the same as:
> llh(c(1,2),x)
[1] -49.50943
And if you try to do three:
> llh(c(1,2,3),x)
[1] -49.52109
Warning message:
In x - teta :
longer object length is not a multiple of shorter object length
which mainly comes from:
> cos(x-c(1,2,3))
[...]
Warning message:
In x - c(1, 2, 3) :
longer object length is not a multiple of shorter object length
R -3 -20. -3 -20, , . ... , R, , , .
, , .
> vllh = Vectorize(llh,"teta")
> vllh(c(1,2,3),x)
[1] -34.88704 -60.00497 -67.30765
> plot(teta, vllh(teta,x))
