predictive_interval.stapreg.Rd
The predictive_interval
function computes Bayesian predictive intervals.
The method for stapreg objects calls posterior_predict
internally, whereas the method for objects of class "ppd"
accepts the
matrix returned by posterior_predict
as input and can be used to avoid
multiple calls to posterior_predict
.
# S3 method for stapreg predictive_interval(object, prob = 0.9, newsubjdata = NULL, newdistdata = NULL, newtimedata = NULL, draws = NULL, subject_ID = NULL, group_ID = NULL, re.form = NULL, fun = NULL, seed = NULL, offset = NULL, ...) # S3 method for ppd predictive_interval(object, prob = 0.9, ...)
object  Either a fitted model object returned by one of the
rstap modeling functions (a stapreg
object) or, for the 

prob  A number \(p \in (0,1)\) indicating the desired
probability mass to include in the intervals. The default is to report
\(90\)% intervals ( 
newsubjdata  Optionally, a data frame of the subjectspecific data
in which to look for variables with which to predict.
If omitted, the original datasets are used. If 
newdistdata  If newsubjdata is provided a data frame of the subjectdistance must also be given for models with a spatial component 
newtimedata  If newsubjdata is provided, a data frame of the subjecttime data 
draws, fun, offset, re.form, seed  Passed to

subject_ID  same as 
group_ID  same as 
...  Currently ignored. 
A matrix with two columns and as many rows as are in newsubjdata
.
If newsubjdata
is not provided then the matrix will have as many rows as
the data used to fit the model. For a given value of prob
, \(p\),
the columns correspond to the lower and upper \(100p\)% central interval
limits and have the names \(100\alpha/2\)% and \(100(1 
\alpha/2)\)%, where \(\alpha = 1p\). For example, if prob=0.9
is
specified (a \(90\)% interval), then the column names will be
"5%"
and "95%"
, respectively.
#> 5% 95% #> 1 0.91361950 0.5923939 #> 2 0.38982645 1.8163569 #> 3 0.68441754 1.3982590 #> 4 0.52202020 1.0468239 #> 5 0.98687036 1.0890773 #> 6 0.84245759 1.0759630 #> 7 0.75337265 0.8983179 #> 8 0.29379107 1.1993876 #> 9 0.31435650 1.3375969 #> 10 0.96855691 1.4766913 #> 11 1.10827140 0.5568126 #> 12 0.03448876 1.5262871 #> 13 0.28995199 1.1379683 #> 14 0.07574048 1.0876035 #> 15 0.54809164 1.3042049 #> 16 0.51060592 1.0289610 #> 17 0.19669231 1.6501689 #> 18 0.63965550 1.2795562 #> 19 0.35125135 0.8809490newdata < data.frame(subj_ID = c(1,1), measure_ID = c(1,2), centered_income = c(1,.7), sex = c(0,0), centered_age = c(1,.7)) # newdata predictive_interval(example_model, newsubjdata = newdata, newdistdata = distdata, newtimedata = timedata, subject_ID = "subj_ID", group_ID = "measure_ID")#> 5% 95% #> 1 0.5953371 1.1372906 #> 2 0.8271130 0.9755302