SOURCEBOOK

R Articles

Data Analysis | Regression

Prior to the steps below, enter the data as appropriate for the analyses (described elsewhere). As always, the following commands should be typed directly in the R console window.

Obtaining Descriptive Statistics

Get the sample sizes, means, and standard deviations for the variables.

lapply(CorrelationData, function(x) c(length(x), mean(x), sd(x)))

Get the covariance matrixfor the variables.

cov(Outcome1,Outcome2)

Obtaining Inferential Statistics

Get the proportion of variance accounted for by the model and the model coefficients, along with statistical significance for each of them.

model <- lm(Outcome2 ~ Outcome1)
summary(model)