Learn R Programming

qrfactor (version 1.1)

qrfactor: R package for Q and R mode Factor analysis

Description

The qrfactor package simultaneously estimates Q and R mode factor analysis loadings and scores.

Usage

qrfactor(data,obs_start=NULL,mod_type='sd')
## S3 method for class 'default':
qrfactor(data,obs_start=NULL,mod_type='sd')
## S3 method for class 'qrfactor':
print(x,...)
## S3 method for class 'qrfactor':
summary(object,...)
## S3 method for class 'qrfactor':
plot(x,...)

Arguments

data
A numeric design matrix for the model. All records must be numeric; it also accepts continuous data. Avoid using categorical variables and characters
obs_start
a numeric record where the row number starts. For example, in time series analysis a record can start from 1960. Insert 1 if your record starts from observation 1. Set it to obs_start = NULL if you do not want specific row numbers assigned to loadings an
mod_type
Standardisation method that you want to use. Set it to "data" if you do not desire data transformation; set it to "sd" if you want the data to be standardised after centring it; set it to "n" if you want to divide the centred data by square root of the nu
x
an object of class "qrfactor", i.e., a fitted model.
object
an object of class "qrfactor", i.e., a fitted model.
...
any other R parameters can be added

Value

  • Objects of the class that basically list its elements
  • dataOriginal data for the model. All records must be numeric. It also accepts continous data
  • x.standardit is the scale matrix of the original data
  • correlationThe correlation matrix for the data
  • eigen.valueeigen value of correlation matrix of the data
  • eigen.vectoreigen vector of correlation matrix of the data
  • diagonal.matrixdiagonal matrix of eigen vector
  • r.loadingR-mode loadings
  • q.loadingQ-mode loadings
  • loadingscombined loadings of R and Q on the same axis
  • q.scorescomputed Q-mode scores
  • scorescombined R-mode and Q-mode scores on the same axis
  • rownamesrow names of the loadings
  • variablesvariables names of the loadings, of the original data

References

Davis, J. C. (2002) Statistics and Data Analysis in Geology. Third Edition. John Wiley & Sons

Examples

Run this code
#data must be numeric, avoid using categorical and characters
data(UScereal, package="MASS")
variables=c("calories","protein","sodium","carbo","sugars","potassium")
data=UScereal[variables]
#create object with observation number starting with nothing. 
mod1 <- qrfactor(data)
#print object
mod1
#extract the loadings
loadings=mod1$loadings
#summary of the loadings
summary(mod1)
#plot the first two axes of the loadings
plot(mod1)


#2nd model with observations or records starting from zero and standardising
mod2<-qrfactor(data,obs_start=0,mod_type='sd')

#print object 2
mod2

#extract the loadings
loadings=mod2$loadings

#summary of the loadings
summary(mod2)
#plot the the first two axes of the loadings
plot(mod2)

#plotting other axes for mod2 for axes 3 and 4
plot(mod2$loadings[,3],mod2$loadings[,4])

Run the code above in your browser using DataLab