In the output of the code below, I want to do the following:

 

-          get hats over some of the betas

-          get the polygons stippled, not coloured grey

-          remove the tick marks at the ends of the axes.   If I put tick =
false, the whole axis disappears.

 

betahat <- c(0.04*0:150)

betahatdens <- dnorm(betahat, 3, 1)

plot(betahat, betahatdens, xlim = c(-0.2, 6.2), ylim = c(-0.09, 1), 

   type = "l", lwd = 2, xlab = NA, ylab = NA, axes = FALSE)

axis(1, pos = 0, labels = FALSE, tick = TRUE, at = c(0, 2, 3, 4, 6))

axis(2, pos = 0, labels = FALSE, tick = TRUE, at = c(0, 0.5))

text (5.5, -0.05, 

   labels = expression(italic(beta)), pos = 4, cex = 1.2)

text (c(-0.3, -0.3, -0.3), c(0.25, 0.3, 0.35), 

   labels = expression('f(',italic(beta),')'), 

   pos = 4, cex = 1.2, srt = 90)

text (2, -0.05, 

   labels = expression(italic(beta - sigma[beta])), pos = 4, cex = 1.2)

text (3, -0.05, 

   labels = expression(italic(beta)), pos = 4, cex = 1.2)

text (4, -0.05, 

   labels = expression(italic(beta + sigma[beta])), pos = 4, cex = 1.2)

selx1 <- c(4 + (6 - 4) * 0:100/100)

selx2 <- c(4 + (6 - 4) * 100:0/100)

sely1 <- dnorm(selx1, 3, 1)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, col = "gray")

selx1 <- c(2 * 0:100/100)

selx2 <- c(2 * 100:0/100)

sely1 <- dnorm(selx1, 3, 1)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, col = "gray")

 

Moreover, in the output of the code below, I want to:

 

-          get values placed by every tickmark, not just every alternate
tickmark

-          give the values to fewer places of decimals.

 

t <- c(0.01*0:900 - 4.5)

tdens <- dt(t, 6)

plot(t, tdens, xlim = c(-4.7, 4.7), ylim = c(-0.09, 0.5), 

   type = "l", lwd = 2, xlab = NA, ylab = NA, axes = FALSE)

axis(1, pos = 0, labels = FALSE, tick = TRUE, at = c(-4.5, 3.21, 4.5))

tcrit025 <- qt(0.975, 6)

tcrit005 <- qt(0.995, 6)

axis(1, pos = 0, labels = TRUE, tick = TRUE, 

   at = c(-tcrit005, -tcrit025, -1, 0, 1, tcrit025, tcrit005))

axis(2, pos = 0, labels = FALSE, tick = TRUE, at = c(0, 0.4))

text (4.2, -0.05, 

   labels = expression(italic(T)), pos = 4, cex = 1.2)

text (c(-0.4, -0.4, -0.4), c(0.2, 0.25, 0.3), 

   labels = expression('f(',italic(T),')'), 

   pos = 4, cex = 1.2, srt = 90)

text (c(2.91, 3.11), c(-0.06, -0.06),

   labels = expression(italic(t), '= 3.21'), pos = 4, cex = 1.2)

points (c(3.21, 3.21), c(0, -0.05), type = "l")

 

selx1 <- c(1 + (4.5 - 1) * 0:100/100)

selx2 <- c(1 + (4.5 - 1) * 100:0/100)

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, col = "gray")

selx1 <- -selx1

selx2 <- -selx2

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, col = "gray")

 

selx1 <- c(tcrit025 + (4.5 - tcrit025) * 0:100/100)

selx2 <- c(tcrit025 + (4.5 - tcrit025) * 100:0/100)

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, density = 20)

selx1 <- -selx1

selx2 <- -selx2

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, density = 20)

 

selx1 <- c(tcrit005 + (4.5 - tcrit005) * 0:100/100)

selx2 <- c(tcrit005 + (4.5 - tcrit005) * 100:0/100)

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, density = 20, angle = 135)

selx1 <- -selx1

selx2 <- -selx2

sely1 <- dt(selx1, 6)

sely2 <- seq(length = 101, from = 0, by = 0)

selx <- c(selx1, selx2)

sely <- c(sely1, sely2)

polygon(selx, sely, density = 20, angle = 135)

 

text (1.4, 0.32,

   labels = "Hatched area = 0.025", pos = 4, cex = 1.2)

points (c(1.5, 3), c(0.3, 0.005), type = "l")

 

text (c(2.3, 2.3), c(0.25, 0.22),

   labels = c("Cross-hatched", "area = 0.005"), pos = 4, cex = 1.2)

points (c(3, 4), c(0.2, 0.005), type = "l")

 

Can anyone advise?

 

Best wishes,

 

Nick Galwey

 


	[[alternative HTML version deleted]]


