Does anybody know what's wrong? I get a warning message saying the amount of rows are 101 even though there only should be one argument, theta. I have tried the sum function instead of the for loop as well.
#> code
p <- ggplot(data.frame(x=0), mapping=aes(x=x))
xsim <- rnorm(100,1,1)
logl <- function(theta){
a <- 0
(100/2)*log(2*pi*theta^2)+ for (j in 1:100){
a <- a+(xsim[j]-theta)^2/(2*theta^2)
}
}
}
p + stat_function(fun = logl) + xlim(-5,5)