Seite 1 von 1

X-Achse Boxplot

Verfasst: Sa Dez 12, 2020 11:40 am
von Tom1980
Hallo Ihr Lieben,

ich möchte die Beschriftung der Achse in folgendem Beispiel ändern. Anstatt 0,1,2,3,4,5 möchte ich dort die entsprechenden Modelnamen "crude", "direct", "total", "bias1"... stehen haben. Wie mache ich das? Kann mir jemand helfen?

Außerdem möchte ich gerne eine Legendenbeschriftung für die rote Linie mit "true causal effect"

Code: Alles auswählen

 
 ## Illustrating causal estimates --------------------------------------------------
# This function add points with confidence interval to an existing plot
add_estimate <- function(model, xpos) {
  # Estimate for causal effect
  estimate <- model$coefficients['dat$ZSpAttAnx_Emp']
  # It's 95 % CI
  ci <- confint(model)['dat$ZSpAttAnx_Emp',]
  
  # Draw CI in plot
  arrows(x0 = xpos, x1 = xpos, y0 = ci[1], y1 = ci[2], 
         length = 0.05, angle = 90, code = 3)
  # Draw point
  points(xpos, estimate, pch = 16, bg = 'grey')
}

# Make plot
plot(0, xlim = c(0, 5), ylim = c(0.4, 0.8), pch = '', xlab = 'Model', 
     ylab = 'Causal estimate', main=" quality of prediction models \n burnout employees",)
# Add line at direct causal effect
lines(c(-1, 6), c(0.5, 0.5), lty = 5, col = 'red')


# Use function to add data points and error bars (95 % CIs)
add_estimate(crude, 0)
add_estimate(direct, 1)
add_estimate(total, 2)
add_estimate(bias1, 3)
add_estimate(bias2, 4)
add_estimate(bias3, 5)
 

Re: X-Achse Boxplot

Verfasst: Sa Dez 12, 2020 6:11 pm
von bigben
Hi!

R sagt zu Deinem Code

Code: Alles auswählen

Fehler in add_estimate(crude, 0) : Objekt 'crude' nicht gefunden
Was nutzt der Code ohne Daten? Im Titel steht was von boxplot, im Code kann ich das nicht finden. Stattdessen ist da von Konfidenzintervallen die Rede.

Ich kann also nur hoffen, dass das hier hilft:

Code: Alles auswählen

plot(0, xlim = c(0, 5), ylim = c(0.4, 0.8), xaxt="n")
axis(1, at = 1:4, labels = LETTERS[1:4])
Siehe bitte auch viewtopic.php?f=20&t=11

LG,
Bernhard