Either 1) initialize a design matrix given a data frame and a list specifying the dependent variable and associated grouping variables, or 2) update a design matrix after modification of of the element summarizing the design matrix over all possible combinations of levels for the grouping variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
designmatrix(df = NULL, select = NULL, dm = NULL, digits = 2) is.designmatrix(x) ## S3 method for class 'designmatrix' print(x) ## S3 method for class 'designmatrix' summary(x) ## S3 method for class 'designmatrix' plot( x, intercept = T, exclude_effects = NULL, error_bars = F, average = T, ... ) ## S3 method for class 'designmatrix' subset(x, summary = T) subset(x, update = F) <- value
A data frame with the observations for the dependent variable and associated grouping variables.
A list with...
If only the column name for the dependent variable is provided, the function assumes all remaining columns are the set of grouping variables.
An object of class
The number of digits to round to when computing the group means.
An object of class
displays the combination of levels and their associated
descriptive statistics (mean, standard deviation,
standard error of the mean, and sample size). The method
subset can be used to access the summary matrix
(or the full design matrix if
or to replace elements of the summary matrix.
plot method generates a simple plot of the group
means (filled circles). If elements of the design matrix are
non-zero, the method fits a simple linear model to the data
using the specified design matrix and shows the resulting
estimates for the group means (empty circles). If the option
intercept is set to
TRUE (the default), the method
assumes the intercept term is defined in the user-submitted
design matrix. The option
adds approximate 95
equal to +/- 2 standard errors relative to the observed means.
exclude_effects takes a string character
with the column names for the design matrix. The method
then displays what the estimated means would be were these
columns excluded from from the design matrix (empty blue circles).
Additional plotting options for
bty, can be supplied.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Example with R data set 'PlantGrowth' dm = designmatrix( PlantGrowth, list( 'weight', 'group' ) ) # Summarize group means summary( dm ) # Specify design matrix # Main effect of treatment 1 subset( dm )[1:2,2] = c(-1,1) # Main effect of treatment 2 subset( dm )[c(1,3),3] = c(-1,1) # Update summaries and full design matrix dm = designmatrix( dm ) # Example of methods print( dm ) plot( dm, intercept = T, error_bars = T, exclude_effects = c( 'X2', 'X3' ) ) # Example analysis dtba = getdata( dm ) lmf = lm( DV ~ -1 + ., data = dtba )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.