Title: | Configural Frequency Analysis (CFA) |
---|---|
Description: | Analysis of configuration frequencies for simple and repeated measures, multiple-samples CFA, hierarchical CFA, bootstrap CFA, functional CFA, Kieser-Victor CFA, and Lindner's test using a conventional and an accelerated algorithm. |
Authors: | Patrick Mair [aut, cre], Stefan Funke [aut], Joachim Harloff [ctb], Alexander von Eye [ctb] |
Maintainer: | Patrick Mair <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.10-1 |
Built: | 2024-11-11 02:57:46 UTC |
Source: | https://github.com/cran/cfa |
The bootstrap-CFA tries to replicate the pattern of significant configurations by re-sampling.
bcfa(configs, cnts, runs=100, sig.item="sig.z",...)
bcfa(configs, cnts, runs=100, sig.item="sig.z",...)
configs |
Contains the configurations. This can be a dataframe or a matrix. The dataframe can contain numbers, characters, factors, or booleans. The matrix can consist of numbers, characters or booleans (factors are implicitely re-converted to numerical levels). There must be >=3 columns. |
cnts |
Contains the counts for the configuration. If it is set to NA, a count of one is assumed for every
row. This allows untabulated data to be processed. |
runs |
Number of samples to be drawn. |
sig.item |
Indicator of significance in the result table (sig.z,sig.chisq,sig.perli,sig.zl, sig.zl.corr). Do not forget to set the proper parameters for the CFA if sig.perli,sig.zl or sig.zl.corr are to be used! |
... |
Parameters to be to relayed to the CFA |
Takes 'runs' samples and does as many CFAs while counting how many times this configuration was considered to be significant.
Repeated-measures CFAs (mcfa) are not provided.
This is a heuristic method rather than a strict test of significance since there is no adjustment for multiple testing whatsoever. The advantage is a more reliable picture compared to splitting the original data, doing a CFA, and checking if the configurations re-appear in a CFA with the other half of the data.
cnt.antitype |
Number of antiypes |
cnt.type |
Number of types |
pct.types |
Number of types in percent |
cnt.sig |
Number of significant results |
pct.cnt.sig |
Number of significant results in percent |
bcfa()
performs many CFAs which are by themselves slow, so the execution can
be very time-consuming, especially if a sufficiently high value for runs
was selected
Stefan Funke <[email protected]>
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse Psychologie und Medizin, Beltz Psychologie Verlagsunion
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) bcfa(configs,counts,runs=25)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) bcfa(configs,counts,runs=25)
This is the main function which will call scfa() und mcfa() as required to handle the simple and the multiple cfa.
cfa(cfg, cnts=NA, sorton="chisq", sort.descending=TRUE, format.labels=TRUE, casewise.delete.empty=TRUE, binom.test=FALSE, exact.binom.test=FALSE, exact.binom.limit=10, perli.correct=FALSE, lehmacher=FALSE, lehmacher.corr=TRUE, alpha=0.05, bonferroni=TRUE)
cfa(cfg, cnts=NA, sorton="chisq", sort.descending=TRUE, format.labels=TRUE, casewise.delete.empty=TRUE, binom.test=FALSE, exact.binom.test=FALSE, exact.binom.limit=10, perli.correct=FALSE, lehmacher=FALSE, lehmacher.corr=TRUE, alpha=0.05, bonferroni=TRUE)
cfg |
Contains the configurations. This can be a dataframe or a matrix. The dataframe can contain numbers, characters, factors, or booleans. The matrix can consist of numbers, characters, or booleans (factors are implicitely re-converted to numerical levels). There must be >=3 columns. |
cnts |
Contains the counts for the configuration. If it is set to NA, a count of one is assumed for every
row. This allows untabulated data to be processed. |
sorton |
Determines the sorting order of the output table. Can be set to |
sort.descending |
Sort in descending order |
format.labels |
Format the labels of the configuration. This makes to output wider but it will increase the readability. |
casewise.delete.empty |
If set to TRUE all configurations containing a NA in any column will be deleted. Otherwise NA is handled as the string "NA" and will appear as a valid configuration. |
binom.test |
Use z approximation for binomial test. |
exact.binom.test |
Do an exact binomial test. |
exact.binom.limit |
Maximum n for which an exact binomial test is performed (n >10 causes p to become inexact). |
perli.correct |
Use Perli's correction for multiple test. |
lehmacher |
Use Lehmacher's correction for multiple test. |
lehmacher.corr |
Use a continuity correction for Lehmacher's correction. |
alpha |
Alpha level |
bonferroni |
Do Bonferroni adjustment for multiple test (irrelevant for Perli's and Lehmacher's test). |
The cfa is used to sift large tables of nominal data. Usually it is used for dichotomous
variables but can be extended to three or more possible values. There should be at least three configuration variables
in cfg
- otherwise a simple contigency table would do.
All tests of significance are two-sided: They test for both types or antitypes, i.e. if n is significantly larger or
smaller than the expected value.
The usual caveats for testing contigency tables apply. If a configuration has a n <5 an exact test
should be used. As an alternative the least interesting configuration variable can be left out (if
it is not essential) which will automatically increase the n for the remaining configurations.
Some of these elements will only be returned when the corresponding argument in the function call has been set. The relation is obvious due to corresponding names.
table |
The cfa output table |
table["label"] |
Label for the given configuration |
table["n"] |
Observed n for this configuration |
table["expected"] |
Expected n for this configuration |
table["Q"] |
Coefficient of pronouncedness (varies between 0 and 1) |
table["chisq"] |
Chi squared for the given configuration |
table["p.chisq"] |
p for the chi squared test |
table["sig.chisq"] |
Is it significant (will Bonferroni-adjust if argument |
table["z"] |
z-approximation for chi squared |
table["p.z"] |
p of z-test |
table["sig.z"] |
Is it significant (will Bonferroni-adjust if argument |
table["x.perli"] |
Statistic for Perli's test |
table["sig.perli"] |
Is it significant (this is designed as a multiple test)? |
table["zl"] |
z for Lehmacher's test |
table["sig.zl"] |
Is it significant (this is designed as a multiple test)? |
table["zl.corr"] |
z for Lehmacher's test (with continuity correction) |
table["sig.zl.corr"] |
Is it significant (this is designed as a multiple test)? |
table["p.exact.bin"] |
p for exact binomial test |
summary.stats |
Summary stats for entire table |
summary.stats["totalchisq"] |
Total chi squared |
summary.stats["df"] |
Degrees of freedom |
summary.stats["p"] |
p for the chi squared test |
summary.stats["sum of counts"] |
Sum of all counts |
levels |
Levels for each configuration. Should all be 2 for the bivariate case |
Note than spurious "significant" configurations are likely to appear in very large tables.
The results should therefore be replicated before they are accepted as real. boot.cfa
can be helpful to check
the results.
There are no hard-coded limits in the program so even large tables can be processed. The output table can be very wide if the levels of factors variables are long strings so ‘options(width=..)’ may need to be adjusted.
The object returned has the class scfa if a one-sample CFA was performed or
the class mcfa if a repeated-measures CFA was performed. cfa()
decides which
one is appropriate by looking at cnts
: If it is a vector, it will do a
simple CFA. If it is a dataframe or matrix with 2 or more columns, a repeated-measures
CFA ist done.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin. Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin. Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) cfa(configs,counts)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) cfa(configs,counts)
These CFA methods detect and eliminate stepwise types/antitypes cells by specifying an appropriate contrast in the design matrix. The procedures stop when model fit is achieved. Functional CFA (fCFA) uses a residual criterion, Kieser-Victor CFA (kvCFA) a LR-criterion.
fCFA(m.i, X, tabdim, alpha = 0.05) kvCFA(m.i, X, tabdim, alpha = 0.05)
fCFA(m.i, X, tabdim, alpha = 0.05) kvCFA(m.i, X, tabdim, alpha = 0.05)
m.i |
Vector of observed frequencies. |
X |
Design Matrix of the base model. |
tabdim |
Vector of table dimensions. |
alpha |
Significance level. |
restable |
Fit results for each step |
design.mat |
Final design matrix |
struc.mat |
Structural part of the design matrix for each step |
typevec |
Type or antitype for each step |
resstep |
Design matrix, expected frequency vector, and fit results for each step |
Patrick Mair, Alexander von Eye
von Eye, A., and Mair, P. (2008). A functional approach to configural frequency analysis. Austrian Journal of Statistics, 37, 161-173.
Kieser, M., and Victor, N. (1999). Configural frequency analysis (CFA) revisited: A new look at an old approach. Biometrical Journal, 41, 967-983.
#Functional CFA for a internet terminal usage data set by Wurzer #(An application of configural frequency analysis: Evaluation of the #usage of internet terminals, 2005, p.82) dd <- data.frame(a1=gl(3,4),b1=gl(2,2,12),c1=gl(2,1,12)) X <- model.matrix(~a1+b1+c1,dd,contrasts=list(a1="contr.sum",b1="contr.sum", c1="contr.sum")) ofreq <- c(121,13,44,37,158,69,100,79,24,0,26,3) tabdim <- c(3,2,2) res1 <- fCFA(ofreq, X, tabdim=tabdim) res1 summary(res1) # Kieser-Vector CFA for Children's temperament data from # von Eye (Configural Frequency Analysis, 2002, p. 192) dd <- data.frame(a1=gl(3,9),b1=gl(3,3,27),c1=gl(3,1,27)) X <- model.matrix(~a1+b1+c1,dd,contrasts=list(a1="contr.sum", b1="contr.sum",c1="contr.sum")) ofreq <- c(3,2,4,23,23,6,39,33,9,11,29,13,19,36,19,21,26,18,13,30, 41,12,14,23,8,6,7) tabdim <- c(3,3,3) res2 <- kvCFA(ofreq, X, tabdim=tabdim) res2 summary(res2)
#Functional CFA for a internet terminal usage data set by Wurzer #(An application of configural frequency analysis: Evaluation of the #usage of internet terminals, 2005, p.82) dd <- data.frame(a1=gl(3,4),b1=gl(2,2,12),c1=gl(2,1,12)) X <- model.matrix(~a1+b1+c1,dd,contrasts=list(a1="contr.sum",b1="contr.sum", c1="contr.sum")) ofreq <- c(121,13,44,37,158,69,100,79,24,0,26,3) tabdim <- c(3,2,2) res1 <- fCFA(ofreq, X, tabdim=tabdim) res1 summary(res1) # Kieser-Vector CFA for Children's temperament data from # von Eye (Configural Frequency Analysis, 2002, p. 192) dd <- data.frame(a1=gl(3,9),b1=gl(3,3,27),c1=gl(3,1,27)) X <- model.matrix(~a1+b1+c1,dd,contrasts=list(a1="contr.sum", b1="contr.sum",c1="contr.sum")) ofreq <- c(3,2,4,23,23,6,39,33,9,11,29,13,19,36,19,21,26,18,13,30, 41,12,14,23,8,6,7) tabdim <- c(3,3,3) res2 <- kvCFA(ofreq, X, tabdim=tabdim) res2 summary(res2)
Recursively eliminates one variable in the configuration to generate all possible sub-tables and performs a global chi-squared-test on them
hcfa(configs, cnts)
hcfa(configs, cnts)
configs |
Contains the configurations. This can be a dataframe or a matrix. The dataframe can contain numbers, characters, factors or booleans. The matrix can consist of numbers, characters or booleans (factors are implicitely re-converted to numerical levels). There must be >=3 columns. |
cnts |
Contains the counts for the configuration. If it is set to NA, a count of one is assumed for every
row. This allows untabulated data to be processed. |
The hierarchical CFA assists in the selection of configuration variables by showing which variables contribute the most to the variability. If eliminating a variable does not markedly decrease the global chi squared the variable is likely to be redundant, provided there are no extraneous reasons for retaining it.
The output is in decreasing order of chi squared so the most useful combinations of variables come first.
chisq |
Global chi squared |
df |
Degrees of freedom for this subtable |
order |
Order (number of configuration variables) |
The p for the test of significance ist provided by the print method
Stefan Funke <[email protected]>
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1], c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) hcfa(configs,counts)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1], c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) hcfa(configs,counts)
Performs an analysis of configuration frequencies for two or more sets of counts.
This function is not designed to be called directly by the user but will only be used internally by cfa()
.
Both the simple an the multiple cfa are handled by cfa()
mcfa(cfg, cnts, sorton="chisq", sort.descending=TRUE, format.labels=TRUE)
mcfa(cfg, cnts, sorton="chisq", sort.descending=TRUE, format.labels=TRUE)
cfg |
Contains the configurations. This can be a dataframe or a matrix. The dataframe can contain numbers, characters, factors or booleans. The matrix can consist of numbers, characters or booleans (factors are implicitely re-converted to numerical levels). There must be >=3 columns. |
cnts |
Contains the counts for the configuration. |
sorton |
Determines the sorting order of the output. Can be set to |
sort.descending |
Sort in descending order |
format.labels |
Format the labels of the configuration. This makes to output wider but it will increase the readability. |
This function is the "engine" cfa()
will use. It does
the aggregation, summing up, and will calculate chi squared. All tests of significance are left to cfa()
The function returns the following list:
labels |
Configuration label |
sums |
Sums for each configuration and each variable in the configuration |
counts |
Matrix of observed n of the given configuration |
expected |
Matrix of expected n for the given configuration |
chisq |
Chi squared for each configuration |
There are no hard-coded limits in the program so even large tables can be processed.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) cfa(configs,cbind(counts1,counts2)) # cfa rather than mcfa!
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) cfa(configs,cbind(counts1,counts2)) # cfa rather than mcfa!
Plots an object of the class bcfa
## S3 method for class 'bcfa' plot(x,...)
## S3 method for class 'bcfa' plot(x,...)
x |
An object of the class |
... |
Any arguments to be given to |
Plots the number of cases considered significant vs. the number of cases considered to be a type (n > expected).
This is in some way like other plots of quality versus quantity.
Configurations can be identified by left-clicking on them until the right mouse button is pressed. The labels of the configurations selected will be displayed in the text window.
Returns a vector of the configurations selected with their name set to the labels
This function is usually invoked plotting an object returned by
bcfa
Stefan Funke <[email protected]>
None - plots have been rarely used with the CFA
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) plot(bcfa(configs,counts,runs=25))
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) plot(bcfa(configs,counts,runs=25))
Plots an object of the class hcfa
## S3 method for class 'hcfa' plot(x,...)
## S3 method for class 'hcfa' plot(x,...)
x |
An object of the class hcfa |
... |
Any arguments to be used by |
A dotchart is generated which plots chi squared vs. the order of the configuration (i.e. the number of configuration variables it contains).
Returns NULL.
This function is usually invoked plotting an object returned by
hcfa
Stefan Funke <[email protected]>
None - plots have been rarely used with the CFA
#configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], # c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) #counts<-trunc(runif(250)*10) #plot(hcfa(configs,counts))
#configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], # c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) #counts<-trunc(runif(250)*10) #plot(hcfa(configs,counts))
Plots an object of the class mcfa
## S3 method for class 'mcfa' plot(x,...)
## S3 method for class 'mcfa' plot(x,...)
x |
An object of the class |
... |
Any arguments to be used by |
Plots chi squared vs. the sum of all counts for this configuration which indicates pronouncedness of the configuration vs. practical importance. Configurations can be identified by left-clicking on them until the right mouse button is pressed. The labels of the configurations selected will be displayed in the text window.
Returns a list of the labels of the configurations selected.
This function is usually invoked plotting an object returned by
cfa
Stefan Funke <[email protected]>
None - plots have been rarely used with the CFA
# Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) plot(cfa(configs,cbind(counts1,counts2)))
# Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) plot(cfa(configs,cbind(counts1,counts2)))
Plots an object of the class scfa
## S3 method for class 'scfa' plot(x,...)
## S3 method for class 'scfa' plot(x,...)
x |
An object of the class |
... |
Any arguments to be used by |
Plots chi squared vs. n which indicates pronouncedness of the configuration vs. practical importance. Configurations can be identified by left-clicking on them until the right mouse button is pressed. The labels of the configurations selected will be displayed in the text window.
Returns a list of the labels of the configurations selected.
This function is usually invoked plotting an object returned by
cfa
Stefan Funke <[email protected]>
None - plots have been rarely used with the CFA
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) plot(cfa(configs,counts))
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) plot(cfa(configs,counts))
Printing method for an object returned by boot.cfa()
## S3 method for class 'bcfa' print(x,...)
## S3 method for class 'bcfa' print(x,...)
x |
An object of the class bcfa |
... |
Additional arguments given to |
This function is usually called implicitely.
Returns NULL
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) result<-bcfa(configs,counts,runs=25) print(result)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) result<-bcfa(configs,counts,runs=25) print(result)
Printing method for an object returned by hier.cfa()
## S3 method for class 'hcfa' print(x,...)
## S3 method for class 'hcfa' print(x,...)
x |
An object of the class hcfa |
... |
Additional arguments given to |
This function is usually called implicitely.
Returns NULL.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
#configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], # c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) #counts<-trunc(runif(250)*10) #result<-hcfa(configs,counts) #print(result)
#configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], # c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) #counts<-trunc(runif(250)*10) #result<-hcfa(configs,counts) #print(result)
Printing method for one of two possible objects returned by cfa()
## S3 method for class 'mcfa' print(x,...)
## S3 method for class 'mcfa' print(x,...)
x |
An object of the class mcfa |
... |
Additional arguments given to |
This function is usually called implicitely.
Returns NULL
Note that cfa()
will return an object with the class scfa if there is only one
row of counts. If there are two or more of them, an object with the class mcfa is returned.
In contrast scfa()
and mcfa()
return a list which has no class of it's own.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) result<-cfa(configs,cbind(counts1,counts2)) print(result)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts1<-trunc(runif(250)*10) counts2<-trunc(runif(250)*10) result<-cfa(configs,cbind(counts1,counts2)) print(result)
Printing method for one of two possible objects returned by cfa()
## S3 method for class 'scfa' print(x,...)
## S3 method for class 'scfa' print(x,...)
x |
An object of the class scfa |
... |
Additional arguments given to |
This function is usually called implicitely.
Returns NULL
Note that cfa()
will return an object with the class scfa if there is only one
row of counts. If there are two or more of them, an object with the class mcfa is returned.
In contrast scfa()
and mcfa()
return a list which has no class of it's own.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) result<-cfa(configs,counts) print(result)
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) result<-cfa(configs,counts) print(result)
Performs a test of significance according to Lindner
PXisM(m,n,Nt,k)
PXisM(m,n,Nt,k)
m |
Observed frequency of the observation tested |
n |
Marginal sums of the parameters realized in the configuration to be tested (vector) |
Nt |
Sample size of configurations |
k |
Number of parameters |
returns p for the test according to Linder
The test according to Lindner requires the packages parallel. All other parts of cfa do not.
J. Harloff <[email protected]>
Lindner, K.: Eine exakte Auswertungsmethode zur Konfigurationsfrequenzanalyse [An exact procedure for the configural frequency analysis]. Psycholog Beitraege 26, 393?415 (1984)
Harloff, Joachim, An efficient algorithm for Lindners test (configural frequency analysis), Qual Quant DOI 10.1007/s11135-011-9499-9
# Does not work with windows since there is no parallel for it if (require(parallel)) { lk<-4 # number of parameters ln<-c(59,57,59,58) # marginal sums of the parameters realized in the configuration to be tested lNt<-116 # sample size of configurations lm0<-16 # observed frequency of the configuration tested # New algorithm starttime=proc.time() pHXsmallerequalM0<-sum(unlist(mclapply(0:lm0,PXisM,ln,lNt,lk))) pHXequalM0<-PXisM(lm0,ln,lNt,lk) pHlargerequalM0<-sum(unlist(mclapply(lm0: min(ln),PXisM,ln,lNt,lk))) stoptime<-proc.time() list(pHXsmallerequalM0=pHXsmallerequalM0,pHXequalM0=pHXequalM0,pHlargerequalM0=pHlargerequalM0, timed.required=stoptime-starttime) # End of the new algorithm }
# Does not work with windows since there is no parallel for it if (require(parallel)) { lk<-4 # number of parameters ln<-c(59,57,59,58) # marginal sums of the parameters realized in the configuration to be tested lNt<-116 # sample size of configurations lm0<-16 # observed frequency of the configuration tested # New algorithm starttime=proc.time() pHXsmallerequalM0<-sum(unlist(mclapply(0:lm0,PXisM,ln,lNt,lk))) pHXequalM0<-PXisM(lm0,ln,lNt,lk) pHlargerequalM0<-sum(unlist(mclapply(lm0: min(ln),PXisM,ln,lNt,lk))) stoptime<-proc.time() list(pHXsmallerequalM0=pHXsmallerequalM0,pHXequalM0=pHXequalM0,pHlargerequalM0=pHlargerequalM0, timed.required=stoptime-starttime) # End of the new algorithm }
Performs a test of significance according to Lindner - old algorithm
PXisMclassic(m,n,Nt,k)
PXisMclassic(m,n,Nt,k)
m |
Observed frequency of the observation tested |
n |
Marginal sums of the parameters realized in the configuration to be tested (vector) |
Nt |
Sample size of configurations |
k |
Number of parameters |
returns p for the test according to Linder
The test according to Lindner requires the packages parallel. All other parts of cfa do not.
J. Harloff <[email protected]>
Lindner, K.: Eine exakte Auswertungsmethode zur Konfigurationsfrequenzanalyse [An exact procedure for the configural frequency analysis]. Psycholog Beitraege 26, 393?415 (1984)
Harloff, Joachim, An efficient algorithm for Lindners test (configural frequency analysis), Qual Quant DOI 10.1007/s11135-011-9499-9
# Does not work with windows since there is no parallel for it if (require (parallel)) { lk<-4 # number of parameters ln<-c(59,57,59,58) # marginal sums of the parameters realized in the configuration to be tested lNt<-116 # sample size of configurations lm0<-16 # observed frequency of the configuration tested # Old algorithm starttime=proc.time() pHXsmallerequalM0<-sum(unlist(mclapply(0:lm0,PXisMclassic,ln,lNt,lk))) pHXequalM0<-PXisMclassic(lm0,ln,lNt,lk) pHlargerequalM0<-sum(unlist(mclapply(lm0: min(ln),PXisMclassic,ln,lNt,lk))) stoptime<-proc.time() list(pHXsmallerequalM0=pHXsmallerequalM0,pHXequalM0=pHXequalM0,pHlargerequalM0=pHlargerequalM0, timed.required=stoptime-starttime) # End of the old algorithm }
# Does not work with windows since there is no parallel for it if (require (parallel)) { lk<-4 # number of parameters ln<-c(59,57,59,58) # marginal sums of the parameters realized in the configuration to be tested lNt<-116 # sample size of configurations lm0<-16 # observed frequency of the configuration tested # Old algorithm starttime=proc.time() pHXsmallerequalM0<-sum(unlist(mclapply(0:lm0,PXisMclassic,ln,lNt,lk))) pHXequalM0<-PXisMclassic(lm0,ln,lNt,lk) pHlargerequalM0<-sum(unlist(mclapply(lm0: min(ln),PXisMclassic,ln,lNt,lk))) stoptime<-proc.time() list(pHXsmallerequalM0=pHXsmallerequalM0,pHXequalM0=pHXequalM0,pHlargerequalM0=pHlargerequalM0, timed.required=stoptime-starttime) # End of the old algorithm }
Performs a configuration frequency analysis if only one set of counts exists.
This function is not designed to be called directly by the user but will only be used internally by by cfa()
. Both the simple an the multiple cfa are handled by cfa()
scfa(cfg, cnt=NA, sorton="chisq", sort.descending=TRUE, format.labels=TRUE)
scfa(cfg, cnt=NA, sorton="chisq", sort.descending=TRUE, format.labels=TRUE)
cfg |
Contains the configurations. This can be a dataframe or a matrix. The dataframe can contain numbers, characters, factors or booleans. The matrix can consist of numbers, characters or booleans (factors are implicitely re-converted to numerical levels). There must be >=3 columns. |
cnt |
Contains the counts for the configuration. If it is set to NA, a count of one is assumed for every
row. This allows untabulated data to be processed. |
sorton |
Determines the sorting order of the output. Can be set to |
sort.descending |
Sort in descending order |
format.labels |
Format the labels of the configuration. This makes to output wider but it will increase the readability. |
This function is the "engine" cfa()
will use. It does the aggregation, summing up,
and will calculate chi squared. All tests of significance are left to cfa()
The function returns the following list:
labels |
Configuration label |
n.levels |
Number of levels for each configuration |
sums |
Sums for each configuration and each variable in the configuration |
counts |
Observed n of the given configuration |
expected |
Expected n for the given configuration |
chisq |
Chi squared for each configuration |
There are no hard-coded limits in the program so even large tables can be processed.
Stefan Funke <[email protected]>
Krauth J., Lienert G. A. (1973, Reprint 1995) Die Konfigurationsfrequenzanalyse (KFA) und ihre Anwendung in Psychologie und Medizin, Beltz Psychologie Verlagsunion
Lautsch, E., von Weber S. (1995) Methoden und Anwendungen der Konfigurationsfrequenzanalyse Psychologie und Medizin, Beltz Psychologie Verlagsunion
Eye, A. von (1990) Introduction to configural frequency analysis. The search for types and anti-types in cross-classification. Cambride 1990
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) cfa(configs,counts) # cfa rather than scfa!
# library(cfa) if not yet loaded # Some random configurations: configs<-cbind(c("A","B")[rbinom(250,1,0.3)+1],c("C","D")[rbinom(250,1,0.1)+1], c("E","F")[rbinom(250,1,0.3)+1],c("G","H")[rbinom(250,1,0.1)+1]) counts<-trunc(runif(250)*10) cfa(configs,counts) # cfa rather than scfa!