model.predictions.rstanarm: Previsioni di un modello lineare

View source: R/model.predictions.rstanarm.R

model.predictions.rstanarmR Documentation

Previsioni di un modello lineare

Description

Produce un data frame con le previsioni di un modello lineare.

Usage

model.predictions.rstanarm( fit, B = 100 )

Arguments

fit

modello lineare ottenuto con rstanarm.

B

numero di campioni da simulare, per default 100.

Value

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.

Author(s)

Massimiliano Pastore

Examples

data( studenti, package = "ADati" )
# null model
fit0 <- rstanarm::stan_glm( voti~1, data = studenti, chains = 1)
Y <- model.predictions.rstanarm( fit0 )
hist( Y$simY )
 
# modello con due predittori
fit <- rstanarm::stan_glm( voti~ore+anno, data = studenti, chains = 1 )
Y <- model.predictions.rstanarm( 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)

masspastore/ADati documentation built on April 18, 2024, 5:55 p.m.