# plotting log likelihood function

#### Henry10

##### New Member
Here is the code I am using to try to plot a log likelihood curve (cauchy distribution):

Code:
X=rcauchy(10)
h <- function(x) log(1+(x-X)^2) + ... + log(1+(x-X)^2)

curve(h, from = -8, to = 7)
But I get the error message 'Error in h(x) : '...' used in an incorrect context'

How do I rectify this error? Thanks

#### Dason

Are you saying that's the literal code you ran? Because "..." isn't just to say to R "and so on" like you use it in math.

#### ted00

##### New Member
are you just trying to make it more succint? possibly something like h1 below (the graph line is kinda clunky)

Code:
X=rcauchy(10)
h <- function(x)
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2) +
log(1+(x-X)^2)

h1 <- function(x)sum(log(1+(x-X)^2))
h(2)
h1(2)
curve(h, from = -8, to = 7,lwd=3)
xa=seq(-8,7,l=101)
y=sapply(xa,function(x)h1(x))
lines(xa,y,col=2,lty=3,lwd=3)

#### Henry10

##### New Member
Thanks, yes I was overestimating the intelligence of R there