### Add Examples for Structural Zeros and Model Fitting Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Includes new examples: Caesar illustrating structural zeros, Heckman with renamed variables for loglm errors, Detergent, and Dyke. These examples showcase handling of specific data structures and model fitting scenarios. ```R example(Caesar) example(Heckman) example(Detergent) example(Dyke) ``` -------------------------------- ### Add GKgamma Example Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Includes an example demonstrating the usage of GKgamma, likely related to gamma statistics or specific model fitting techniques, within the vcd-tutorial. ```R example(GKgamma) ``` -------------------------------- ### R: Add GKgamma example to vcd-tutorial Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md An example demonstrating the usage of GKgamma is added to the vcd-tutorial vignette. This helps users understand and apply the GKgamma function. ```R vignette("vcd-tutorial") ``` -------------------------------- ### Kway Function Examples (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Extends the description and examples for the `Kway()` function, which is used for analyzing K-way contingency tables, offering clearer guidance on its usage and capabilities. ```R Kway(table, ...) ``` -------------------------------- ### Reformat .Rd files and extend examples Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Reformats all .Rd files and expands the examples provided within them. ```R all .Rd files reformatted and many examples extended. ``` -------------------------------- ### VCD Tutorial Plyr Examples (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Revises the `vcd-tutorial` to include examples demonstrating the use of the `plyr` package, highlighting its utility for data manipulation and analysis in conjunction with VCD functions. ```R library(plyr) ``` -------------------------------- ### R: Illustrate structural zeros with example(Caesar) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The Caesar dataset is included with an example demonstrating how to handle structural zeros in log-linear models. This is crucial for accurate model specification. ```R example(Caesar) ``` -------------------------------- ### Install vcdExtra Development Version from GitHub Source: https://github.com/friendly/vcdextra/blob/master/README.md Installs the development version of the vcdExtra package directly from its GitHub repository. This method requires the 'remotes' package and allows for building vignettes, providing the most up-to-date code. ```R if (!require(remotes)) install.packages("remotes") remotes::install_github("friendly/vcdExtra", build_vignettes = TRUE) ``` -------------------------------- ### Install vcdExtra Development Version from GitHub Source: https://github.com/friendly/vcdextra/blob/master/docs/index.html Installs the development version of the vcdExtra package directly from its GitHub repository. This requires the 'remotes' package and allows for building vignettes. ```R if (!require(remotes)) install.packages("remotes") remotes::install_github("friendly/vcdExtra", build_vignettes = TRUE) ``` -------------------------------- ### R: Poisson Model Initialization and Iterations Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/vcdExtra-package.html Demonstrates the initialization and iterative process for a statistical model, likely within the context of the 'vcdextra' package. It shows the setup with a 'poisson' family and 'Mental' data, followed by progress indicators for startup and main iterations. ```R #> + family = poisson, data = Mental) #> Initialising #> Running start-up iterations.. #> Running main iterations........ #> Done #> ``` -------------------------------- ### Removed uses of summarise() and Summarise() from demos and examples (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Removed instances of `summarise()` and `Summarise()` from package demos and examples, as these functions are being deprecated. Users should transition to `LRstats()`. ```R LRstats() ``` -------------------------------- ### Add Demo Housing Vignette (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md A new vignette, `demo-housing.Rmd`, has been added. This vignette utilizes content from `demo/housing.R` to provide practical examples related to housing data. ```R vignette("demo-housing.Rmd") ``` -------------------------------- ### R: Add vcd-tutorial vignette Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md A new vignette titled 'vcd-tutorial' is added. This provides a comprehensive guide to using the functions and features within the vcdExtra package. ```R vignette("vcd-tutorial") ``` -------------------------------- ### R: hatvalues function example Source: https://github.com/friendly/vcdextra/blob/master/extra/vignettes-new/tidyCats.html Demonstrates the usage of the `hatvalues` function in R, specifically when applied to an object of class `loglm`. The example shows an error indicating that `hatvalues` is not implemented for this class. ```R hatvalues(hec.indep) ## Error in UseMethod("hatvalues"): no applicable method for 'hatvalues' applied to an object of class "loglm" ``` -------------------------------- ### VCD Tutorial RC Models Section (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Adds a section to the `vcd-tutorial` vignette discussing RC models (R by C association models), providing explanations and examples for analyzing association patterns in two-way contingency tables. ```R rc_model(table) ``` -------------------------------- ### R: Visualize models with mosaic() and effect plots Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Demonstrates visualizing models fitted in the 'housing' example from the MASS package using mosaic() and effect plots. This helps in understanding model fit and interpretation. ```R example(housing, package="MASS") mosaic() ``` -------------------------------- ### View Vignette Information for vcdExtra Source: https://github.com/friendly/vcdextra/blob/master/docs/index.html Shows how to access information about the vignettes included in the vcdExtra package, including their file names and titles. Vignettes provide in-depth tutorials and examples of package usage. ```R tools::getVignetteInfo("vcdExtra")[,c("File", "Title")] |> knitr::kable() ``` -------------------------------- ### Creating a Matrix for Table Data (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Provides an example of creating a matrix in R to represent table form data, specifically for the Job Satisfaction dataset. It demonstrates initializing the matrix with frequency counts and assigning dimension names for clarity. ```R # A 4 x 4 table Agresti (2002, Table 2.8, p. 57) Job Satisfaction JobSat <- matrix(c( 1, 2, 1, 0, 3, 3, 6, 1, 10,10,14, 9, 6, 7,12,11), 4, 4) dimnames(JobSat) = list( income = c("< 15k", "15-25k", "25-40k", "> 40k"), satisfaction = c("VeryD", "LittleD", "ModerateS", "VeryS") ) JobSat ## satisfaction ## income VeryD LittleD ModerateS VeryS ## < 15k 1 3 10 6 ## 15-25k 2 3 10 7 ## 25-40k 1 6 14 12 ## > 40k 0 1 9 11 ``` -------------------------------- ### Read Local TV Data File in R Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates how to read a local data file 'tv.dat' using the read.table function in R. This is useful when the data is not part of an installed package. ```R tv.data<-read.table("C:/R/data/tv.dat") ``` -------------------------------- ### Create Categorical Data Vectors in R Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/A_creating.html Provides example code for creating sample categorical data using factor() and the sample() function in R. This data is then used to demonstrate the table-related functions. ```R n=500 A <- factor(sample(c("a1","a2"), n, rep=TRUE)) B <- factor(sample(c("b1","b2"), n, rep=TRUE)) C <- factor(sample(c("c1","c2"), n, rep=TRUE)) mydata <- data.frame(A,B,C) ``` -------------------------------- ### Getting Table Dimension Sizes (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Illustrates how to obtain the sizes of each dimension (number of levels for each factor) in a table object using `sapply()` with `dimnames()` in R. This helps in understanding the granularity of the categorical variables. ```R sapply(dimnames(HairEyeColor), length) ## Hair Eye Sex ## 4 4 2 ``` -------------------------------- ### Format Dataset List with kable Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/datasets.html This R code demonstrates how to use the `datasets()` function in conjunction with `knitr::kable()` to create a more readable, table-formatted output of datasets within an R Markdown document. It requires the 'vcdExtra' and 'knitr' packages to be installed. ```R datasets("vcdExtra") |> knitr::kable() ``` -------------------------------- ### Install vcdExtra from CRAN Source: https://github.com/friendly/vcdextra/blob/master/docs/index.html Installs the released version of the vcdExtra package from the Comprehensive R Archive Network (CRAN). This is the standard way to get the latest stable release. ```R install.packages("vcdExtra") ``` -------------------------------- ### Stepwise Log-Linear Model Selection Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/Hoyt.html This example demonstrates a forward stepwise model selection process starting from a baseline model (`hoyt.mod0`) using the `step` function. The goal is to find a parsimonious model by iteratively adding terms. The `scope` argument defines the maximum model to consider. Requires MASS and vcdextra packages. ```R steps <- step(hoyt.mod0, direction="forward", scope=~Status*Sex*Rank*Occupation) steps$anova ``` -------------------------------- ### Creating a Matrix for Table Data (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/A_creating.html Provides an example of creating a matrix in R to represent table form data, specifically for the Job Satisfaction dataset. It demonstrates initializing the matrix with frequency counts and assigning dimension names for clarity. ```R # A 4 x 4 table Agresti (2002, Table 2.8, p. 57) Job Satisfaction JobSat <- matrix(c( 1, 2, 1, 0, 3, 3, 6, 1, 10,10,14, 9, 6, 7,12,11), 4, 4) dimnames(JobSat) = list( income = c("< 15k", "15-25k", "25-40k", "> 40k"), satisfaction = c("VeryD", "LittleD", "ModerateS", "VeryS") ) JobSat ## satisfaction ## income VeryD LittleD ModerateS VeryS ## < 15k 1 3 10 6 ## 15-25k 2 3 10 7 ## 25-40k 1 6 14 12 ## > 40k 0 1 9 11 ``` -------------------------------- ### R: Add demos for quasi-likelihood and other models Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md New demonstrations are added, including mental-glm, ucb-glm, vision-quasi, occStatus, and yaish-unidiff. These illustrate various modeling techniques and datasets. ```R demo(mental-glm) demo(ucb-glm) ``` -------------------------------- ### Example: seq_mosaic with Custom Panel and Shading (Bugged) Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/seq_mosaic.html Shows an example of using custom panel functions (like 'sieve') and shading options ('shading_Friendly', 'labeling_values') with seq_mosaic. This example is marked as potentially buggy and is enclosed in a \dontrun{} block. ```R if (FALSE) { # \dontrun{ seq_mosaic(Titanic, type="mutual", panel=sieve, gp=shading_Friendly, labeling=labeling_values) } } ``` -------------------------------- ### Create Frequency Table from Scratch (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/A_creating.html Shows how to create a frequency table in R using `expand.grid()` to generate combinations of factors and `c()` to provide the corresponding counts. This is useful for entering small frequency tables directly. ```R # Agresti (2002), table 3.11, p. 106 GSS <- data.frame( expand.grid(sex = c("female", "male"), party = c("dem", "indep", "rep")), count = c(279,165,73,47,225,191)) GSS ## sex party count ## 1 female dem 279 ## 2 male dem 165 ## 3 female indep 73 ## 4 male indep 47 ## 5 female rep 225 ## 6 male rep 191 names(GSS) ## [1] "sex" "party" "count" str(GSS) ## 'data.frame': 6 obs. of 3 variables: ## $ sex : Factor w/ 2 levels "female","male": 1 2 1 2 1 2 ## $ party: Factor w/ 3 levels "dem","indep",..: 1 1 2 2 3 3 ## $ count: num 279 165 73 47 225 191 sum(GSS$count) ## [1] 980 ``` -------------------------------- ### Fix mosaic3d rgl example problem Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Resolves a problem encountered when using the rgl package within examples for the mosaic3d function. ```R Fix problem re use of rgl in `[mosaic3d()](../reference/mosaic3d.html)` examples ``` -------------------------------- ### Load R Packages for vcdExtra Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/demo-housing.html Loads the vcdExtra and MASS packages, which are necessary for performing categorical data analysis and accessing the housing dataset within this vignette. ```R library(vcdExtra) library(MASS) library(effects) ``` -------------------------------- ### Generate and Display 3-Way Table with ftable() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates creating a three-way frequency table using `table()` and then displaying it attractively using `ftable()`. ```R mytable <- table(A, B, C) ftable(mytable) ``` -------------------------------- ### Load Fungicide Dataset in R Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/Fungicide.html Demonstrates how to load the Fungicide dataset into an R environment. This is typically the first step before performing any analysis or visualization. ```R data(Fungicide) ``` -------------------------------- ### Load Libraries for Categorical Data Analysis Source: https://github.com/friendly/vcdextra/blob/master/extra/vignettes-new/tidyCats.html This snippet demonstrates how to load the necessary libraries, 'MASS' and 'vcdExtra', which are essential for performing categorical data analysis and utilizing the functionalities provided by the tidyCat project. ```R library(MASS) library(vcdExtra) ``` -------------------------------- ### Creating and Visualizing Mosaic Plot with `xtabs()` and `mosaic()` in R Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates creating a contingency table using `xtabs()` and then visualizing it with a mosaic plot using the `mosaic()` function from the `vcd` package. This example uses the `Arthritis` dataset to show the relationship between 'Treatment' and 'Improved' factors. ```R data(Arthritis, package="vcd") art <- xtabs(~Treatment + Improved, data = Arthritis) mosaic(art, gp = shading_max, split_vertical = TRUE, main="Arthritis: [Treatment] [Improved]") ``` -------------------------------- ### Load vcdExtra and MASS Packages Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/a5-demo-housing.html Loads the 'vcdExtra' and 'MASS' packages, which are necessary for performing categorical data analysis and accessing datasets like 'housing'. ```R library(vcdExtra) library(MASS) library(effects) ``` -------------------------------- ### Example: Plotting with cutfac in R Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/cutfac.html This example demonstrates using cutfac to discretize a numeric variable ('chronic') for plotting. It creates a scatter plot where the y-axis is the log of physician office visits and the x-axis represents the discretized 'chronic' variable, using cutfac for interval creation. It also shows an example with custom breaks for the 'hospital' variable. ```R if (require(AER)) { data("NMES1988", package="AER") nmes <- NMES1988[, c(1, 6:8, 13, 15, 18)] plot(log(visits+1) ~ cutfac(chronic), data = nmes, ylab = "Physician office visits (log scale)", xlab = "Number of chronic conditions", main = "chronic") plot(log(visits+1) ~ cutfac(hospital, c(0:2, 8)), data = nmes, ylab = "Physician office visits (log scale)", xlab = "Number of hospital stays", main = "hospital") } ``` -------------------------------- ### R: Proof-of-concept for 3D mosaic displays Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md A demo, mosaic3d-demo, is provided as a proof-of-concept for generating 3D mosaic displays. This showcases the capabilities of the new mosaic3d() function. ```R demo(mosaic3d-demo) ``` -------------------------------- ### Fix problem re use of rgl in mosaic3d() examples (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Resolved an issue related to the usage of the `rgl` package within the examples for `mosaic3d()`. This ensures the 3D plotting functionality works as expected. ```R mosaic3d(..., rgl = TRUE) ``` -------------------------------- ### Install vcdExtra from CRAN Source: https://github.com/friendly/vcdextra/blob/master/README.md Installs the released version of the vcdExtra package from the Comprehensive R Archive Network (CRAN). This is the standard method for obtaining stable package versions. ```R install.packages("vcdExtra") ``` -------------------------------- ### Generate and Display 3-Way Table with ftable() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/a1-creating.html Demonstrates creating a three-way frequency table using `table()` and then displaying it attractively using `ftable()`. ```R mytable <- table(A, B, C) ftable(mytable) ``` -------------------------------- ### Example: Birthweight Model Fit Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/HLtest.html This example demonstrates how to use the HLtest function to assess the goodness of fit for a logistic regression model predicting low birthweight using the birthwt dataset. ```R data(birthwt, package="MASS") # how to do this without attach? attach(birthwt) race = factor(race, labels = c("white", "black", "other")) ptd = factor(ptl > 0) ftv = factor(ftv) levels(ftv)[-(1:2)] = "2+" bwt <- data.frame(low = factor(low), age, lwt, race, smoke = (smoke > 0), ptd, ht = (ht > 0), ui = (ui > 0), ftv) detach(birthwt) options(contrasts = c("contr.treatment", "contr.poly")) BWmod <- glm(low ~ ., family=binomial, data=bwt) (hlt <- HLtest(BWmod)) str(hlt) ``` -------------------------------- ### Create and Inspect Frequency Table (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Shows how to create a frequency table in R using `expand.grid` and `c` for counts, then inspects the resulting data frame. This is useful for entering small frequency tables directly. ```R # Agresti (2002), table 3.11, p. 106 GSS <- data.frame( expand.grid(sex = c("female", "male"), party = c("dem", "indep", "rep")), count = c(279,165,73,47,225,191)) GSS ## sex party count ## 1 female dem 279 ## 2 male dem 165 ## 3 female indep 73 ## 4 male indep 47 ## 5 female rep 225 ## 6 male rep 191 names(GSS) ## [1] "sex" "party" "count" str(GSS) ## 'data.frame': 6 obs. of 3 variables: ## $ sex : Factor w/ 2 levels "female","male": 1 2 1 2 1 2 ## $ party: Factor w/ 3 levels "dem","indep",..: 1 1 2 2 3 3 ## $ count: num 279 165 73 47 225 191 sum(GSS$count) ## [1] 980 ``` -------------------------------- ### Conditional Density Plot Example Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/continuous.html A basic example of creating a conditional density plot using the `cdplot()` function from the R graphics package to visualize the relationship between the 'Improved' response and the 'Age' predictor in the Arthritis dataset. ```R cdplot(Improved ~ Age, data = Arthritis) ``` -------------------------------- ### Calculate Proportions with prop.table() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Illustrates using `prop.table()` to calculate cell percentages, row percentages, and column percentages from a two-way table. ```R prop.table(mytable) prop.table(mytable, 1) prop.table(mytable, 2) ``` -------------------------------- ### Install vcdExtra Development Version from R-universe Source: https://github.com/friendly/vcdextra/blob/master/README.md Installs the development version of the vcdExtra package from its R-universe repository. This provides access to the latest features and bug fixes, but may be less stable than the CRAN version. ```R install.packages("mvinfluence", repos = c('https://friendly.r-universe.dev')) ``` -------------------------------- ### Example: Basic seq_mosaic on Titanic Data Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/seq_mosaic.html Demonstrates the basic usage of the seq_mosaic function with the built-in Titanic dataset. This example generates mosaic plots for joint independence models, with the 'Survived' variable considered last. ```R data(Titanic, package="datasets") seq_mosaic(Titanic) # models of joint independence, Survived last ``` -------------------------------- ### List Datasets in vcdExtra Source: https://github.com/friendly/vcdextra/blob/master/docs/index.html Demonstrates how to list all available datasets within the vcdExtra package and retrieve their titles and descriptions. This is useful for exploring the data available for analysis. ```R vcdExtra::datasets("vcdExtra")[,1] ``` -------------------------------- ### R: Example using Crossings with Hauser79 data Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/Crossings.html This example demonstrates how to use the `Crossings` function with the `Hauser79` dataset in R. It shows how to fit a loglinear model including the `Crossings` term and compare it with a model including both `Crossings` and `Diag` terms using `LRstats`. ```R data(Hauser79) # display table structable(~Father + Son, data=Hauser79) hauser.indep <- gnm(Freq ~ Father + Son, data=Hauser79, family=poisson) hauser.CR <- update(hauser.indep, ~ . + Crossings(Father,Son)) LRstats(hauser.CR) hauser.CRdiag <- update(hauser.indep, ~ . + Crossings(Father,Son) + Diag(Father,Son)) LRstats(hauser.CRdiag) ``` -------------------------------- ### Example Usage of zero.test with Frequency Table Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/zero.test.html Illustrates using `zero.test` with a frequency table derived from data. This example uses the `PhdPubs` dataset to test for zero inflation in the `articles` variable, both directly and via its frequency table. ```R data(PhdPubs, package="vcdExtra") zero.test(PhdPubs$articles) phd.tab <- table(PhdPubs$articles) zero.test(phd.tab) ``` -------------------------------- ### vcdExtra gets a hex sticker Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Announces the addition of a hex sticker for the vcdExtra package. ```R vcdExtra gets a hex sticker ``` -------------------------------- ### Now use importsFrom() for all functions from recommended packages (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The package now utilizes `importsFrom()` to explicitly import all functions from its recommended packages. This enhances clarity and namespace management. ```R importFrom(package, function) ``` -------------------------------- ### Use importsFrom for Recommended Packages (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The package now uses `importsFrom()` for all functions imported from recommended packages. This improves namespace management and clarity. ```R importFrom(package, function) ``` -------------------------------- ### Enhance frequency tables vignette Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Improves the 'Creating and manipulating frequency tables' vignette (`vignettes/creating.Rmd`) with additional content and examples. ```R Enhanced the vignette, “Creating and manipulating frequency tables”, `vignettes/creating.Rmd` ``` -------------------------------- ### loddsratio.Rd Fix Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html The documentation for `loddsratio.Rd` has been fixed in vcdExtra to work with the revised `vcd::CoalMiners` data. This ensures that examples and usage descriptions are accurate. ```R loddsratio() ``` -------------------------------- ### Load vcdExtra Tutorial Vignette in R Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/vcdExtra-package.html This command loads the 'vcd-tutorial' vignette, which provides guidance on working with categorical data in R using the vcd and vcdExtra packages. It covers various aspects of data manipulation and model fitting. ```R vignette("vcd-tutorial", package = "vcdExtra") ``` -------------------------------- ### Revise mosaic vignette Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Significantly updates the 'mosaic.Rmd' vignette on mosaic displays, adding examples for square tables and row/column variable permutation. ```R the vignette `mosaic.Rmd` on mosaic displays has been extensively revised with examples for square tables and permutation of row / column variables. ``` -------------------------------- ### Calculate Proportions with prop.table() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/a1-creating.html Illustrates using `prop.table()` to calculate cell percentages, row percentages, and column percentages from a two-way table. ```R prop.table(mytable) prop.table(mytable, 1) prop.table(mytable, 2) ``` -------------------------------- ### Get Unique Method Tags Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/datasets.html Extracts and returns a vector of all unique method tags identified from the dataset processing. ```R unique(tag_dset$tag) ``` -------------------------------- ### Suggest Seriation for Correspondence Analysis (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The package now suggests the `seriation` package. This allows for the illustration of Correspondence Analysis (CA) re-ordering of rows and columns, enhancing visualization capabilities. ```R Suggests: seriation ``` -------------------------------- ### Add Mobility tables vignette Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Introduces a new vignette, 'Mobility tables', featuring comprehensive examples of models and graphs for square mobility tables. ```R Created a new vignette, “Mobility tables”, with extensive examples of models and graphs for square mobility tables. ``` -------------------------------- ### Load and View Accident Data in R Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/Accident.html Demonstrates how to load the 'Accident' dataset into an R environment and display the first few rows to inspect its structure and content. This is a common first step in data analysis. ```R data(Accident) head(Accident) ``` -------------------------------- ### Remove summarise() and Summarise() from Demos (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Removed usages of `summarise()` and `Summarise()` from demos and examples in preparation for their deprecation. Users should now use `LRstats()`. ```R LRstats() ``` -------------------------------- ### Mean Residuals Function (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Adds the `meanResiduals()` function and extends `mosaic.glm()` examples, likely to improve the calculation and visualization of residuals in generalized linear models. ```R meanResiduals(object, ...) ``` ```R mosaic.glm(object, ...) ``` -------------------------------- ### Explore Housing Data Structure Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/demo-housing.html Loads the housing dataset from the MASS package and displays its structure. This helps in understanding the variables, their types, and the overall organization of the frequency table. ```R data(housing, package="MASS") str(housing) ``` -------------------------------- ### Fixed examples/vignette for ggplot_2.0.0 (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Ensured that examples and vignettes are compatible with `ggplot2` version 2.0.0, addressing any potential issues arising from updates in that version. ```R library(ggplot2) ``` -------------------------------- ### Add Demos for Mosaic Displays and Model Comparisons Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Introduces several new demos: mosaic-hec for comparing 2D and 3D mosaics, mosaic3d-demo as a proof-of-concept for 3D mosaic displays, Wong3-1 for three-way tables and conditional association, and housing for visualizing models using mosaic() and effect plots. ```R demo(mosaic-hec) demo(mosaic3d-demo) demo(Wong3-1) demo(housing) ``` -------------------------------- ### Doubledecker Plots in R Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md This snippet highlights the addition of doubledecker plots, with examples provided in `Dyke.Rd` and the `vcd-tutorial` vignette, demonstrating their use for visualizing categorical data. ```R doubledecker plots Dyke.Rd vcd-tutorial vignette ``` -------------------------------- ### Load and Inspect Housing Data Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/a5-demo-housing.html Loads the 'housing' dataset from the 'MASS' package and displays its structure. The 'housing' dataset contains frequency counts from a survey on housing conditions, classified by satisfaction, dwelling type, perceived influence, and contact with residents. ```R data(housing, package="MASS") str(housing) ``` -------------------------------- ### Fix examples/vignette for ggplot2 2.0.0 (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Updates examples and vignettes to ensure compatibility with `ggplot2` version 2.0.0. This addresses any breaking changes introduced in that version. ```R library(ggplot2) ``` -------------------------------- ### Import Functions from Recommended Packages Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html vcdExtra now uses `importsFrom()` for all functions from recommended packages. This improves package namespace management and reduces potential conflicts. ```R importsFrom() ``` -------------------------------- ### Fix mosaic3d() rgl Usage (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md Addresses a problem concerning the use of `rgl` within the `mosaic3d()` examples. This ensures that the 3D visualizations function correctly. ```R mosaic3d() ``` -------------------------------- ### Fit Model with MASS::loglm Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/demo-housing.html Demonstrates fitting a statistical model using the loglm() function from the MASS package, which employs an iterative proportional scaling algorithm. This is presented as an alternative method to update() for fitting models with added association terms. ```R (house.loglm1 <- MASS::loglm(Freq ~ Infl * Type * Cont + Sat*(Infl + Type + Cont), data = housing)) ``` -------------------------------- ### vcdExtra Gets a Hex Sticker (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The `vcdExtra` package now includes a hex sticker. This serves as a visual identifier for the package, often used in presentations and online. ```R vcdExtra hex sticker ``` -------------------------------- ### Collapsing Factors in VCD Tutorial (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Extends the `vcd-tutorial` vignette with a section on collapsing factors in contingency tables, providing guidance on how to simplify complex tables while preserving important information. ```R collapse_table(table, ...) ``` -------------------------------- ### Load and Display HouseTasks Dataset (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/a4-mosaics.html Loads the 'HouseTasks' dataset from the 'vcdExtra' package and displays its contents. This dataset represents frequencies of household tasks performed by couples, categorized by task and performer. ```R data("HouseTasks", package = "vcdExtra") HouseTasks ``` -------------------------------- ### Example: Plotting Pairwise Mosaics Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/mosaic.glmlist.html Demonstrates how to view all pairwise mosaic plots for a given dataset using the xtabs function to create a frequency table. ```R data(JobSatisfaction, package="vcd") # view all pairwise mosaics pairs(xtabs(Freq~management+supervisor+own, data=JobSatisfaction), ``` -------------------------------- ### R: Deprecated summarise functions Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/vcdExtra-deprecated.html Provides usage examples for deprecated 'summarise' functions in the vcdExtra package. These functions are intended for compatibility with older versions and are superseded by LRstats. ```R summarise(...) # summarise.glm(...) # summarise.glmlist(...) # summarise.loglm(...) # summarise.loglmlist(...) ``` -------------------------------- ### R: Create 3-Way Frequency Table with xtabs() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates how to create a 3-way frequency table using the `xtabs()` function in R with a formula specifying the variables. It also shows how to print the table using `ftable()` and perform a chi-square test of independence using `summary()`. ```R # 3-Way Frequency Table mytable <- xtabs(~A+B+C, data=mydata) ftable(mytable) # print table ## C c1 c2 ## A B ## a1 b1 45 71 ## b2 59 55 ## a2 b1 62 76 ## b2 76 56 summary(mytable) # chi-square test of indepedence ## Call: xtabs(formula = ~A + B + C, data = mydata) ## Number of cases in table: 500 ## Number of factors: 3 ## Test for independence of all factors: ## Chisq = 9.888, df = 4, p-value = 0.04235 ``` -------------------------------- ### Compare CMH Test with mantelhaen.test Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/CMHtest.html This example shows how to use the `mantelhaen.test` function as an alternative to `CMHtest` for performing the Cochran-Mantel-Haenszel test. It highlights the direct comparison of results. ```R mantelhaen.test(MSPatients) ``` -------------------------------- ### Print Kappa for Stratified Tables Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/print.Kappa.html Illustrates the application of the print.Kappa method to stratified tables, showing how it handles multiple Kappa calculations for different strata. This is useful for analyzing agreement across various subgroups. ```R # stratified 3-way table apply(MSPatients, 3, Kappa) #> $Winnipeg #> value ASE z Pr(>|z|) #> Unweighted 0.2079 0.05046 4.121 3.767e-05 #> Weighted 0.3797 0.05167 7.350 1.988e-13 #> #> $`New Orleans` #> value ASE z Pr(>|z|) #> Unweighted 0.2965 0.07850 3.777 1.587e-04 #> Weighted 0.4773 0.07303 6.535 6.352e-11 #> ``` -------------------------------- ### Doubledecker Plots for Dyke Data (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/news/index.html Enhances the `Dyke.Rd` documentation to include examples of doubledecker plots, a visualization technique for categorical data, improving the understanding of associations in contingency tables. ```R doubledecker(Dyke) ``` -------------------------------- ### Inspect Arthritis Data Structure (R) Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates how to inspect the structure and variable names of the Arthritis dataset, which is in case form. This helps understand the data before analysis. ```R names(Arthritis) # show the variables ## [1] "ID" "Treatment" "Sex" "Age" "Improved" str(Arthritis) # show the structure ## 'data.frame': 84 obs. of 5 variables: ## $ ID : int 57 46 77 17 36 23 75 39 33 55 ... ## $ Treatment: Factor w/ 2 levels "Placebo","Treated": 2 2 2 2 2 2 2 2 2 2 ... ## $ Sex : Factor w/ 2 levels "Female","Male": 2 2 2 2 2 2 2 2 2 2 ... ## $ Age : int 27 29 30 32 46 58 59 59 63 63 ... ## $ Improved : Ord.factor w/ 3 levels "None"<"Some"<..: 2 1 1 3 3 3 1 3 1 1 ... head(Arthritis,5) # first 5 observations, same as Arthritis[1:5,] ## ID Treatment Sex Age Improved ## 1 57 Treated Male 27 Some ## 2 46 Treated Male 29 None ## 3 77 Treated Male 30 None ## 4 17 Treated Male 32 Marked ## 5 36 Treated Male 46 Marked ``` -------------------------------- ### Revise Mosaic Display Vignette (R) Source: https://github.com/friendly/vcdextra/blob/master/NEWS.md The `mosaic.Rmd` vignette, which focuses on mosaic displays, has been significantly revised. It now includes updated examples for square tables and the permutation of row/column variables. ```R vignette("mosaic.Rmd") ``` -------------------------------- ### Display HairEyeColor Table with structable() Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/creating.html Demonstrates the default usage of the `structable()` function to display the HairEyeColor dataset, showing a multi-way frequency table. ```R structable(HairEyeColor) ``` -------------------------------- ### Mosaic Plot with Expected Values from Conditional Model Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/loglin-utilities.html This example demonstrates creating a mosaic plot with expected values calculated from a conditional loglinear model using `conditional(3)`. ```R mosaic(HairEyeColor, expected=conditional(3)) ``` -------------------------------- ### Fit Loglinear Model using MASS::loglm Source: https://github.com/friendly/vcdextra/blob/master/docs/reference/loglin-utilities.html This example demonstrates how to use the `loglin2formula` function to obtain a formula for `MASS::loglm` and then fit the loglinear model to the `HairEyeColor` dataset. ```R require(MASS) loglm(cond3, data=HairEyeColor) #> Call: #> loglm(formula = cond3, data = HairEyeColor) #> #> Statistics: #> X^2 df P(> X^2) #> Likelihood Ratio 156.6779 18 0 #> Pearson 147.9440 18 0 ``` -------------------------------- ### Load vcdExtra and MASS Libraries Source: https://github.com/friendly/vcdextra/blob/master/docs/articles/tidyCats.html This snippet demonstrates how to load the necessary R libraries, 'MASS' and 'vcdExtra', which are required for categorical data analysis and the proposed 'tidyCat' functionality. ```r library(MASS) library(vcdExtra) ```