psych (version 1.0-95)

mat.regress: Multiple Regression from matrix input

Description

Extract subsets of variables (x and y) from a correlation or data matrix matrix and find the multiple correlation and beta weights of the (x) set predicting each member of the (y) set.

Usage

mat.regress(m, x, y,n.obs=NULL)

Arguments

m
a matrix of correlations or, if not square of data
x
either the column numbers of the x set (e.g., c(1,3,5) or the column names of the x set (e.g. c("Cubes","PaperFormBoard")
y
either the column numbers of the y set (e.g., c(2,4,6) or the column names of the y set (e.g., c("Flags","Addition")
n.obs
If specified, then confidence intervals, etc. are calculated, not needed if raw data are given

Value

  • betathe beta weights for each variable in X for each variable in Y
  • RThe multiple R for each equation (the amount of change a unit in the predictor set leads to in the criterion set).
  • R2The multiple R2 (% variance acounted for) for each equation

Details

Although it is more common to calculate multiple regression from raw data, it is, of course, possible to do so from a set of correlations. The input to the function is a square covariance or correlation matrix, as well as the column numbers (or names) of the x (predictor) and y (criterion) variables. The program will find the correlations if given raw data. The output is a set of multiple correlations, one for each dependent variable in the y set. A typical use in the SAPA project is to form item composites by clustering or factoring (see ICLUST, principal), extract the clusters from these results (factor2cluster), and then form the composite correlation matrix using cluster.cor. The variables in this reduced matrix may then be used in multiple R procedures using mat.regress.

Although the overall matrix can have missing correlations, the correlations in the subset of the matrix used for prediction must exist. If the number of observations is entered, then the conventional confidence intervals, statistical significance, and shrinkage estimates are reported. If the input matrix is rectangular, correlations are found from the data.

See Also

cluster.cor, factor2cluster,principal,ICLUST

Examples

Run this code
test.data <- Harman74.cor$cov     #24 mental variables
#choose 3 of them to regress against another 4 -- arbitrary choice of variables
summary(mat.regress(test.data,c(1,2,3),c(4,5,10,12),n.obs=213),digits=2) #choose the variables by number 
mat.regress(test.data,c("VisualPerception", "Cubes","PaperFormBoard"),c("Flags","Addition"))  #choose the variables by name
data(attitude)
mat.regress(attitude,c(1:3),c(4:7)) #standardized regression from raw data

Run the code above in your browser using DataCamp Workspace