i want plot loglikelihood function of series of independent bernoulli distributed random variables y parameter p being function (the logistic function) of feature x. logistic function has parameter b. parameter want estimate. want plot loglikelihood function of b. want in r using ggplot2, because want become better in those. my creation of loglikelihood function can , should done better, not point here. problem plotted loglikelihood constant on interval (-5,5). seems wrong. especially, because when call function arbitrary b in interval returns different value. why happen? thank you. library(ggplot2) set.seed(123) # parameters n=100 mu=0 s=2 b<-0.2 # functions logit <- function(x,b){1/(1+exp(-b*x))} # simulation of data x<-rnorm(n,mu,s) y_prob<-logit(x,b) y<-rbinom(n,1,y_prob) df<-data.frame(x,y) # loglikelihood function loglikelihood<-function(b,df){ prd<-1 (i in 1:nrow(df)){ events<-logit(df$x[i],b) nonevents<-1-events prd...
Comments
Post a Comment