| Type: | Package | 
| Title: | Tools for Exploring Multiple Response Data | 
| Version: | 2.3.0 | 
| BugReports: | https://github.com/iNZightVIT/iNZightMR/issues | 
| Contact: | inzight_support@stat.auckland.ac.nz | 
| URL: | https://inzight.nz | 
| Depends: | R (≥ 2.13) | 
| Imports: | grid, grDevices, graphics, stats, utils | 
| Suggests: | iNZightPlots, testthat, covr | 
| LazyData: | true | 
| Description: | Interaction and analysis of multiple response data, along with other tools for analysing these types of data including missing value analysis and calculation of standard errors for a range of covariance matrix results (proportions, multinomial, independent samples, and multiple response). | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| Language: | en-GB | 
| RoxygenNote: | 7.2.3 | 
| NeedsCompilation: | no | 
| Packaged: | 2024-01-17 19:14:52 UTC; tom | 
| Author: | Tom Elliott | 
| Maintainer: | Tom Elliott <tom.elliott@auckland.ac.nz> | 
| Repository: | CRAN | 
| Date/Publication: | 2024-01-17 19:40:02 UTC | 
iNZightMR: Multiple Response Data Analysis
Description
The iNZightMR package provides a suite of functions which can be used in the analysis of multiple response data. It is used in the iNZight software package.
Author(s)
Junjie Zeng, Tom Elliott
Multiple response barplot
Description
Draws a barplot of a multiple response object (MRO), showing response rates for each option along with confidence intervals and comparison intervals.
Usage
barplotMR(obj, ...)
## S3 method for class 'mrocalc'
barplotMR(obj, ...)
## S3 method for class 'bymrocalc'
barplotMR(obj, g1.level = NULL, g2.level = "_MULTI", ...)
## S3 method for class 'between'
barplotMR(obj, ...)
## S3 method for class 'b2'
barplotMR(obj, g1.level = NULL, ...)
Arguments
| obj | an  | 
| ... | additional parameters, currently not used | 
| g1.level | vector of subset variable 1 levels to show | 
| g2.level | vector of subset variable 2 levels to show | 
Methods (by class)
-  barplotMR(mrocalc): method for classmrocalc
-  barplotMR(bymrocalc): method for classbymrocalc
-  barplotMR(between): method for classbetween
-  barplotMR(b2): method for classb2
Author(s)
Junjie Zheng
Examples
if (requireNamespace("iNZightPlots")) {
    require(iNZightPlots)
    mr <- iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
        data = census.at.school.5000
    )
    barplotMR(mroPara(mr))
    barplotMR(byMRO(mr, ~gender, mroPara))
}
Compute Between se's
Description
Between SEs
Usage
between(bymro)
Arguments
| bymro | a bymro object | 
Value
something about between.
Author(s)
Junjie Zheng
Examples
mr <- iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
    data = census.at.school.5000)
(bt <- between(byMRO(mr, ~gender, mroPara)))
if (requireNamespace("iNZightPlots"))
    barplotMR(bt)
