| Title: | Basic Functions in Knowledge Space Theory Using Matrix Representation |
|---|---|
| Description: | Knowledge space theory by Doignon and Falmagne (1999) <doi:10.1007/978-3-642-58625-5> is a set- and order-theoretical framework, which proposes mathematical formalisms to operationalize knowledge structures in a particular domain. The 'kstMatrix' package provides basic functionalities to generate, handle, and manipulate knowledge structures and knowledge spaces. Opposed to the 'kst' package, 'kstMatrix' uses matrix representations for knowledge structures. Furthermore, 'kstMatrix' contains several knowledge spaces developed by the research group around Cornelia Dowling through querying experts. |
| Authors: | Cord Hockemeyer [aut, cre], Peter Steiner [aut], Wai Wong [aut] |
| Maintainer: | Cord Hockemeyer <[email protected]> |
| License: | GPL-3 |
| Version: | 2.3-2 |
| Built: | 2026-05-26 06:16:55 UTC |
| Source: | https://github.com/cran/kstMatrix |
Bases of knowledge spaces on AutoCAD knowledge obtained from querying experts.
cadcad
A list containing seven bases (cad1 to cad6, and cadmaj) in binary matrix form. Each matrix has 28 columns representing the different knowledge items and a varying number of rows containing the basis elements.
Six experts were queried about prerequisite relationships between 28 AutoCAD knowledge items (Dowling, 1991; 1993). A seventh basis represents those prerequisite relationships on which the majority (4 out of 6) of the experts agree (Dowling & Hockemeyer, 1998).
Dowling, C. E. (1991). Constructing Knowledge Structures from the Judgements of Experts. Habilitationsschrift, Technische Universität Carolo-Wilhelmina, Braunschweig, Germany.
Dowling, C. E. (1993). Applying the basis of a knowledge space for controlling the questioning of an expert. Journal of Mathematical Psychology, 37, 21–48.
Dowling, C. E. & Hockemeyer, C. (1998). Computing the intersection of knowledge spaces using only their basis. In Cornelia E. Dowling, Fred S. Roberts, & Peter Theuns, editors, Recent Progress in Mathematical Psychology, pp. 133–141. Lawrence Erlbaum Associates Ltd., Mahwah, NJ.
Other Data:
fractions,
phsg,
readwrite,
xpl
Bases of knowledge spaces on fractions obtained from querying experts.
fractionsfractions
A list containing four bases (frac1 to frac3, and fracmaj) in binary matrix form. Each matrix has 77 columns representing the different knowledge items and a varying number of rows containing the basis elements.
Three experts were queried about prerequisite relationships between 77 items on fractions (Baumunk & Dowling, 1997). A forth basis represents those prerequisite relationships on which the majority of the experts agree (Dowling & Hockemeyer, 1998).
Baumunk, K. & Dowling, C. E. (1997). Validity of spaces for assessing knowledge about fractions. Journal of Mathematical Psychology, 41, 99–105.
Dowling, C. E. & Hockemeyer, C. (1998). Computing the intersection of knowledge spaces using only their basis. In Cornelia E. Dowling, Fred S. Roberts, & Peter Theuns, editors, Recent Progress in Mathematical Psychology, pp. 133–141. Lawrence Erlbaum Associates Ltd., Mahwah, NJ.
Other Data:
cad,
phsg,
readwrite,
xpl
kmassess performs a probabilistic knowledge assessment for a given
response vector, knowledge structure, and BLIM parameters.
kmsassess performs a simplified probabilistic knowledge assessment
for a given response vector, knowledge structure, and BLIM parameters. It
assumes an equal probability distribution over the knowledge structure
as starting point and identical beta and eta values for all items.
kmassess( r, pks, questioning, update, beta, eta, zeta0, zeta1, threshold, probdev = FALSE, directory = tempdir() ) kmsassess( r, ks, questioning, update, beta, eta, zeta0, zeta1, threshold, probdev = FALSE, directory = NULL )kmassess( r, pks, questioning, update, beta, eta, zeta0, zeta1, threshold, probdev = FALSE, directory = tempdir() ) kmsassess( r, ks, questioning, update, beta, eta, zeta0, zeta1, threshold, probdev = FALSE, directory = NULL )
r |
Response pattern (binary vector) |
pks |
Probabilistic knowledge structure: a data frame with a probability distribution in the first columns and the structure matrix in the subsequent columns. |
questioning |
Questioning rule ("halfsplit" o "informative") |
update |
Update rule ("Bayesian" or "multiplicative") |
beta |
Careless error probability |
eta |
Lucky guess probability |
zeta0 |
Update parameter for wrong responses |
zeta1 |
Update parameter for correct responses |
threshold |
Probability threshold for stopping criterion |
probdev |
Provide information on the probability development
including Hasse diagrams stored in |
directory |
Where to store the Hasse diagrams. |
ks |
Knowledge structure: a binary matrix |
kmassess implements the stochastic assessment procedures according
to Doignon & Falmagne, 1999, chapter 10.
kmassess stops if the number of questions has reached twice the
number of items.
A list with the following elements:
Diagnosed knowledge state (binary vector)
Resulting probability distribution. If probdev is set to TRUE, a list of probability distributions for each step is given instead.
Sequence of items used in the assessment (list)
Average time for finding a question
Average time for updating the probabilities
A list with the following elements:
Diagnosed knowledge state (binary vector)
Resulting probability distribution. If probdev is set to TRUE, a list of probability distributions for each step is given instead.
Sequence of items used in the assessment (list)
Average time for finding a question
Average time for updating the probabilities
Doignon & Falmagne (1985, 1999) proposed knowledge space theory originally with adaptive knowledge assessment in mind. The basic idea is to apply prerequisite relationships between items for reducing the number of problems to be posed to a learner in knowledge assessment.
Falmagne & Doignon (1988; Doignon & Falmange, 1999, chapte 10) proposed a class of stochastic procdures for such adaptive assessment which take into account that careless errors and lucky guesses may happen during the assessment by estimating a probability distribution over the knowledge structure. Such an assessment consists of three important parts
Question rule
Update rule
Stopping criterion
For the question rule, they propose the halfsplit and the infomrative
rules, implemented in kmassesshalfslit and kmassessinfomrative.
For the update rule, they again propose two possibilities there the
multiplicative rule is a generalisation of the (classical) Bayesian
update rule implemented here in kmassessmultiplicative and
kmassessbayesian, respectively.
As stopping criterion, usually a threshold for the maximal probability for one knowledge state is used. It is strongly recommended to keep this larger than 0.5 in order to have one unequivocal resulting state (see also Hockemeyer, 2002).
The founding stones are the four aforementioned functions for finding suitable questions and for updating the probability estimates, respectively. They could also be used in an interactive system, e.g. a Shiny app, for "real" adaptive assessment.
The remaining three assessment functions serve for mere simulation of
adaptive assessment. kmassess takes, among others, a full response
pattern as parameter and takes the responses for the selected questions
from this vector. kmsassess is a simplified version where the
update parameters (beta and eta for Bayesian or zeta0 and zeta1 for
multiplicative update, respectively) are identical for all items whereas
they are item-specific in kmassess. Finally,
kmassesssimulation takes a whole data set, i.e. a collection of
response patterns, and does an assessment for each of these patterns. Its
result is a data frame which should be suitable for further statistical
evaluation, especially if it is called several times with variant
parameters (e.g., structures, update parameters, update and question rules).
Both, kmsassess and kmassesssimulation call kmassess.
In rare cases kmassess may flip forth and back between probability
distributions resulting in an endless loop. Therefore, it stops after
twice the number of items delivering a NULL result.
Doignon, J.-P. & Falmagne, J.-C. (1985). Spaces for the assessment of knowledge. International Journal of Man-Machne-Studies, 23, 175-196. doi:10.1016/S0020-7373(85)80031-6.
Doignon, J.-P. & Falmagne, J.-C. (1999). Knowledge Spaces. Springer Verlag, Berlin. doi:10.1007/978-3-642-58625-5.
Falmagne, J.-C. & Doignon, J.-P. (1988). A class of stochastic procedures for the assessment of knowledge. British Journal of Mathematical and Statistical Psychology, 41, 1-23. doi:10.1111/j.2044-8317.1988.tb00884.x.
Hoxkemeyer, C. (2002). A comparison of non-deterministic procedures for the adaptive assessment of knowledge. Psychlogische Beiträge, 44(4), 495-503.
Other Knowledge assessment:
kmassessbayesian(),
kmassesshalfsplit(),
kmassessinformative(),
kmassessmentsimulation(),
kmassessmultiplicative()
Other Knowledge assessment:
kmassessbayesian(),
kmassesshalfsplit(),
kmassessinformative(),
kmassessmentsimulation(),
kmassessmultiplicative()
kmassess(c(1, 1, 0, 0), cbind(as.data.frame(as.matrix(rep(1/9.0, 9), ncol=1)), xpl$space), "halfsplit", "Bayesian", rep(0.12, 4), rep(0.1, 4), NULL, NULL, 0.55 ) kmsassess(c(1,1,0,0), xpl$space, "halfsplit", "Bayesian", 0.1, 0.1, NULL, NULL, 0.55)kmassess(c(1, 1, 0, 0), cbind(as.data.frame(as.matrix(rep(1/9.0, 9), ncol=1)), xpl$space), "halfsplit", "Bayesian", rep(0.12, 4), rep(0.1, 4), NULL, NULL, 0.55 ) kmsassess(c(1,1,0,0), xpl$space, "halfsplit", "Bayesian", 0.1, 0.1, NULL, NULL, 0.55)
kmassessbayesian updates a probability distribution over a
knowledge structure according to the Bayesian update rule.
kmassessbayesian(probs, ks, beta, eta, question, response)kmassessbayesian(probs, ks, beta, eta, question, response)
probs |
Probability distribution over the knowledge structure (vector) |
ks |
Binary matrix of the knowledge structure |
beta |
Vector of careless error probabilities |
eta |
Vector of lucky guess probabilities |
question |
Item that has been posed |
response |
Correctness of received response (0 or 1) |
Updated probability vector
Other Knowledge assessment:
kmassess(),
kmassesshalfsplit(),
kmassessinformative(),
kmassessmentsimulation(),
kmassessmultiplicative()
kmassessbayesian(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, rep(0.2,4), rep(0.1,4), 3, 1 )kmassessbayesian(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, rep(0.2,4), rep(0.1,4), 3, 1 )
kmassesshalfsplit determines the next question in a probabilistic
assessment according to the halfsplit rule.
kmassesshalfsplit(probs, ks)kmassesshalfsplit(probs, ks)
probs |
Probability distribution over the knowledge structure (vector) |
ks |
Binary matrix of the knowledge structure |
Number of the selected question
Other Knowledge assessment:
kmassess(),
kmassessbayesian(),
kmassessinformative(),
kmassessmentsimulation(),
kmassessmultiplicative()
kmassesshalfsplit(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space)kmassesshalfsplit(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space)
kmassessinfmrative determines the next question in a probabiliststic
assessment according to the informative rule.
kmassessinformative(probs, ks, update, beta, eta, zeta0, zeta1)kmassessinformative(probs, ks, update, beta, eta, zeta0, zeta1)
probs |
Probability distribution over the knowledge structure (vector) |
ks |
Binary matrix of the knowledge structure |
update |
Update rule ("Bayesian" or "multiplicative") |
beta |
Careless error probabilities (vector) |
eta |
Lucky guess probabilities (vector) |
zeta0 |
Vector of update parameters for wrong responses |
zeta1 |
Vector of update parameters for correct responses |
Number of the selected question
Other Knowledge assessment:
kmassess(),
kmassessbayesian(),
kmassesshalfsplit(),
kmassessmentsimulation(),
kmassessmultiplicative()
kmassessinformative(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, "Bayesian", rep(0.3,4), rep(0.2,4), NULL, NULL )kmassessinformative(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, "Bayesian", rep(0.3,4), rep(0.2,4), NULL, NULL )
kmassessmentsimulation does a probabilistic knowledge assessment
for each response pattern in a data matrix and stores information about
the assessment.
kmassessmentsimulation( respdata, ks, questioning, update, beta, eta, zeta0, zeta1, threshold )kmassessmentsimulation( respdata, ks, questioning, update, beta, eta, zeta0, zeta1, threshold )
respdata |
Data matrix |
ks |
Knowledge structure |
questioning |
Question rule |
update |
Updating rule |
beta |
Careless error probability |
eta |
Lucky guess probability |
zeta0 |
Update parameter for wrong responses |
zeta1 |
Update parameter for correct responses |
threshold |
Stopping criterion |
kmassessmentsimulation applies the kmsassess function.
Assessment data as data frame
Other Knowledge assessment:
kmassess(),
kmassessbayesian(),
kmassesshalfsplit(),
kmassessinformative(),
kmassessmultiplicative()
kmassessmentsimulation( xpl$data, xpl$space, "halfsplit", "multiplicative", NULL, NULL, 5, 5, 0.55 )kmassessmentsimulation( xpl$data, xpl$space, "halfsplit", "multiplicative", NULL, NULL, 5, 5, 0.55 )
kmassessmultiplicative updates a probability distribution on a
knowledge structure according to the multiplicative rule.
kmassessmultiplicative(probs, ks, zeta0, zeta1, question, response)kmassessmultiplicative(probs, ks, zeta0, zeta1, question, response)
probs |
Probability distribution over the knowledge structure (vector) |
ks |
Binary matrix of the knowledge structure |
zeta0 |
Vector of update parameters for wrong responses |
zeta1 |
Vector of update parameters for correct responses |
question |
Item that has been posed |
response |
Correctness of received response (0 or 1) |
Updated probability vector
Other Knowledge assessment:
kmassess(),
kmassessbayesian(),
kmassesshalfsplit(),
kmassessinformative(),
kmassessmentsimulation()
kmassessmultiplicative(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, rep(1.2,4), rep(2.1,4), 3, 1 )kmassessmultiplicative(c(0.02, 0.1, 0.07, 0.01, 0.4, 0.17, 0.07, 0.08, 0.08), xpl$space, rep(1.2,4), rep(2.1,4), 3, 1 )
kmbasis.matrix returns a matrix representing the basis of a
knowledge space. If x is a knowledge structure or an
arbitrary family of sets kmbasis returns the basis of
the smallest knowledge space containing x.
kmbasis.kmsurmiserelation takes a surmise relation and returns the
corresponding basis.
kmbasis.matrix returns a matrix representing the basis of a
knowledge space. If x is a knowledge structure or an
arbitrary family of sets kmbasis returns the basis of
the smallest knowledge space containing x.
kmbasis(x) ## S3 method for class 'kmsurmisefunction' kmbasis(x) ## S3 method for class 'kmsurmiserelation' kmbasis(x) ## S3 method for class 'matrix' kmbasis(x)kmbasis(x) ## S3 method for class 'kmsurmisefunction' kmbasis(x) ## S3 method for class 'kmsurmiserelation' kmbasis(x) ## S3 method for class 'matrix' kmbasis(x)
x |
Binary matrix representing a knowledge space |
Binary matrix representing the basis of the knowledge space.
Basis
Basis
Binary matrix representing the basis of the knowledge space.
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
kmbasis(xpl$space) kmbasis(xpl$space)kmbasis(xpl$space) kmbasis(xpl$space)
kmbasisfringe computes the fringe of a state
within a knowledge structure, i.e. the set of items by which
the state differs from its neighbours.
kmbasisfringe(state, basis) kmbasisinnerfringe(state, basis) kmbasisouterfringe(state, basis)kmbasisfringe(state, basis) kmbasisinnerfringe(state, basis) kmbasisouterfringe(state, basis)
state |
Binary vector representing a knowledge state |
basis |
|
Binary vector representing the fringe
Hockemeyer C (1997). Using the Basis of a Knowledge Space for Determining the Fringe of a Knowledge State. Journal of Mathematical Psychology, 41, 275–279.
Other Fringes & learning paths:
kmbasisneighbourhood(),
kmfringe(),
kmgradations(),
kmlearningpaths(),
kmneighbourhood(),
kmnneighbourhood()
kmbasisfringe(c(1,0,0,0), xpl$basis)kmbasisfringe(c(1,0,0,0), xpl$basis)
kmbasisneighbourhood computes the neighbourhood of a state
within a knowledge structure, i.e. the family of all other
states with a symmetric set difference of 1.
kmbasisneighbourhood(state, basis, include = FALSE)kmbasisneighbourhood(state, basis, include = FALSE)
state |
Binary vector representing a knowledge state |
basis |
|
include |
Boolean whether the original state should be included in the result (default FALSE) |
Matrix containing the neighbouring states, one per row
Other Fringes & learning paths:
kmbasisfringe(),
kmfringe(),
kmgradations(),
kmlearningpaths(),
kmneighbourhood(),
kmnneighbourhood()
kmbasisneighbourhood(c(1,1,0,0), xpl$basis)kmbasisneighbourhood(c(1,1,0,0), xpl$basis)
kmcolors takes a probabilty vector and a color palette and
creates a color vector to be used with kstMatrix::plot.
kmcolors(prob, palette = cm.colors)kmcolors(prob, palette = cm.colors)
prob |
Probability vector |
palette |
Color palette (default = cm.colors) |
Other Plotting knowledge structures:
plot()
Other Utilities:
kmdoubleequal(),
kmsetiselement(),
kmsymmsetdiff()
kmdist returns a named vector with the frequencies of distances
between a set of response patterns and a knowledge structure. This vector
can be used to compute, e.g., the Discrepancy Index (DI) or the
Distance Agreement Coefficient (DA).
kmdist(data, struct)kmdist(data, struct)
data |
Binary matrix representing a set of response patterns |
struct |
Binary matrix representing a knowledge structure |
Distance distribution vector
Other Validating knowledge spaces:
kmSRvalidate(),
kmvalidate()
kmdist(xpl$data, xpl$space)kmdist(xpl$data, xpl$space)
Test two double numbers on equity with a certain tolerance
kmdoubleequal(x, y, tol = sqrt(.Machine$double.eps))kmdoubleequal(x, y, tol = sqrt(.Machine$double.eps))
x |
First double to compare |
y |
Second double to compare |
tol |
Tolerance optional) |
Boolean for (approximate) equity
Other Utilities:
kmcolors(),
kmsetiselement(),
kmsymmsetdiff()
kmdoubleequal(0.5+0.5, 1)kmdoubleequal(0.5+0.5, 1)
kmeqreduction takes a family of knowledge states and returns its
reduction to non-equivalent items.
kmeqreduction(x)kmeqreduction(x)
x |
Binary matrix |
Binary matrix reduced by equivalences
Other Properties of knowledge structures:
kmiswellgraded(),
kmnotions()
kmeqreduction(xpl$space)kmeqreduction(xpl$space)
kmfamset object (family of sets)kmfamset returns a kmfamset object after checking that
the passed object is a binary matrix with all different rows. If the
passe object inherits the kmfamset property, nothing else is
changed.
kmfamset(x)kmfamset(x)
x |
Binary matrix representing a family of sets |
kmfamset object
Other Constructors:
kmspace(),
kmstructure()
m <- as.matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmfamset(m)m <- as.matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmfamset(m)
kmfringe computes the fringe of a state
within a knowledge structure, i.e. the set of items by which
the state differs from its neighbours.
kmfringe(state, struct) kminnerfringe(state, struct) kmouterfringe(state, struct)kmfringe(state, struct) kminnerfringe(state, struct) kmouterfringe(state, struct)
state |
Binary vector representing a knowledge state |
struct |
Binary matrix representing a knowledge structure |
Binary vector representing the fringe
Other Fringes & learning paths:
kmbasisfringe(),
kmbasisneighbourhood(),
kmgradations(),
kmlearningpaths(),
kmneighbourhood(),
kmnneighbourhood()
kmfringe(c(1,0,0,0), xpl$space)kmfringe(c(1,0,0,0), xpl$space)
kmgenerate returns a matrix representing a knowledge structure generated
from data. It uses a simplistic approach: patterns with a frequency above a
specified threshold are considered as knowledge states.
If the specified threshold is 0 (default) a real threshold is computed as
N (number of response patterns) divided by 2^|Q|.
Please note that the number of response patterns should be much higher than the
size of the power set of the item set Q. A factor of art least 10 is recommended.
Currently, the number of items is limited to the number of bits in a C long
minus one (i.e. 31 under Windows and 63 otherwise). But we would probably run into
memory problems way earlier anyway.
kmgenerate(x, threshold = 0)kmgenerate(x, threshold = 0)
x |
Binary matrix representing a data set |
threshold |
Threshold for taking response patterns as knowledge states (default 0) |
Binary matrix representing the generated knowledge structure
Other Generating knowledge spaces:
kmiita2SR()
kmgenerate(xpl$sim, 15)kmgenerate(xpl$sim, 15)
Determine all gradations between two states
kmgradations(structure, from = NULL, to = NULL)kmgradations(structure, from = NULL, to = NULL)
structure |
Knowledge structure |
from |
Starting state (if NULL (default), it is the empty set) |
to |
Goal state (if NULL (default), it is the full item set) |
A list of gradations where each gradation is a list of states
Other Fringes & learning paths:
kmbasisfringe(),
kmbasisneighbourhood(),
kmfringe(),
kmlearningpaths(),
kmneighbourhood(),
kmnneighbourhood()
kmgradations(xpl$space)kmgradations(xpl$space)
kmiita2SR takes the result of a DAKS::iita() call and
delivers the matrix of the computed surmise relation.
kmiita2SR(ii, names = NULL, items = 0)kmiita2SR(ii, names = NULL, items = 0)
ii |
|
names |
Vector of item names (default NULL) |
items |
Minimal number of items (default 0) |
Surmise relation matrix
The iita() function looses information on the item names and
uses consecutive numbers instead. The implications part of its
result does not give any hint on isolated items, i.e. items which#
neither have a prerequisite nor are prerequisite of any other item.
Therefore, a minimal number of items can be passed to
kmiita2SR(). If the highest item number within
implications is higher, this items parameter is ignored.
Other Generating knowledge spaces:
kmgenerate()
kmiswellgraded returns whether a knowledge structure is wellgraded.
kmiswellgraded(x)kmiswellgraded(x)
x |
Binary matrix representing a knowledge space |
Logical value specifying whether x is wellgraded
Doignon, J.-P. & Falmagne, J.-C. (1999). Knowledge Spaces. Springer–Verlag, Berlin.
Other Properties of knowledge structures:
kmeqreduction(),
kmnotions()
kmiswellgraded(xpl$space)kmiswellgraded(xpl$space)
Determine all learning paths in a knowledge structure
kmlearningpaths(structure)kmlearningpaths(structure)
structure |
Knowledge structure |
A list of learning paths where each learning path is a list of states
Other Fringes & learning paths:
kmbasisfringe(),
kmbasisneighbourhood(),
kmfringe(),
kmgradations(),
kmneighbourhood(),
kmnneighbourhood()
kmlearningpaths(xpl$space)kmlearningpaths(xpl$space)
kmneighbourhood computes the neighbourhood of a state
within a knowledge structure, i.e. the family of all other
states with a symmetric set difference of 1.
kmneighbourhood(state, struct, include = FALSE)kmneighbourhood(state, struct, include = FALSE)
state |
Binary vector representing a knowledge state |
struct |
Binary matrix representing a knowledge structure |
include |
Boolean whether the original state should be included in the result (default FALSE) |
Matrix containing the neighbouring states, one per row
Other Fringes & learning paths:
kmbasisfringe(),
kmbasisneighbourhood(),
kmfringe(),
kmgradations(),
kmlearningpaths(),
kmnneighbourhood()
kmneighbourhood(c(1,1,0,0), xpl$space)kmneighbourhood(c(1,1,0,0), xpl$space)
kmnneighbourhood computes the n-neighbourhood of a state
within a knowledge structure, i.e. the family of all other
states with a symmetric set difference maximal n.
kmnneighbourhood(state, struct, distance, include = FALSE)kmnneighbourhood(state, struct, distance, include = FALSE)
state |
Binary vector representing a knowledge state |
struct |
Binary matrix representing a knowledge structure |
distance |
Size of the n-neighbourhood |
include |
Boolean whether the original state should be included (defaul FALSE) |
Matrix containing the neighbouring states, one per row
Other Fringes & learning paths:
kmbasisfringe(),
kmbasisneighbourhood(),
kmfringe(),
kmgradations(),
kmlearningpaths(),
kmneighbourhood()
kmnneighbourhood(c(1,1,0,0), xpl$space, 2)kmnneighbourhood(c(1,1,0,0), xpl$space, 2)
kmnotions returns a matrix representing the
notions of a knowledge structure.
kmnotions(x)kmnotions(x)
x |
Binary matrix representing a knowledge structure |
Binary matrix representing notions in the knowledge structure
The matrix has a '1' in row 'i' and column 'j' if 'i' and 'j' belong to the same notion (i.e. are equivalent). It is a symmetric matrix with '1's in the main diagonal.
Other Properties of knowledge structures:
kmeqreduction(),
kmiswellgraded()
kmnotions(xpl$space)kmnotions(xpl$space)
Test if a state is contained in a family of states
kmsetiselement(s, f)kmsetiselement(s, f)
s |
State |
f |
Family of sets |
Boolean is s is contained in f
Other Utilities:
kmcolors(),
kmdoubleequal(),
kmsymmsetdiff()
kmsetiselement(c(1,1,1,0), xpl$space)kmsetiselement(c(1,1,1,0), xpl$space)
kmSF2basis expects a surmise function data frame
and returns the corresponding basis.
kmSF2basis(sf)kmSF2basis(sf)
sf |
Surmise function |
Matrix representing the basis.
Other Different representations for knowledge spaces:
kmSR2basis(),
kmbasis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
kmsimulate returns a data set of n simulated response patterns based
on the knowledge structure x given as a binary matrix. The simulation follows
the BLIM (Basic Local Independence Model; see Doigon & Falmagne, 1999).
kmsimulate(x, n, beta, eta)kmsimulate(x, n, beta, eta)
x |
Binary matrix representing a knowledge space |
n |
Number of simulated response patterns |
beta |
Careless error probability value or vector |
eta |
Lucky guess probability value or vector |
The beta and eta parameters must be either single numericals
or vectors with a length identical to the number of rows in the x matrix.
A mixture is possible.
The sample function used by kmsimulate might work inaccurately for knowledge
structures x with 2^31 or more states.
Binary matrix representing the simulated data set
Doignon, J.-P. & Falmagne, J.-C. (1999). Knowledge Spaces. Springer–Verlag, Berlin.
kmsimulate(xpl$space, 50, 0.2, 0.1) kmsimulate(xpl$space, 50, c(0.2, 0.25, 0.15, 0.2), c(0.1, 0.15, 0.05, 0.1)) kmsimulate(xpl$space, 50, c(0.2, 0.25, 0.15, 0.2), 0)kmsimulate(xpl$space, 50, 0.2, 0.1) kmsimulate(xpl$space, 50, c(0.2, 0.25, 0.15, 0.2), c(0.1, 0.15, 0.05, 0.1)) kmsimulate(xpl$space, 50, c(0.2, 0.25, 0.15, 0.2), 0)
kmspace objectkmspace() returns a kmspace object for a binary matrix.
kmspace(x)kmspace(x)
x |
Binary matrix representing a family of sets |
kmspace object
Other Constructors:
kmfamset(),
kmstructure()
m <- matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmspace(m)m <- matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmspace(m)
kmSR2basis takes a surmise relation and returns the
corresponding basis.
kmSR2basis(sr)kmSR2basis(sr)
sr |
Surmise relation |
Basis
Other Different representations for knowledge spaces:
kmSF2basis(),
kmbasis(),
kmsurmisefunction(),
kmsurmiserelation(),
kmunionclosure()
kmSRvalidate returns a list with two elements,
Goodman & Kruskal's gamma value and the violational
coefficient (VC).
kmSRvalidate(data, sr)kmSRvalidate(data, sr)
data |
Binary matrix representing a set of response patterns |
sr |
Binary matrix representing a surmise relation |
A list with two elements:
Goodman & Kruskal's gamma index
Violational Coefficient
Other Validating knowledge spaces:
kmdist(),
kmvalidate()
kmSRvalidate(xpl$data, xpl$sr)kmSRvalidate(xpl$data, xpl$sr)
kmstructure objectkmstructure() returns a kmstructure object after checking that
the passed object is a binary matrix without double rows. The empty set
and the full item set are added if missing.
kmstructure(x)kmstructure(x)
x |
Binary matrix representing a family of sets |
kmstructure object
Other Constructors:
kmfamset(),
kmspace()
m <- matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmstructure(m)m <- matrix(c(1,0,0,0,1,0,1,1,1), nrow=3, byrow=TRUE) kmstructure(m)
kmsurmisefunction returns a data frame representing the
surmise function for a knowledge space or basis. The rows of the
data frame are ordered by item name.
kmsurmisefunction(x)kmsurmisefunction(x)
x |
Binary matrix representing a knowledge space or basis |
Data frame representing the surmise unction of x.
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmbasis(),
kmsurmiserelation(),
kmunionclosure()
kmsurmisefunction(xpl$space)kmsurmisefunction(xpl$space)
kmsurmiserelation returns a matrix representing the
surmise relation of a quasi-ordinal knowledge space. If x
is a general knowledge space, a knowledge structure or an
arbitrary family of sets, kmsurmiserelation returns the
surmise relation of the smallest quasi-ordinal knowledge space
containing x.
kmsurmiserelation(x)kmsurmiserelation(x)
x |
Binary matrix representing a family of sets (class kmfamset) |
Binary matrix representing the surmise relation
Note: The columns of the surmise relation matrix describe the minimal state for the respective item in the quasi-ordinal knowledge space.
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmbasis(),
kmsurmisefunction(),
kmunionclosure()
kmsurmiserelation(xpl$space)kmsurmiserelation(xpl$space)
Compute the symmetric set difference between two sets
kmsymmsetdiff(x, y) kmsetdistance(x, y)kmsymmsetdiff(x, y) kmsetdistance(x, y)
x |
Binary vector representing a set |
y |
Binary vector representing a set |
kmsymmsetdiff: Symmetric set difference between 'x' and 'y'
kmsetdistance: Distance between the sets 'x' and 'y', i.e. the cardinality of the symmetric set difference
Other Utilities:
kmcolors(),
kmdoubleequal(),
kmsetiselement()
Other Utilities:
kmcolors(),
kmdoubleequal(),
kmsetiselement()
kmsymmsetdiff(c(1,0,0), c(1,1,0)) kmsetdistance(c(1,0,0), c(1,1,0))kmsymmsetdiff(c(1,0,0), c(1,1,0)) kmsetdistance(c(1,0,0), c(1,1,0))
These functions create trivial knowledge spaces of a given item number. The minimal space contains just the empty set and the full item set while the maximal space is equal to the power set.
kmminimalspace(noi) kmmaximalspace(noi)kmminimalspace(noi) kmmaximalspace(noi)
noi |
Number of items |
Please note that the computation time for creating large power sets can grow quite large easily.
A binary matrix representing the respective knowledge space
kmminimalspace(5) kmmaximalspace(5)kmminimalspace(5) kmmaximalspace(5)
kmunionclosure returns a matrix representing a knowledge space. Please note
that it may take quite some time for computing larger knowledge spaces.
kmunionclosure(x) ## S3 method for class 'kmdata' kmunionclosure(x) ## S3 method for class 'kmfamset' kmunionclosure(x) ## S3 method for class 'kmstructure' kmunionclosure(x)kmunionclosure(x) ## S3 method for class 'kmdata' kmunionclosure(x) ## S3 method for class 'kmfamset' kmunionclosure(x) ## S3 method for class 'kmstructure' kmunionclosure(x)
x |
Binary matrix representing a family of sets |
Binary matrix representing the corresponding knowledge space, i.e. the closure of the family under union including the empty set and the full set.
kmunionclosure implements the irredundant algorithm developed by Dowling (1993).
Dowling, C. E. (1993). On the irredundant construction of knowledge spaces. Journal of Mathematical Psychology, 37, 49–62.
Other Different representations for knowledge spaces:
kmSF2basis(),
kmSR2basis(),
kmbasis(),
kmsurmisefunction(),
kmsurmiserelation()
kmunionclosure(xpl$basis)kmunionclosure(xpl$basis)
kmvalidate returns a list with three elements,
a named vector (dist) with the frequencies of distances
between a set of response patterns and a knowledge structure, the
Discrepancy Index (DI), and the Distance Agreement Coefficient (DA).
kmvalidate(data, struct)kmvalidate(data, struct)
data |
Binary matrix representing a set of response patterns |
struct |
Binary matrix representing a knowledge structure |
A list with three elements:
Distance distribution vector
Discrepancy Index
Distance Agreement Coefficient
The DA computation can take quite some time for larger item sets as the power set has to be computed. For item sets with around 30 items or more, it may even crash the system due to huge memory requests.
Other Validating knowledge spaces:
kmSRvalidate(),
kmdist()
kmvalidate(xpl$data, xpl$space)kmvalidate(xpl$data, xpl$space)
Basis of a small knowledge space and list of items on linear functions used in a manuscript by Steiner et al.
phsgphsg
A list containing the basis and the list of items
Other Data:
cad,
fractions,
readwrite,
xpl
plot draws a Hasse diagram for a family of sets or a surmise relation.
## S3 method for class 'kmfamset' plot( x, ..., horizontal = FALSE, colors = NULL, keepNames = TRUE, itemsep = ",", braces = TRUE, vertexshape = "oval", arrowhead = "none", arrowtail = "none", edgelabel = FALSE, verbose = 0 ) ## S3 method for class 'kmneighbourhood' plot( x, ..., horizontal = FALSE, colors = c("#eeee00", "#aaccff", "#bbffbb"), keepNames = TRUE, itemsep = ",", braces = TRUE, vertexshape = "oval", arrowhead = "none", arrowtail = "none", edgelabel = FALSE, state, verbose = 0 ) ## S3 method for class 'kmsurmiserelation' plot( x, ..., horizontal = FALSE, colors = NULL, keepNames = TRUE, vertexshape = "circle", arrowhead = "none", arrowtail = "none", verbose = 0 )## S3 method for class 'kmfamset' plot( x, ..., horizontal = FALSE, colors = NULL, keepNames = TRUE, itemsep = ",", braces = TRUE, vertexshape = "oval", arrowhead = "none", arrowtail = "none", edgelabel = FALSE, verbose = 0 ) ## S3 method for class 'kmneighbourhood' plot( x, ..., horizontal = FALSE, colors = c("#eeee00", "#aaccff", "#bbffbb"), keepNames = TRUE, itemsep = ",", braces = TRUE, vertexshape = "oval", arrowhead = "none", arrowtail = "none", edgelabel = FALSE, state, verbose = 0 ) ## S3 method for class 'kmsurmiserelation' plot( x, ..., horizontal = FALSE, colors = NULL, keepNames = TRUE, vertexshape = "circle", arrowhead = "none", arrowtail = "none", verbose = 0 )
x |
Binary matrix representing a family of sets |
... |
Optional inherited parameters |
horizontal |
Boolean defining orientation of the graph, default FALSE |
colors |
Color value or vector (default NULL). |
keepNames |
Keep item names (default TRUE) |
itemsep |
Item separator in sets (default ','; only for families of states) |
braces |
Put braces around vertices (default TRUE; only for families of states) |
vertexshape |
Shape of the vertex objects, e.g. circle, oval, box, or none. See Graphviz Node Shapes for a complete list of possible values. |
arrowhead |
Form of the arrow head, e.g. vee or none (default). See Graphviz Arrow Types for a complete list of possible values. This may be used for vertical graphs although none is the standard there. |
arrowtail |
Form of the arrow tail, e.g. vee or none (default). See Graphviz Arrow Types for a complete list of possible values. This should be used for horizontal graphs. |
edgelabel |
Boolean whether to label the edges of the diagram (default FALSE) |
verbose |
Verbosity level (0 (default), 1, or 2) |
state |
Knowledge state whose neighbourhood is to be pictured |
plot takes a matrix representing a family of sets (knowledge states)
or a surmise relation and a color vector, and draws a Hasse diagram.
If the color vector is NULL the states are drawn in green, the items in
the relation are drawn in orange.
For a surmise relation, if there are equivalent items, they are contracted into one vertex labelled 'a ~ b ~ ...' for equivalent items a, b, ...
If the plot is to be used within a Shiny app, it must be included with
grVizOutput() and renderGrViz() from the DiagrammeR
package (plotOutput() and renderPlot() do not work).
Please note that, for equivalent items in a relation plot, the prerequisites are lost.
Other Plotting knowledge structures:
kmcolors()
plot(phsg$basis) sp <- kmunionclosure(phsg$basis) n <- kmneighbourhood(phsg$basis[3,], sp, include=TRUE) plot(n, state=phsg$basis[3,]) m <- matrix(c(1,0,0,1,1,1,1,1,1), ncol=3, byrow=FALSE) class(m) <- unique(c("kmsurmiserelation", class(m))) plot(m, vertexshape="oval")plot(phsg$basis) sp <- kmunionclosure(phsg$basis) n <- kmneighbourhood(phsg$basis[3,], sp, include=TRUE) plot(n, state=phsg$basis[3,]) m <- matrix(c(1,0,0,1,1,1,1,1,1), ncol=3, byrow=FALSE) class(m) <- unique(c("kmsurmiserelation", class(m))) plot(m, vertexshape="oval")
Bases of knowledge spaces on reading/writing abilities obtained from querying experts.
readwritereadwrite
A list containing four bases (rw1 to rw3, and rwmaj) in binary matrix form. Each matrix has 48 columns representing the different knowledge items and a varying number of rows containing the basis elements.
Three experts were queried about prerequisite relationships between 48 items on reading and writing abilities (Dowling, 1991; 1993). A forth basis represents those prerequisite relationships on which the majority of the experts agree (Dowling & Hockemeyer, 1998).
Dowling, C. E. (1991). Constructing Knowledge Structures from the Judgements of Experts. Habilitationsschrift, Technische Universität Carolo-Wilhelmina, Braunschweig, Germany.
Dowling, C. E. (1993). Applying the basis of a knowledge space for controlling the questioning of an expert. Journal of Mathematical Psychology, 37, 21–48.
Dowling, C. E. & Hockemeyer, C. (1998). Computing the intersection of knowledge spaces using only their basis. In Cornelia E. Dowling, Fred S. Roberts, & Peter Theuns, editors, Recent Progress in Mathematical Psychology, pp. 133–141. Lawrence Erlbaum Associates Ltd., Mahwah, NJ.
Other Data:
cad,
fractions,
phsg,
xpl
Basis and space matrix, surmise relation and surmise function of a small
fictional knowledge space, and two data sets (data (7 patterns) and
sim (500 patterns)to be used in examples. The latter was produced from
the space with kmsimulate() with beta and eta values of 0.1.
xplxpl
A list containing the basis, the space, the surmise relation, the surmise function, and the two data matrices data and sim.
Other Data:
cad,
fractions,
phsg,
readwrite