[Asrr-commits] r4 - pkg/man www
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 12 18:06:23 CET 2009
Author: wincent
Date: 2009-01-12 18:06:23 +0100 (Mon, 12 Jan 2009)
New Revision: 4
Modified:
pkg/man/cs_truthTable.rd
pkg/man/student.Rd
www/index.html
Log:
documentation of cs_truthTable
Modified: pkg/man/cs_truthTable.rd
===================================================================
--- pkg/man/cs_truthTable.rd 2009-01-11 18:04:15 UTC (rev 3)
+++ pkg/man/cs_truthTable.rd 2009-01-12 17:06:23 UTC (rev 4)
@@ -4,162 +4,87 @@
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Construct a truthTable for csQCA or mvQCA}
\description{
- ~~ A concise (1-5 lines) description of what the function does. ~~
+ Construct a truthTable for csQCA and mvQCA. Both deterministic and
+ probabilistic methods of determining configurations of positive,
+ negative and contraditory outcome are implemented.
}
\usage{
-cs_truthTable(mydata, outcome, conditions, method = c("deterministic", "probabilistic"), complete = FALSE, weight = NULL, show.cases = TRUE, cases = NULL, nlevels = rep(2, length(conditions)), cutoff1 = 1, cutoff0 = 1, benchmark = 0.65, conf.level = 0.95)
+cs_truthTable(mydata, outcome, conditions,
+method = c("deterministic","probabilistic"),
+complete = FALSE, weight = NULL, show.cases = TRUE,
+cases = NULL, nlevels = rep(2, length(conditions)),
+cutoff1 = 1, cutoff0 = 1, benchmark = 0.65, conf.level = 0.95)
}
-%- maybe also 'usage' for other objects documented here.
\arguments{
- \item{mydata}{ ~~Describe \code{mydata} here~~ }
- \item{outcome}{ ~~Describe \code{outcome} here~~ }
- \item{conditions}{ ~~Describe \code{conditions} here~~ }
- \item{method}{ ~~Describe \code{method} here~~ }
- \item{complete}{ ~~Describe \code{complete} here~~ }
- \item{weight}{ ~~Describe \code{weight} here~~ }
- \item{show.cases}{ ~~Describe \code{show.cases} here~~ }
- \item{cases}{ ~~Describe \code{cases} here~~ }
- \item{nlevels}{ ~~Describe \code{nlevels} here~~ }
- \item{cutoff1}{ ~~Describe \code{cutoff1} here~~ }
- \item{cutoff0}{ ~~Describe \code{cutoff0} here~~ }
- \item{benchmark}{ ~~Describe \code{benchmark} here~~ }
- \item{conf.level}{ ~~Describe \code{conf.level} here~~ }
+ \item{mydata}{data frame of the raw data.}
+ \item{outcome}{character, the name of the outcome variable in mydata.}
+ \item{conditions}{character vector, the name of the conditions from mydata.}
+ \item{method}{character, specifying the method of determining the
+ outcome of a configuration.}
+ \item{complete}{logical, when it is TRUE the result includes
+ configurations without empirical cases.}
+ \item{weight}{character, name of a variable specifying the weights.}
+ \item{show.cases}{logical, when TRUE the result shows case names.}
+ \item{cases}{character, variable specifying the case names. When it is
+ NUll, then use row names of mydata as case names.}
+ \item{nlevels}{a integer vector, specifying the number of levels of
+ each conditions.}
+ \item{cutoff1}{length one numeric vector.}
+ \item{cutoff0}{length one numeric vector. }
+ \item{benchmark}{Benchmark for statistical test. Must equal or greater 0.5.}
+ \item{conf.level}{confident level of statistical test.}
}
\details{
- ~~ If necessary, more details than the description above ~~
+ Symbols of the outcome. '1' is postive configuration, '0' is negative
+ configuration, 'C' is contraditory configuration, and '-' is don't
+ care configuration.
+
+ 'cutoff1' and 'cutoff0' are only meaningful for'deterministic'
+ method. They represent cutting point of positive case and negative
+ case. When a configuration has positive case only and the number of
+ cases is equal or greater than the cutting point, then it is regared as
+ positive outcome, otherwise as don't care outcome. Similarly, When a
+ configuration has negative case only and the number of cases is equal or
+ greater than the cutting point, then it is regared as negative
+ outcome, otherwise as don't care outcome. If a configuration has both
+ positive case and nagetive case, the number of each type of cases will
+ be compared with the corresponding cutting point. If only one type of
+ case have enough case (number of cases greater than cutting point),
+ that configuration is regarded as that type. If both types have enough
+ case, it is contraditory configuration. If neither type has enough
+ case, it is don't care configuration.
+
+ The caculation of cutting point: if it is equal or greater than 1, the
+ cutting point is the value of cutoff1 and cutoff0. If it is between 0
+ and 1, then the cutting point is the cutoff1/cutoff0 multiplied by the
+ total number of case.
+
+ 'benchmark' and 'conf.level' are only meaningful for 'probabilistic'
+ method. When the method is 'probabilistic', a statistical test will
+ conducted to test if the proportion of case for a configuration is
+ greater then a benchmark. If the proportion of cases with outcome '1' is
+ greater than benchmark, then the it is a configuratin with outcome
+ '1'. If the proportion of case with outcome '0' is greater than
+ benchmark, then the configuration with outcome of '0'. If neither
+ proportion fits the criterion, then it is don't care
+ configuration. There is no contraditory congfiguration in this method,
+ as it is designed to handle with contraditory configurations.
}
\value{
- ~Describe the value returned
- If it is a LIST, use
- \item{comp1 }{Description of 'comp1'}
- \item{comp2 }{Description of 'comp2'}
- ...
+A truthTable.
}
-\references{ ~put references to the literature/web site here ~ }
-\author{ ~~who you are~~ }
-\note{ ~~further notes~~
-
- ~Make other sections like Warning with \section{Warning }{....} ~
+\references{
+ Ragin, Charles. 2000. Fuzzy-Set Social Science. Pp109-116. University Of Chicago Press.
}
-\seealso{ ~~objects to See Also as \code{\link{help}}, ~~~ }
+\author{Ronggui HUANG}
+\seealso{\code{\link{fs_truthTable}}}
\examples{
-##---- Should be DIRECTLY executable !! ----
-##-- ==> Define data, use random,
-##-- or do help(data=index) for the standard data sets.
+## truthTable for csQCA
+cs_truthTable(Lipset_cs,"SURVIVAL", c("GNPCAP", "URBANIZA", "LITERACY",
+ "INDLAB", "GOVSTAB"),case="CASEID")
-## The function is currently defined as
-function (mydata, outcome, conditions, method = c("deterministic",
- "probabilistic"), complete = FALSE, weight = NULL, show.cases = TRUE,
- cases = NULL, nlevels = rep(2, length(conditions)), cutoff1 = 1,
- cutoff0 = 1, benchmark = 0.65, conf.level = 0.95)
-{
- if (outcome == "" || conditions == "")
- stop("You must specific outcome and conditions first.")
- fulldata <- mydata[, c(outcome, conditions)]
- if (any(fulldata \%in\% c(0, 1)))
- stop("data value must in [0,1].")
- outcomeData <- mydata[, outcome]
- conditionsData <- mydata[, conditions]
- if (!is.null(weight))
- weight <- mydata[[weight]]
- else weight <- rep(1, nrow(mydata))
- method <- match.arg(method)
- getId <- function(implicant, nlevels) {
- IDX <- cumprod(nlevels)/nlevels
- ans <- sum(implicant * IDX) + 1
- ans
- }
- rowid <- apply(conditionsData, 1, getId, nlevels = nlevels)
- N_total <- sum(weight, na.rm = TRUE)
- Positive <- tapply(outcomeData, rowid, FUN = function(each) all(each ==
- 1))
- Pid <- names(Positive)[Positive]
- Negative <- tapply(outcomeData, rowid, FUN = function(each) all(each ==
- 0))
- Nid <- names(Negative)[Negative]
- Contradictory <- tapply(outcomeData, rowid, FUN = function(each) {
- c1 <- (!all(each == 0)) && (!all(each == 1))
- c1
- })
- Cid <- names(Negative)[Contradictory]
- if (complete) {
- exp <- sprintf("c(0:\%i)", nlevels - 1)
- allExpress <- eval(parse(text = sprintf("expand.grid(\%s)",
- paste(conditions, "=", exp, sep = "", collapse = ","))))
- }
- else {
- WhichUnique <- match(sort(unique(rowid)), rowid)
- allExpress <- conditionsData[WhichUnique, ]
- rownames(allExpress) <- as.character(sort(unique(rowid)))
- }
- allExpress$NCase <- 0
- Ncase <- tapply(weight, rowid, sum)
- allExpress$NCase[match(names(Ncase), rownames(allExpress))] <- Ncase
- allExpress$freq0 <- allExpress$freq1 <- 0
- Ncase1 <- by(cbind(weight, outcomeData), rowid, FUN = function(idx) sum(idx[,
- 1][idx[, 2] == 1]))
- allExpress$freq1[match(names(Ncase1), rownames(allExpress))] <- Ncase1
- Ncase0 <- by(cbind(weight, outcomeData), rowid, FUN = function(idx) sum(idx[,
- 1][idx[, 2] == 0]))
- allExpress$freq0[match(names(Ncase0), rownames(allExpress))] <- Ncase0
- allExpress$OUT <- "?"
- if (method == "deterministic") {
- cutoff1 <- ifelse(cutoff1 < 1, cutoff1 * N_total, cutoff1)
- cutoff0 <- ifelse(cutoff0 < 1, cutoff0 * N_total, cutoff0)
- pidx <- intersect(match(Pid, rownames(allExpress)), which(allExpress$freq1 >=
- cutoff1))
- allExpress$OUT[pidx] <- "1"
- nidx <- intersect(match(Nid, rownames(allExpress)), which(allExpress$freq0 >=
- cutoff0))
- allExpress$OUT[nidx] <- "0"
- cidx1 <- intersect(match(Cid, rownames(allExpress)),
- which(allExpress$freq1 >= cutoff1))
- cidx0 <- intersect(match(Cid, rownames(allExpress)),
- which(allExpress$freq0 >= cutoff0))
- cidx <- intersect(cidx1, cidx0)
- allExpress$OUT[cidx] <- "C"
- Dontcare1 <- intersect(match(Cid, rownames(allExpress)),
- which(allExpress$freq1 < cutoff1))
- Dontcare0 <- intersect(match(Cid, rownames(allExpress)),
- which(allExpress$freq0 < cutoff0))
- Dontcareid <- intersect(Dontcare1, Dontcare0)
- allExpress$OUT[Dontcareid] <- "-"
- allExpress$OUT[intersect(cidx1, Dontcare0)] <- "1"
- allExpress$OUT[intersect(cidx0, Dontcare1)] <- "0"
- }
- if (method == "probabilistic") {
- limit1 <- lowerLimite(allExpress$freq1, allExpress$NCase,
- conf.level)
- limit0 <- lowerLimite(allExpress$freq0, allExpress$NCase,
- conf.level)
- pidx <- intersect(which(limit1 >= benchmark), match(c(Pid,
- Cid), rownames(allExpress)))
- nidx <- intersect(which(limit0 >= benchmark), match(c(Nid,
- Cid), rownames(allExpress)))
- Dontcareid <- setdiff(match(c(Nid, Cid, Pid), rownames(allExpress)),
- c(pidx, nidx))
- allExpress$OUT[pidx] <- "1"
- allExpress$OUT[nidx] <- "0"
- allExpress$OUT[Dontcareid] <- "-"
- }
- if (show.cases) {
- if (is.null(cases))
- casesNames <- rownames(mydata)
- else casesNames <- mydata[, cases]
- casesNames <- gsub(",", "_", casesNames)
- casesNames[outcomeData == 0] <- paste("[", casesNames[outcomeData ==
- 0], "]", sep = "")
- casesNames <- tapply(casesNames, rowid, FUN = function(each) paste(each,
- sep = "", collapse = ", "))
- allExpress$Cases <- ""
- allExpress$Cases[match(names(casesNames), rownames(allExpress))] <- casesNames
- allExpress$Cases[allExpress$OUT != "C"] <- gsub("\\[|\\]",
- "", allExpress$Cases[allExpress$OUT != "C"])
- }
- allExpress
- }
+## truthTable for mvQCA, please note the nlevels argument.
+cs_truthTable(Lipset_mv,"SURVIVAL", c("GNPCAP", "URBANIZA", "LITERACY",
+ "INDLAB"),case="CASEID",nlevels=c(3,2,2,2))
}
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ ~kwd1 }
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+%\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
Modified: pkg/man/student.Rd
===================================================================
--- pkg/man/student.Rd 2009-01-11 18:04:15 UTC (rev 3)
+++ pkg/man/student.Rd 2009-01-12 17:06:23 UTC (rev 4)
@@ -1,4 +1,4 @@
-\name{student}
+\name{Student}
\alias{student}
\docType{data}
\title{Students dataset}
@@ -46,5 +46,6 @@
\dontrun{
data(student)
}
+## see 'coefchange' for more examples
}
\keyword{datasets}
Modified: www/index.html
===================================================================
--- www/index.html 2009-01-11 18:04:15 UTC (rev 3)
+++ www/index.html 2009-01-12 17:06:23 UTC (rev 4)
@@ -26,7 +26,7 @@
<P ALIGN=CENTER><FONT COLOR="#008000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 15pt"><SPAN LANG="en-US">Welcome to ASRR Project!</SPAN></FONT></FONT></FONT></P>
<h1>What is ASRR?</h1>
-ASRR is a <A HREF="http://www.r-project.org/">R</A> package. It aims to provide Miscellaneous R functions for Applied Sociological Research. It stands for Applied Sociological Research with R. The most important set of functions is for Qulitative Comparative Analysis (QCA). It can used for all three types of QCA.You can find examples of QCA <A HREF="http://code.google.com/p/asrr/">here</A>. ASRR is released as free software under the New style <A HREF="License.html">BSD</A> license.
+ASRR is a <A HREF="http://www.r-project.org/">R</A> package. It aims to provide Miscellaneous R functions for Applied Sociological Research. It stands for Applied Sociological Research with R. The most important set of functions is for Qulitative Comparative Analysis (QCA). It can used for all three types of QCA, namely csQCA, mvQCA and fsQCA.You can find examples of QCA <A HREF="http://code.google.com/p/asrr/">here</A>. ASRR is released as free software under the New style <A HREF="License.html">BSD</A> license.
<h1>Installation</h1>
<p>Launch R, then use R command to install ASRR: <I>install.packages("ASRR",repos=" http://R-Forge.R-project.org",dependencies=TRUE)</I> .
More information about the Asrr-commits
mailing list