O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – visualizing the likelihood function

We will now visualize the likelihood function for the binomial, Poisson, and normal distributions discussed before:

  1. Initialize the graphics windows for the three samples using par(mfrow= c(1,3)).
  2. Declare the number of trials n and the number of success x by n <- 10; x <- 7.
  3. Set the sequence of p values with p_seq <- seq(0,1,0.01).

    For p_seq, obtain the probabilities for n = 10 and x = 7 by using the dbinom function: dbinom(x=7,size=n,prob=p_seq).

  4. Next, obtain the likelihood function plot by running plot(p_seq, dbinom( x=7,size=n,prob=p_seq), xlab="p", ylab="Binomial Likelihood Function", "l")
  5. Enter the data for the Poisson random sample into R using x <- c(1,2,2,1, 0,2,3,1,2,4) and the number of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required