Calculate MRO inference for subsets
Description
Constructs a multiple response object (MRO) subset by another explanatory variable.
Usage
byMRO(mro.obj, formula, FUN, ...)
Arguments
| mro.obj | an mro object (created by  | 
| formula | variable for subsetting, as a formula (e.g.,  | 
| FUN | the function to apply to subsets | 
| ... | additional arguments passed to  | 
Value
an object with classes of by and bymrocalc
See Also
Examples
mr <- iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
    data = census.at.school.5000
)
byMRO(mr, ~gender, mroPara)
byMRO(mr, ~ gender + handed, mroPara)
Calculate missing observation summary
Description
Calculates the summary of missingness in a data set.
Usage
calcmissing(obj, ...)
## S3 method for class 'data.frame'
calcmissing(obj, MRO.case = FALSE, ...)
## S3 method for class 'mro'
calcmissing(obj, ...)
Arguments
| obj | An object | 
| ... | additional arguments | 
| MRO.case | does something with rownames | 
Value
Missing value object
Methods (by class)
-  calcmissing(data.frame): Method for a dataframe
-  calcmissing(mro): accepts a whole mr.object , which is first mro.mat, second element labels, third element the input data frame.
Author(s)
Junjie Zeng
See Also
plotcombn
Examples
calcmissing(census.at.school.5000[, 1:20])
Census at School 5000
Description
A dataset containing 5000 observations from a New Zealand census of school students. It includes binary response variables.
Usage
census.at.school.5000
Format
A data frame with 72 variables and 5000 rows.
- X
- unique identifier for each observation 
- gender
- their biological gender 
- age
- their age, years 
- country
- The country the student is from 
- country_en
- Country code 
- country_mi
- A different country code 
- ethniceng
- binary for ethnicity english 
- ethnicmri
- binary for ethnicity maori 
- ethnicwsm
- binary for ethnicity wsm 
- ethniccok
- binary for ethnicity cok 
- ethnicton
- binary for ethnicity tonga 
- ethnicniu
- binary for ethnicity niue 
- ethnicchn
- binary for ethnicity china 
- ethnicind
- binary for ethnicity india 
- ethnicother
- factor for other ethnicity 
- ethnicother_en
- factor for other ethnicity_en 
- ethnicother_mi
- factor for other ethnicity_mi 
- languages
- how many languages they know 
- handed
- left, right, or ambi 
- height
- height measurement, cm 
- rightfoot
- length of the right foot, mm 
- armspan
- their armspan measurement, cm 
- wrist
- wrist measurement 
- neck
- neck measurement 
- popliteal
- another measurement 
- indexfinger
- index finger measurement 
- ringfinger
- ring finger measurement 
- hairlength
- the length of their hair 
- travel
- travel method used to get to school 
- timetravel
- how long they spend travelling 
- bagweightraw
- the weight of the bag 
- bagweight
- weight of the bag 
- bagcarry
- factor of how they're carrying 
- favlearning
- their favourite subject 
- favlearningmo
- their favourite subject? 
- memory
- a memory score 
- reaction
- a reaction score 
- sport
- what sport they play 
- sport_en
- what sport they play 
- techtv
- binary for use of TV 
- techmp3
- binary for use of mp3 
- techinternet
- binary for use of the internet 
- techmobinternet
- binary for use of mobile internet 
- techfacebook
- binary for use of facebook 
- techtwitter
- binary for use of twitter 
- techbebo
- binary for use of bebo 
- techmyspace
- binary for use of myspace 
- techskype
- binary for use of skype 
- techconsole
- binary for use of a console 
- technone
- binary for use of no technology 
- cellmonths
- how many months they've had a cellphone? 
- onlinemusic
- binary for if they listen to music online 
- onlinevideo
- binary for if they watch video online 
- onlinegame
- binary for if they play games online 
- onlinefriend
- binary for if they talk to friends online 
- onlineschool
- binary for if they access school online 
- onlineother
- binary for if they do anything else online 
- onlinenone
- binary for if they do nothing online 
- bedtime
- hours spent in bed 
- waketime
- hours spent awake 
- favtvshow
- the name of their favourite TV show 
- favtvshow_en
- the name of their favourite TV show 
- importwarm
- binary about warm 
- importpollution
- binary about pollution 
- importrecycling
- binary about recycling 
- importwater
- binary about water 
- importlifestyle
- binary about lifestyle 
- importenergy
- binary about energy 
- importgovern
- binary about government 
- importcomputer
- binary about computer 
- region
- number of the region they're in 
- year
- their school year 
Source
http://new.censusatschool.org.nz/
Create iNZightMR multiple response object (MRO)
Description
Creates a multiple response object (MRO) containing binary response matrix (zeros and ones) as well as the input data source.
Usage
iNZightMR(frm, data, Labels = NULL, inverse = FALSE, ...)
Arguments
| frm | formula containing the response variables | 
| data | a data.frame containing response and explanatory variables | 
| Labels | labels for the response categories; by default, the function
will attempt to. Can also be the function  | 
| inverse | if  | 
| ... | additional arguments, passed to  | 
Details
The individual response variable names can be detected from the
variable name by passing Labels = substrsplit.
For example, in 'ethniceng' and 'ethnicmri', 'ethnic' is common
to both, so the labels will be 'eng' and 'mri'.
If a user wants to inverse the response (zeros becomes ones), then pass
inverse = TRUE. This is useful when the responses are characters
(such as "correct" and "wrong", where correct would be given a zero)
and the order needs reversing (so that correct is 1 instead).
Value
An mro object containing a multiple response binary matrix and input
data source
See Also
Examples
mr <- iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
    data = census.at.school.5000)
