predict.femlm {FENmlm} | R Documentation |
Predict method for femlm fits
Description
This function obtains prediction from a fitted model estimated with femlm
.
Usage
## S3 method for class 'femlm'
predict(object, newdata, type = c("response", "link"),
...)
Arguments
object |
An object of class |
newdata |
A data.frame containing the variables used to make the prediction. If not provided, the fitted expected (or linear if |
type |
Character either equal to |
... |
Not currently used. |
Value
It returns a numeric vector of length equal to the number of observations in argument newdata
.
Author(s)
Laurent Berge
See Also
femlm
, update.femlm
, summary.femlm
, vcov.femlm
, getFE
.
Examples
# Estimation on iris data
res = femlm(Sepal.Length ~ Petal.Length | Species, iris)
# what would be the prediction if the data was all setosa?
newdata = data.frame(Petal.Length = iris$Petal.Length, Species = "setosa")
pred_setosa = predict(res, newdata = newdata)
# Let's look at it graphically
plot(c(1, 7), c(3, 11), type = "n", xlab = "Petal.Length",
ylab = "Sepal.Length")
newdata = iris[order(iris$Petal.Length), ]
newdata$Species = "setosa"
lines(newdata$Petal.Length, predict(res, newdata))
# versicolor
newdata$Species = "versicolor"
lines(newdata$Petal.Length, predict(res, newdata), col=2)
# virginica
newdata$Species = "virginica"
lines(newdata$Petal.Length, predict(res, newdata), col=3)
# The original data
points(iris$Petal.Length, iris$Sepal.Length, col = iris$Species, pch = 18)
legend("topleft", lty = 1, col = 1:3, legend = levels(iris$Species))