View source: R/predict.lm.rrpp.r
predict.lm.rrpp | R Documentation |
Computes predicted values from an lm.rrpp
model fit, using bootstrapped residuals
to generate confidence intervals. (Residuals are the residuals of
the lm.rppp fit, not its null model. The bootstrap
procedure resamples residual vectors with replacement.)
The bootstrap permutations use the same number of iterations and
seed as used
in the lm.rrpp
model fit. A predict.lm.rrpp
object can be plotted using various options.
See plot.predict.lm.rrpp
.
Note that if data offsets are used (if the offset argument is used
when fitting a lm.rrpp
model),
they are ignored for estimating coefficients over iterations.
Offsets are subtracted from data in lm
and
added to predicted values in predict.lm
,
effectively adjusting the intercept and then un-adjusting
it for predictions. This causes problems if the newdata have a
different number of observations than the original
model fit.
## S3 method for class 'lm.rrpp'
predict(object, newdata = NULL, block = NULL, confidence = 0.95, ...)
object |
Object from |
newdata |
Data frame of either class |
block |
An optional factor for blocks within which to restrict resampling permutations. |
confidence |
The desired confidence interval level for prediction. |
... |
Other arguments (currently none) |
Michael Collyer
## Not run:
# See examples for lm.rrpp to see how predict.lm.rrpp works in conjunction
# with other functions
data(Pupfish)
# CS is centroid (fish) size
fit <- lm.rrpp(coords ~ log(CS) + Sex*Pop,
SS.type = "I", data = Pupfish, iter = 999)
# Predictions (holding alternative effects constant)
shapeDF <- expand.grid(Sex = levels(Pupfish$Sex), Pop = levels(Pupfish$Pop))
rownames(shapeDF) <- paste(shapeDF$Sex, shapeDF$Pop, sep = ".")
shapeDF
shapePreds <- predict(fit, shapeDF)
summary(shapePreds)
summary(shapePreds, PC = TRUE)
shapePreds99 <- predict(fit, shapeDF, confidence = 0.99)
summary(shapePreds99, PC = TRUE)
# Plot prediction
plot(shapePreds, PC = TRUE)
plot(shapePreds, PC = TRUE, ellipse = TRUE)
plot(shapePreds99, PC = TRUE)
plot(shapePreds99, PC = TRUE, ellipse = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.