# users can also override the variable names
iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
    Labels = c("gaming", "youtube", "spotify"),
    data = census.at.school.5000
)
Margin of Error Calculation
Description
Computes the margin of error for various objects.
Usage
moecalc(
  x,
  factorname = NULL,
  levelnames = NULL,
  coef.idx = NULL,
  est = NULL,
  ci = NULL,
  base = TRUE,
  basename = "base",
  conf.level = 1.96
)
Arguments
| x | the object for which we compute margins of error | 
| factorname | name of factor | 
| levelnames | names of factor levels | 
| coef.idx | index of coefficient to use | 
| est | estimates | 
| ci | confidence intervals | 
| base | baseline | 
| basename | name of baseline | 
| conf.level | level of confidence to use | 
Details
If x is a model, must have factorname or coefficient index (coef.idx)
If input factorname, will compute ErrBars by factorname (for given model)
If input coefficient index, will compute ErrBars simply by index only (even they are not factor)
If x is ses.moecalc object, will compute ErrBars simply by given ses.moecalc object
Value
a moecalc object
Examples
fit <- lm(Sepal.Length ~ Species, data = iris)
(mc <- moecalc(fit, "Species"))
summary(mc)
plot(mc)
Calculate MRO inference
Description
Calculates required proportions, their differences, variance-covariance matrices, standard errors of differences, and comparison intervals for differences, over all of the data. To compute values over various subsets of another explanatory variable, see by.
Usage
mroPara(obj, conf.levels = 1.96, nonparallel = NULL)
Arguments
| obj | an MRO object created by  | 
| conf.levels | confidence level to use, default is 1.96 for 95% intervals | 
| nonparallel | Should these things be parallel? | 
Value
An object of class mrocalc
See Also
Examples
mr <- iNZightMR(online ~ onlinegame + onlinevideo + onlinemusic,
    data = census.at.school.5000)
mrp <- mroPara(mr)
Missing Value plot
Description
Plot of Missing Value combinations
Usage
plotcombn(obj)
Arguments
| obj | a calcmissing object | 
Value
summarised info for plot
Author(s)
Junjie Zeng
Examples
plotcombn(census.at.school.5000[, 10:25])
Independent Binomial Proportions
Description
Compute SEs for Independent Binomial Proportions
Usage
seBinprops(ns, phats)
Arguments
| ns | the number of observations in the independent groups | 
| phats | the proportions of TRUE/1's etc. | 
Value
an ses.moecalc object
Author(s)
Junjie Zeng
Examples
seBinprops(c(50, 30), c(0.3, 0.7))
Compute standard error for covariance matrix
Description
Compute the standard error information for a given covariance matrix.
Usage
seCovs(covs, addbase = FALSE)
Arguments
| covs | covariance matrix | 
| addbase | logical, is there a baseline? | 
Value
an ses.moecalc object
Author(s)
Junjie Zeng
Examples
seCovs(cov(iris[, -5]))
Independent Standard errors given
Description
Returns ses.moecalc for given SEs
Usage
seIndepSes(ses)
Arguments
| ses | the standard errors | 
Value
an ses.moecalc object
Author(s)
Junjie Zeng
Examples
seIndepSes(c(0.02, 0.05, 0.1))
Compute SE for Multinomial proportions
Description
SEs for Multinomial Proportions
Usage
seMNprops(n, phat)
Arguments
| n | the number of observations in each group | 
| phat | the estimates proportions for each group | 
Value
an ses.moecalc object
Author(s)
Junjie Zeng
Examples
phat <- table(iris$Species) / nrow(iris)
seMNprops(nrow(iris), phat)
Multiple binary response
Description
SE's for multiple binary response
Usage
seMRprops(obj)
Arguments
| obj | something that can be turned into a matrix | 
Value
an ses.moecalc object
Author(s)
Junjie Zeng
Examples
x <- data.frame(
    v1 = rbinom(20, 1, 0.8),
    v2 = rbinom(20, 1, 0.3),
    v3 = rbinom(20, 1, 0.5)
)
seMRprops(x)
Extract Common Name from variables
Description
Help mro variables extract common name out
Usage
substrsplit(obj, split_string = "")
Arguments
| obj | It can be a vector or data frame, however,  | 
| split_string | Specification of a string to allow splits on (e.g., use " " to only allow splitting at words). | 
Value
A list with common character and unique variable name respectively
Examples
substrsplit(c("varx", "vary", "varz"))
strings <- c("Do you like eating eggs?", "Do you like elephants?" , "Do you like elections?")
substrsplit(strings)
substrsplit(strings, split_string = " ")