#Creates a fake dataframe
set.seed(1234)
df <- as.data.frame(cbind(Y=rnorm(30, 30,9), X=rnorm(30, 450,133)))
head(df)
descstat(df)
#fitting a candidate model
mod1 <- lm(Y~X, data=df)
#Using the valesta function
valesta(y.obs=df$Y,y.pred=fitted(mod1))
# If some of the predicted values is missing (e.g. because of a
# missing predictor variable) the number of observations can be exported
df2 <- data.frame(y.obs=df$Y,y.pred=fitted(mod1))
df2[c(14,26), 2] <- NA
descstat(df2)
#Notice the different sample size
valesta(y.obs = df2$y.obs, y.pred = df2$y.pred, want.n = TRUE)
# Thus, only 28 observations are used, as it should be.
Run the code above in your browser using DataLab