View source: R/model.predictions.stanarm.R
| model.predictions.stanarm | R Documentation | 
Produce un data frame con le previsioni di un modello lineare ottenuto con il pacchetto rstanarm.
model.predictions.stanarm( fit, B = 100 )
fit | 
 modello lineare ottenuto con   | 
B | 
 numero di campioni da simulare, per default 100.  | 
Restituisce un data frame in forma lunga con le seguenti colonne
$simY | 
 valori della variabile dipendente simulati dal modello.  | 
$b | 
 etichetta per identificare il campione simulato.  | 
... | 
 valori osservati dei predittori usati nel modello lineare.  | 
Massimiliano Pastore
data( studenti, package = "ADati" )
# null model
fit0 <- rstanarm::stan_glm( voti~1, data = studenti, chains = 1)
Y <- model.predictions.stanarm( fit0 )
hist( Y$simY )
 
# modello con due predittori
fit <- rstanarm::stan_glm( voti~ore+anno, data = studenti, chains = 1 )
Y <- model.predictions.stanarm( fit, 100 )
par( mfrow=c(1,3))
for (j in levels(Y$anno)) plot( simY ~ ore, data = subset(Y,anno==j))
 
library( ggplot2 )
ggplot( Y, aes( ore, simY ))+facet_wrap(~anno)+
  geom_point(colour="red")+geom_point(aes(ore,voti),data=studenti,size=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.