predict.mind {mind} | R Documentation |
Predict method for Multivariate Linear Mixed Model
Description
Predicted values based on Multivariate Linear Mixed Model object
Usage
## S3 method for class 'mind'
predict(object,data,type= "proj",dir_s=NULL,dir_cov=NULL,...)
Arguments
object |
an object of class " |
data |
an object in which to look with which to predict. |
type |
the type of prediction required. ; the predictors type are the |
dir_s |
optionally, if |
dir_cov |
optionally, if |
... |
arguments based from or to other methods |
Details
predict.mind
produces predicted values, obtained by means the regression parameters on the frame data
.
In the actual version of predict.mind
only unit level predictions are provided. If the type is equal to proj
or synth
a data.frame with individual predictions for all the modalities of the responce variable will be produced. When the eblup
predictor is chosen two more input data.frame must be provided and the function will produce predictions for all the profiles identified by the cross-classification of the domains and covariate patterns.
Value
When the predictor type is set equal to proj
or synth
the predict.mind
produces a data.frame
of predictions with the columns name equal to the multivariate responses
. If the predictor type is eblup
a data frame with predictions for all the profile (cross-clafficiation of domain of interest and coavariate patterns) is provided.
Author(s)
Developed by Andrea Fasulo
Examples
# Load example data
data(data_s);data(univ)
# The sample units cover 104 over 333 domains in the population data frame
length(unique(data_s$dom));length(unique(univ$dom))
# One random effect at domain level
formula<-as.formula(cbind(emp,unemp,inact)~(1|mun)+
factor(sexage)+factor(edu)+factor(fore))
# Drop from the universe data frame variables not referenced in the formula or in the broadarea
univ_1<-univ[,-6]
example.1<-mind.unit(formula=formula,dom="dom",data=data_s,universe=univ_1)
## Example 1
#Projection predictions
example.1.predict<-predict.mind(object=example.1,data=univ,type= "proj")
# Check if the sum of the unit level predictions at
# domain level are equal to the mind.unit Projection predictions
ck<-cbind(univ,example.1.predict)
ck<-aggregate(cbind(emp,unemp,inact)~dom,ck,sum)
head(ck);head(example.1$PROJ)
## Example 2
#Synthetic predictions
example.1.synth<-predict.mind(object=example.1,data=univ,type="synth")
# Check if the sum of the unit level predictions at
# domain level are equal to the mind.unit Synthetic predictions
ck<-cbind(univ,example.1.synth)
ck<-aggregate(cbind(emp,unemp,inact)~dom,ck,sum)
head(ck);head(example.1$SYNTH)
## Example 3
#EBLUP predictions
inp_1<-aggregate(cbind(emp,unemp,inact)~dom+mun+sexage + edu + fore,data_s,sum)
inp_2<-aggregate(emp+unemp+inact~dom+mun+sexage+edu +fore,data_s,sum)
example.1.eblup<-predict.mind(object=example.1,data=univ_1,type="eblup",dir_s=inp_1,dir_cov=inp_2)
# Check if the sum of the predictions at
# profile level are equal to the mind.unit Eblup predictions
ck<-aggregate(cbind(emp,unemp,inact)~dom,example.1.eblup,sum)
head(ck);head(example.1$EBLUP)