Come posso aggiungere RMSE, slope, intercettare e r^2 a un grafico usando R? Ho allegato uno script con dati di esempio, che è un formato simile al mio set di dati reale - sfortunatamente, sono fermo. C'è un modo più semplice per aggiungere queste statistiche al grafico piuttosto che creare un oggetto da un'equazione e inserirlo in text()
? Preferirei che le statistiche fossero visualizzate impilate sul grafico. Come posso realizzare questo?Come aggiungere RMSE, slope, intercettare, r^2 alla trama R?
## Generate Sample Data
x = c(2,4,6,8,9,4,5,7,8,9,10)
y = c(4,7,6,5,8,9,5,6,7,9,10)
# Create a dataframe to resemble existing data
mydata = data.frame(x,y)
#Plot the data
plot(mydata$x,mydata$y)
abline(fit <- lm(y~x))
# Calculate RMSE
model = sqrt(deviance(fit)/df.residual(fit))
# Add RMSE value to plot
text(3,9,model)
Guardate questa domanda http://stackoverflow.com/questions/7549694/ggplot2-adding-regression-line-equation-and-r2-on-graph – mnel
Tutte le idee su come aggiungere "RMSE = valore "oltre a r^2 e un eq per pendenza e intercettazione in un modo ordinato e formattato? – Borealis
Non hai fornito alcun dettaglio su cosa intendi per "modo formattato". Nella grafica di base, il modo in cui aggiungi testo ad un grafico è con 'text' (o' mtext'), e hai un link per una risposta eccellente per ggplot. Che problema rimane? – joran